From 4b0e27e83e062ffdd79fc77b8e3880ae2f848f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 10:52:58 +0100 Subject: [PATCH 01/13] add not working version --- .gitignore | 29 + .npmignore | 3 +- .npmrc | 3 + CHANGELOG.md | 1 + TODO.md | 7 +- configs/esbuild/index.js | 20 + configs/esbuild/package.json | 9 + configs/eslint-config/index.js | 69 + configs/eslint-config/package.json | 16 + configs/tsconfig/base.json | 20 + configs/tsconfig/package.json | 11 + {example => demo-app}/demo-styles.css | 0 {example => demo-app}/demo-ui-tools.js | 0 {example => demo-app}/elven.js | 0 {example => demo-app}/index.html | 0 dev-server.mjs | 2 +- esbuild.config.cjs | 38 - eslint.config.mjs | 74 +- package-lock.json | 5008 ----------------- package.json | 69 +- .../mobile-signing-provider/esbuild.config.js | 21 + .../mobile-signing-provider/package.json | 24 + .../src/mobile-signing-provider.ts | 5 + packages/elven.js/esbuild.config.js | 21 + packages/elven.js/package.json | 24 + .../elven.js/src}/auth/account-sync.ts | 0 .../elven.js/src}/auth/expires-at.ts | 0 .../src}/auth/init-extension-provider.ts | 0 .../src}/auth/init-mobile-provider.ts | 0 .../src}/auth/init-web-wallet-provider.ts | 0 .../src}/auth/login-with-extension.ts | 0 .../elven.js/src}/auth/login-with-mobile.ts | 0 .../src}/auth/login-with-native-auth-token.ts | 0 .../src}/auth/login-with-web-wallet.ts | 0 {src => packages/elven.js/src}/auth/logout.ts | 0 .../src}/auth/qr-code-and-pairings-builder.ts | 0 .../elven.js/src}/core/account.ts | 0 .../elven.js/src}/core/async-timer.ts | 0 .../src}/core/browser-extension-signing.ts | 0 .../elven.js/src}/core/constants.ts | 0 {src => packages/elven.js/src}/core/errors.ts | 0 .../elven.js/src}/core/keccak256.ts | 0 .../elven.js/src}/core/message.ts | 0 .../elven.js/src}/core/native-auth-client.ts | 0 .../elven.js/src}/core/network-provider.ts | 0 .../src}/core/transaction-converter.ts | 0 .../elven.js/src}/core/transaction-status.ts | 0 .../elven.js/src}/core/transaction-watcher.ts | 0 .../elven.js/src}/core/transaction.ts | 0 {src => packages/elven.js/src}/core/types.ts | 0 {src => packages/elven.js/src}/core/utils.ts | 0 .../src}/core/walletconnect-signing.ts | 0 .../elven.js/src}/core/walletconnect-utils.ts | 0 .../elven.js/src}/core/web-wallet-signing.ts | 0 .../src}/core/webview-event-handler.ts | 0 .../elven.js/src}/core/webview-signing.ts | 0 {src => packages/elven.js/src}/elven.ts | 0 .../elven.js/src}/events-store.ts | 0 .../elven.js/src}/initialize-events-store.ts | 0 .../src}/interaction/guardian-operations.ts | 0 .../elven.js/src}/interaction/post-send-tx.ts | 0 .../elven.js/src}/interaction/pre-send-tx.ts | 0 .../web-wallet-sign-message-finalize.ts | 0 .../interaction/web-wallet-tx-finalize.ts | 0 {src => packages/elven.js/src}/main.ts | 0 {src => packages/elven.js/src}/types.ts | 0 .../elven.js/src}/utils/amount.ts | 0 .../elven.js/src}/utils/constants.ts | 0 .../elven.js/src}/utils/error-parse.ts | 0 .../elven.js/src}/utils/get-param-from-url.ts | 0 .../utils/get-random-address-from-network.ts | 0 .../elven.js/src}/utils/ls-helpers.ts | 0 .../elven.js/src}/utils/with-login-events.ts | 0 .../src}/webview-provider/base64-utils.ts | 0 .../webview-provider/decode-login-token.ts | 0 .../decode-native-auth-token.ts | 0 .../elven.js/src}/webview-provider/utils.ts | 0 tsconfig.json | 20 +- turbo.json | 35 + 79 files changed, 342 insertions(+), 5187 deletions(-) create mode 100644 .npmrc create mode 100644 configs/esbuild/index.js create mode 100644 configs/esbuild/package.json create mode 100644 configs/eslint-config/index.js create mode 100644 configs/eslint-config/package.json create mode 100644 configs/tsconfig/base.json create mode 100644 configs/tsconfig/package.json rename {example => demo-app}/demo-styles.css (100%) rename {example => demo-app}/demo-ui-tools.js (100%) rename {example => demo-app}/elven.js (100%) rename {example => demo-app}/index.html (100%) delete mode 100644 esbuild.config.cjs delete mode 100644 package-lock.json create mode 100644 packages/@elven.js/mobile-signing-provider/esbuild.config.js create mode 100644 packages/@elven.js/mobile-signing-provider/package.json create mode 100644 packages/@elven.js/mobile-signing-provider/src/mobile-signing-provider.ts create mode 100644 packages/elven.js/esbuild.config.js create mode 100644 packages/elven.js/package.json rename {src => packages/elven.js/src}/auth/account-sync.ts (100%) rename {src => packages/elven.js/src}/auth/expires-at.ts (100%) rename {src => packages/elven.js/src}/auth/init-extension-provider.ts (100%) rename {src => packages/elven.js/src}/auth/init-mobile-provider.ts (100%) rename {src => packages/elven.js/src}/auth/init-web-wallet-provider.ts (100%) rename {src => packages/elven.js/src}/auth/login-with-extension.ts (100%) rename {src => packages/elven.js/src}/auth/login-with-mobile.ts (100%) rename {src => packages/elven.js/src}/auth/login-with-native-auth-token.ts (100%) rename {src => packages/elven.js/src}/auth/login-with-web-wallet.ts (100%) rename {src => packages/elven.js/src}/auth/logout.ts (100%) rename {src => packages/elven.js/src}/auth/qr-code-and-pairings-builder.ts (100%) rename {src => packages/elven.js/src}/core/account.ts (100%) rename {src => packages/elven.js/src}/core/async-timer.ts (100%) rename {src => packages/elven.js/src}/core/browser-extension-signing.ts (100%) rename {src => packages/elven.js/src}/core/constants.ts (100%) rename {src => packages/elven.js/src}/core/errors.ts (100%) rename {src => packages/elven.js/src}/core/keccak256.ts (100%) rename {src => packages/elven.js/src}/core/message.ts (100%) rename {src => packages/elven.js/src}/core/native-auth-client.ts (100%) rename {src => packages/elven.js/src}/core/network-provider.ts (100%) rename {src => packages/elven.js/src}/core/transaction-converter.ts (100%) rename {src => packages/elven.js/src}/core/transaction-status.ts (100%) rename {src => packages/elven.js/src}/core/transaction-watcher.ts (100%) rename {src => packages/elven.js/src}/core/transaction.ts (100%) rename {src => packages/elven.js/src}/core/types.ts (100%) rename {src => packages/elven.js/src}/core/utils.ts (100%) rename {src => packages/elven.js/src}/core/walletconnect-signing.ts (100%) rename {src => packages/elven.js/src}/core/walletconnect-utils.ts (100%) rename {src => packages/elven.js/src}/core/web-wallet-signing.ts (100%) rename {src => packages/elven.js/src}/core/webview-event-handler.ts (100%) rename {src => packages/elven.js/src}/core/webview-signing.ts (100%) rename {src => packages/elven.js/src}/elven.ts (100%) rename {src => packages/elven.js/src}/events-store.ts (100%) rename {src => packages/elven.js/src}/initialize-events-store.ts (100%) rename {src => packages/elven.js/src}/interaction/guardian-operations.ts (100%) rename {src => packages/elven.js/src}/interaction/post-send-tx.ts (100%) rename {src => packages/elven.js/src}/interaction/pre-send-tx.ts (100%) rename {src => packages/elven.js/src}/interaction/web-wallet-sign-message-finalize.ts (100%) rename {src => packages/elven.js/src}/interaction/web-wallet-tx-finalize.ts (100%) rename {src => packages/elven.js/src}/main.ts (100%) rename {src => packages/elven.js/src}/types.ts (100%) rename {src => packages/elven.js/src}/utils/amount.ts (100%) rename {src => packages/elven.js/src}/utils/constants.ts (100%) rename {src => packages/elven.js/src}/utils/error-parse.ts (100%) rename {src => packages/elven.js/src}/utils/get-param-from-url.ts (100%) rename {src => packages/elven.js/src}/utils/get-random-address-from-network.ts (100%) rename {src => packages/elven.js/src}/utils/ls-helpers.ts (100%) rename {src => packages/elven.js/src}/utils/with-login-events.ts (100%) rename {src => packages/elven.js/src}/webview-provider/base64-utils.ts (100%) rename {src => packages/elven.js/src}/webview-provider/decode-login-token.ts (100%) rename {src => packages/elven.js/src}/webview-provider/decode-native-auth-token.ts (100%) rename {src => packages/elven.js/src}/webview-provider/utils.ts (100%) create mode 100644 turbo.json diff --git a/.gitignore b/.gitignore index 8d321f7..3b3f041 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,32 @@ +# Dependencies node_modules +.pnp +.pnp.js + +# Testing +coverage + +# Turbo +.turbo + +# Build outputs build +dist +out + +# Misc +.DS_Store +*.pem stats.html + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Local env files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local diff --git a/.npmignore b/.npmignore index c1aea8a..ae184d4 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,7 @@ -example +apps node_modules src +configs .prettierrc .eslintrc .editorconfig diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..c129521 --- /dev/null +++ b/.npmrc @@ -0,0 +1,3 @@ +engine-strict=true +resolution-mode=highest +save-exact=true diff --git a/CHANGELOG.md b/CHANGELOG.md index a3260d4..334a476 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - add esbuild adjustments - elven.js script is now much smaller - add some most crucial automatic tests +- xPortal and Webview signing providers are now extracted as separate js file to be used as optional signing providers - ... ### [0.20.0](https://github.com/elven-js/elven.js/releases/tag/v0.20.0) (2024-10-13) diff --git a/TODO.md b/TODO.md index cd460ea..587c7aa 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ -- move all previous signing providers (wallet connect is left) - - check what can be done with wallet connect to make it as small as possible -- think about moving xPortal and webview integrations to separate files ???? +- move xPortal integration to separate file + - do a monorepo, mainly for example testing + - the wallet connect dependencies are quite big, there is not much that can be done here + - anyway check what can be done with wallet connect to make it as small as possible - add tests for at least most used utilities, maybe some core tools, check tests in MVX SDKs (more tests can be added later) - prepare a new API - for token operations diff --git a/configs/esbuild/index.js b/configs/esbuild/index.js new file mode 100644 index 0000000..a998f18 --- /dev/null +++ b/configs/esbuild/index.js @@ -0,0 +1,20 @@ +const banner = `/*! + * Portions of this code are derived from MultiversX libraries. + * These portions are licensed under the MIT License. + * + * See the MultiversX repository for details: https://github.com/multiversx + * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE + */ +`; + +export default { + format: 'esm', + bundle: true, + metafile: true, + minify: true, + outdir: 'build', + platform: 'browser', + banner: { js: banner }, + treeShaking: true, + // drop: ['console', 'debugger'], +}; diff --git a/configs/esbuild/package.json b/configs/esbuild/package.json new file mode 100644 index 0000000..089cb05 --- /dev/null +++ b/configs/esbuild/package.json @@ -0,0 +1,9 @@ +{ + "name": "@configs/esbuild", + "type": "module", + "private": true, + "main": "index.js", + "devDependencies": { + "esbuild": "0.24.0" + } +} \ No newline at end of file diff --git a/configs/eslint-config/index.js b/configs/eslint-config/index.js new file mode 100644 index 0000000..0255a66 --- /dev/null +++ b/configs/eslint-config/index.js @@ -0,0 +1,69 @@ +/* eslint-disable no-redeclare */ +import typescriptEslint from '@typescript-eslint/eslint-plugin'; +import globals from 'globals'; +import tsParser from '@typescript-eslint/parser'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}); + +export default [ + ...compat.extends( + 'plugin:prettier/recommended', + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended' + ), + { + plugins: { + '@typescript-eslint': typescriptEslint, + }, + + languageOptions: { + globals: { + ...globals.node, + ...globals.browser, + ElvenJS: 'readonly', + }, + + parser: tsParser, + ecmaVersion: 2020, + sourceType: 'commonjs', + }, + + rules: { + 'no-var': 'error', + 'prefer-const': 'error', + 'no-use-before-define': 'error', + 'no-mixed-spaces-and-tabs': 'error', + 'no-nested-ternary': 'error', + + 'prettier/prettier': [ + 'error', + { + endOfLine: 'auto', + }, + ], + + '@typescript-eslint/explicit-module-boundary-types': 'off', + '@typescript-eslint/no-explicit-any': 'off', + 'no-unused-vars': 'off', + + '@typescript-eslint/no-unused-vars': [ + 'error', + { + vars: 'all', + args: 'after-used', + ignoreRestSiblings: false, + }, + ], + }, + }, +]; diff --git a/configs/eslint-config/package.json b/configs/eslint-config/package.json new file mode 100644 index 0000000..c73371b --- /dev/null +++ b/configs/eslint-config/package.json @@ -0,0 +1,16 @@ +{ + "name": "@configs/eslint-config", + "version": "0.0.0", + "private": true, + "main": "index.js", + "devDependencies": { + "@eslint/eslintrc": "3.1.0", + "@eslint/js": "9.14.0", + "@typescript-eslint/eslint-plugin": "8.12.2", + "@typescript-eslint/parser": "8.12.2", + "eslint": "9.14.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.2.1", + "prettier": "3.3.3" + } +} \ No newline at end of file diff --git a/configs/tsconfig/base.json b/configs/tsconfig/base.json new file mode 100644 index 0000000..e298026 --- /dev/null +++ b/configs/tsconfig/base.json @@ -0,0 +1,20 @@ +{ + "include": [ + "src/**/*" + ], + "compilerOptions": { + "strict": true, + "target": "ES2020", + "module": "ES2020", + "declaration": true, + "declarationDir": "build/types", + "emitDeclarationOnly": true, + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true, + "types": [ + "node" + ], + "skipLibCheck": true + } +} \ No newline at end of file diff --git a/configs/tsconfig/package.json b/configs/tsconfig/package.json new file mode 100644 index 0000000..051ecf2 --- /dev/null +++ b/configs/tsconfig/package.json @@ -0,0 +1,11 @@ +{ + "name": "@configs/tsconfig", + "version": "0.0.0", + "private": true, + "files": [ + "base.json" + ], + "devDependencies": { + "typescript": "5.6.3" + } +} \ No newline at end of file diff --git a/example/demo-styles.css b/demo-app/demo-styles.css similarity index 100% rename from example/demo-styles.css rename to demo-app/demo-styles.css diff --git a/example/demo-ui-tools.js b/demo-app/demo-ui-tools.js similarity index 100% rename from example/demo-ui-tools.js rename to demo-app/demo-ui-tools.js diff --git a/example/elven.js b/demo-app/elven.js similarity index 100% rename from example/elven.js rename to demo-app/elven.js diff --git a/example/index.html b/demo-app/index.html similarity index 100% rename from example/index.html rename to demo-app/index.html diff --git a/dev-server.mjs b/dev-server.mjs index bda379b..93d6440 100644 --- a/dev-server.mjs +++ b/dev-server.mjs @@ -3,7 +3,7 @@ import http from 'http'; const server = http.createServer((request, response) => { return handler(request, response, { - public: 'example', + public: 'apps/demo-app', headers: [ { source: '**/*', diff --git a/esbuild.config.cjs b/esbuild.config.cjs deleted file mode 100644 index f86b40f..0000000 --- a/esbuild.config.cjs +++ /dev/null @@ -1,38 +0,0 @@ -/* eslint-disable @typescript-eslint/no-require-imports */ -const esbuild = require('esbuild'); - -const fs = require('fs'); - -const banner = `/*! - * Portions of this code are derived from MultiversX libraries. - * These portions are licensed under the MIT License. - * - * See the MultiversX repository for details: https://github.com/multiversx - * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE - */ -`; - -esbuild - .build({ - format: 'esm', - entryPoints: ['./src/elven.ts'], - bundle: true, - metafile: true, - minify: true, - outdir: 'build', - platform: 'browser', - banner: { js: banner }, - treeShaking: true, - // drop: ['console', 'debugger'], - }) - .then((result) => { - fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); - return result; - }) - .then((result) => { - return esbuild.analyzeMetafile(result.metafile); - }) - .then((result) => { - fs.writeFileSync('./build/meta.txt', result); - }) - .catch(() => process.exit(1)); diff --git a/eslint.config.mjs b/eslint.config.mjs index 0255a66..c75ba51 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,69 +1,5 @@ -/* eslint-disable no-redeclare */ -import typescriptEslint from '@typescript-eslint/eslint-plugin'; -import globals from 'globals'; -import tsParser from '@typescript-eslint/parser'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import js from '@eslint/js'; -import { FlatCompat } from '@eslint/eslintrc'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all, -}); - -export default [ - ...compat.extends( - 'plugin:prettier/recommended', - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended' - ), - { - plugins: { - '@typescript-eslint': typescriptEslint, - }, - - languageOptions: { - globals: { - ...globals.node, - ...globals.browser, - ElvenJS: 'readonly', - }, - - parser: tsParser, - ecmaVersion: 2020, - sourceType: 'commonjs', - }, - - rules: { - 'no-var': 'error', - 'prefer-const': 'error', - 'no-use-before-define': 'error', - 'no-mixed-spaces-and-tabs': 'error', - 'no-nested-ternary': 'error', - - 'prettier/prettier': [ - 'error', - { - endOfLine: 'auto', - }, - ], - - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-explicit-any': 'off', - 'no-unused-vars': 'off', - - '@typescript-eslint/no-unused-vars': [ - 'error', - { - vars: 'all', - args: 'after-used', - ignoreRestSiblings: false, - }, - ], - }, - }, -]; +export default { + root: true, + extends: ["./configs/eslint-config/index.js"], + ignorePatterns: ["node_modules", "build", "dist", ".turbo"] +}; diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index ef76c3f..0000000 --- a/package-lock.json +++ /dev/null @@ -1,5008 +0,0 @@ -{ - "name": "elven.js", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "elven.js", - "version": "1.0.0", - "license": "MIT", - "devDependencies": { - "@eslint/eslintrc": "3.1.0", - "@eslint/js": "9.14.0", - "@types/qrcode": "1.5.5", - "@types/serve-handler": "6.1.4", - "@typescript-eslint/eslint-plugin": "8.12.2", - "@typescript-eslint/parser": "8.12.2", - "@walletconnect/sign-client": "^2.17.1", - "esbuild": "0.24.0", - "eslint": "9.14.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.2.1", - "globals": "15.11.0", - "prettier": "3.3.3", - "qrcode": "1.5.4", - "rimraf": "6.0.1", - "serve-handler": "6.1.6", - "typescript": "5.6.3" - } - }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz", - "integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.0.tgz", - "integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz", - "integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.0.tgz", - "integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz", - "integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz", - "integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz", - "integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz", - "integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz", - "integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz", - "integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz", - "integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz", - "integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz", - "integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz", - "integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz", - "integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz", - "integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz", - "integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz", - "integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz", - "integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz", - "integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz", - "integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz", - "integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz", - "integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz", - "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@eslint-community/eslint-utils": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", - "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - }, - "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" - } - }, - "node_modules/@eslint-community/regexpp": { - "version": "4.12.1", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", - "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", - "dev": true, - "engines": { - "node": "^12.0.0 || ^14.0.0 || >=16.0.0" - } - }, - "node_modules/@eslint/config-array": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", - "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", - "dev": true, - "dependencies": { - "@eslint/object-schema": "^2.1.4", - "debug": "^4.3.1", - "minimatch": "^3.1.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/core": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", - "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/eslintrc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", - "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", - "dev": true, - "dependencies": { - "ajv": "^6.12.4", - "debug": "^4.3.2", - "espree": "^10.0.1", - "globals": "^14.0.0", - "ignore": "^5.2.0", - "import-fresh": "^3.2.1", - "js-yaml": "^4.1.0", - "minimatch": "^3.1.2", - "strip-json-comments": "^3.1.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", - "dev": true, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/@eslint/js": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", - "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/object-schema": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", - "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@eslint/plugin-kit": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", - "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", - "dev": true, - "dependencies": { - "levn": "^0.4.1" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, - "node_modules/@ethersproject/abstract-provider": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz", - "integrity": "sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/networks": "^5.7.0", - "@ethersproject/properties": "^5.7.0", - "@ethersproject/transactions": "^5.7.0", - "@ethersproject/web": "^5.7.0" - } - }, - "node_modules/@ethersproject/abstract-signer": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz", - "integrity": "sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-provider": "^5.7.0", - "@ethersproject/bignumber": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/properties": "^5.7.0" - } - }, - "node_modules/@ethersproject/address": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.7.0.tgz", - "integrity": "sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/keccak256": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/rlp": "^5.7.0" - } - }, - "node_modules/@ethersproject/base64": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.7.0.tgz", - "integrity": "sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.7.0" - } - }, - "node_modules/@ethersproject/bignumber": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz", - "integrity": "sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "bn.js": "^5.2.1" - } - }, - "node_modules/@ethersproject/bytes": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.7.0.tgz", - "integrity": "sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/logger": "^5.7.0" - } - }, - "node_modules/@ethersproject/constants": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.7.0.tgz", - "integrity": "sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bignumber": "^5.7.0" - } - }, - "node_modules/@ethersproject/hash": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz", - "integrity": "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/abstract-signer": "^5.7.0", - "@ethersproject/address": "^5.7.0", - "@ethersproject/base64": "^5.7.0", - "@ethersproject/bignumber": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/keccak256": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/properties": "^5.7.0", - "@ethersproject/strings": "^5.7.0" - } - }, - "node_modules/@ethersproject/keccak256": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz", - "integrity": "sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.7.0", - "js-sha3": "0.8.0" - } - }, - "node_modules/@ethersproject/logger": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.7.0.tgz", - "integrity": "sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ] - }, - "node_modules/@ethersproject/networks": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.7.1.tgz", - "integrity": "sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/logger": "^5.7.0" - } - }, - "node_modules/@ethersproject/properties": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz", - "integrity": "sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/logger": "^5.7.0" - } - }, - "node_modules/@ethersproject/rlp": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz", - "integrity": "sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/logger": "^5.7.0" - } - }, - "node_modules/@ethersproject/signing-key": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz", - "integrity": "sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/properties": "^5.7.0", - "bn.js": "^5.2.1", - "elliptic": "6.5.4", - "hash.js": "1.1.7" - } - }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "dev": true, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/@ethersproject/strings": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", - "integrity": "sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/constants": "^5.7.0", - "@ethersproject/logger": "^5.7.0" - } - }, - "node_modules/@ethersproject/transactions": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.7.0.tgz", - "integrity": "sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/address": "^5.7.0", - "@ethersproject/bignumber": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/constants": "^5.7.0", - "@ethersproject/keccak256": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/properties": "^5.7.0", - "@ethersproject/rlp": "^5.7.0", - "@ethersproject/signing-key": "^5.7.0" - } - }, - "node_modules/@ethersproject/web": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz", - "integrity": "sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==", - "dev": true, - "funding": [ - { - "type": "individual", - "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" - }, - { - "type": "individual", - "url": "https://www.buymeacoffee.com/ricmoo" - } - ], - "dependencies": { - "@ethersproject/base64": "^5.7.0", - "@ethersproject/bytes": "^5.7.0", - "@ethersproject/logger": "^5.7.0", - "@ethersproject/properties": "^5.7.0", - "@ethersproject/strings": "^5.7.0" - } - }, - "node_modules/@humanfs/core": { - "version": "0.19.1", - "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", - "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", - "dev": true, - "engines": { - "node": ">=18.18.0" - } - }, - "node_modules/@humanfs/node": { - "version": "0.16.6", - "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", - "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", - "dev": true, - "dependencies": { - "@humanfs/core": "^0.19.1", - "@humanwhocodes/retry": "^0.3.0" - }, - "engines": { - "node": ">=18.18.0" - } - }, - "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", - "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", - "dev": true, - "engines": { - "node": ">=18.18" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@humanwhocodes/module-importer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", - "dev": true, - "engines": { - "node": ">=12.22" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@humanwhocodes/retry": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.0.tgz", - "integrity": "sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==", - "dev": true, - "engines": { - "node": ">=18.18" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, - "node_modules/@isaacs/cliui": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", - "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", - "dev": true, - "dependencies": { - "string-width": "^5.1.2", - "string-width-cjs": "npm:string-width@^4.2.0", - "strip-ansi": "^7.0.1", - "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", - "wrap-ansi": "^8.1.0", - "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@nodelib/fs.walk": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", - "dev": true, - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/@parcel/watcher": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.4.1.tgz", - "integrity": "sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==", - "dev": true, - "dependencies": { - "detect-libc": "^1.0.3", - "is-glob": "^4.0.3", - "micromatch": "^4.0.5", - "node-addon-api": "^7.0.0" - }, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "optionalDependencies": { - "@parcel/watcher-android-arm64": "2.4.1", - "@parcel/watcher-darwin-arm64": "2.4.1", - "@parcel/watcher-darwin-x64": "2.4.1", - "@parcel/watcher-freebsd-x64": "2.4.1", - "@parcel/watcher-linux-arm-glibc": "2.4.1", - "@parcel/watcher-linux-arm64-glibc": "2.4.1", - "@parcel/watcher-linux-arm64-musl": "2.4.1", - "@parcel/watcher-linux-x64-glibc": "2.4.1", - "@parcel/watcher-linux-x64-musl": "2.4.1", - "@parcel/watcher-win32-arm64": "2.4.1", - "@parcel/watcher-win32-ia32": "2.4.1", - "@parcel/watcher-win32-x64": "2.4.1" - } - }, - "node_modules/@parcel/watcher-android-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.4.1.tgz", - "integrity": "sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-darwin-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.4.1.tgz", - "integrity": "sha512-ln41eihm5YXIY043vBrrHfn94SIBlqOWmoROhsMVTSXGh0QahKGy77tfEywQ7v3NywyxBBkGIfrWRHm0hsKtzA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-darwin-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.4.1.tgz", - "integrity": "sha512-yrw81BRLjjtHyDu7J61oPuSoeYWR3lDElcPGJyOvIXmor6DEo7/G2u1o7I38cwlcoBHQFULqF6nesIX3tsEXMg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-freebsd-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.4.1.tgz", - "integrity": "sha512-TJa3Pex/gX3CWIx/Co8k+ykNdDCLx+TuZj3f3h7eOjgpdKM+Mnix37RYsYU4LHhiYJz3DK5nFCCra81p6g050w==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-arm-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.4.1.tgz", - "integrity": "sha512-4rVYDlsMEYfa537BRXxJ5UF4ddNwnr2/1O4MHM5PjI9cvV2qymvhwZSFgXqbS8YoTk5i/JR0L0JDs69BUn45YA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-arm64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.4.1.tgz", - "integrity": "sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-arm64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.4.1.tgz", - "integrity": "sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-x64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.4.1.tgz", - "integrity": "sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-linux-x64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.4.1.tgz", - "integrity": "sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-wasm": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.4.1.tgz", - "integrity": "sha512-/ZR0RxqxU/xxDGzbzosMjh4W6NdYFMqq2nvo2b8SLi7rsl/4jkL8S5stIikorNkdR50oVDvqb/3JT05WM+CRRA==", - "bundleDependencies": [ - "napi-wasm" - ], - "dev": true, - "dependencies": { - "is-glob": "^4.0.3", - "micromatch": "^4.0.5", - "napi-wasm": "^1.1.0" - }, - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-wasm/node_modules/napi-wasm": { - "version": "1.1.0", - "dev": true, - "inBundle": true, - "license": "MIT" - }, - "node_modules/@parcel/watcher-win32-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.4.1.tgz", - "integrity": "sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-win32-ia32": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.4.1.tgz", - "integrity": "sha512-maNRit5QQV2kgHFSYwftmPBxiuK5u4DXjbXx7q6eKjq5dsLXZ4FJiVvlcw35QXzk0KrUecJmuVFbj4uV9oYrcw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@parcel/watcher-win32-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.4.1.tgz", - "integrity": "sha512-+DvS92F9ezicfswqrvIRM2njcYJbd5mb9CUgtrHCHmvn7pPPa+nMDRu1o1bYYz/l5IB2NVGNJWiH7h1E58IF2A==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/@pkgr/core": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", - "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", - "dev": true, - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, - "node_modules/@stablelib/aead": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/aead/-/aead-1.0.1.tgz", - "integrity": "sha512-q39ik6sxGHewqtO0nP4BuSe3db5G1fEJE8ukvngS2gLkBXyy6E7pLubhbYgnkDFv6V8cWaxcE4Xn0t6LWcJkyg==", - "dev": true - }, - "node_modules/@stablelib/binary": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", - "integrity": "sha512-ClJWvmL6UBM/wjkvv/7m5VP3GMr9t0osr4yVgLZsLCOz4hGN9gIAFEqnJ0TsSMAN+n840nf2cHZnA5/KFqHC7Q==", - "dev": true, - "dependencies": { - "@stablelib/int": "^1.0.1" - } - }, - "node_modules/@stablelib/bytes": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/bytes/-/bytes-1.0.1.tgz", - "integrity": "sha512-Kre4Y4kdwuqL8BR2E9hV/R5sOrUj6NanZaZis0V6lX5yzqC3hBuVSDXUIBqQv/sCpmuWRiHLwqiT1pqqjuBXoQ==", - "dev": true - }, - "node_modules/@stablelib/chacha": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/chacha/-/chacha-1.0.1.tgz", - "integrity": "sha512-Pmlrswzr0pBzDofdFuVe1q7KdsHKhhU24e8gkEwnTGOmlC7PADzLVxGdn2PoNVBBabdg0l/IfLKg6sHAbTQugg==", - "dev": true, - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/chacha20poly1305": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/chacha20poly1305/-/chacha20poly1305-1.0.1.tgz", - "integrity": "sha512-MmViqnqHd1ymwjOQfghRKw2R/jMIGT3wySN7cthjXCBdO+qErNPUBnRzqNpnvIwg7JBCg3LdeCZZO4de/yEhVA==", - "dev": true, - "dependencies": { - "@stablelib/aead": "^1.0.1", - "@stablelib/binary": "^1.0.1", - "@stablelib/chacha": "^1.0.1", - "@stablelib/constant-time": "^1.0.1", - "@stablelib/poly1305": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/constant-time/-/constant-time-1.0.1.tgz", - "integrity": "sha512-tNOs3uD0vSJcK6z1fvef4Y+buN7DXhzHDPqRLSXUel1UfqMB1PWNsnnAezrKfEwTLpN0cGH2p9NNjs6IqeD0eg==", - "dev": true - }, - "node_modules/@stablelib/ed25519": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@stablelib/ed25519/-/ed25519-1.0.3.tgz", - "integrity": "sha512-puIMWaX9QlRsbhxfDc5i+mNPMY+0TmQEskunY1rZEBPi1acBCVQAhnsk/1Hk50DGPtVsZtAWQg4NHGlVaO9Hqg==", - "dev": true, - "dependencies": { - "@stablelib/random": "^1.0.2", - "@stablelib/sha512": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/hash": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/hash/-/hash-1.0.1.tgz", - "integrity": "sha512-eTPJc/stDkdtOcrNMZ6mcMK1e6yBbqRBaNW55XA1jU8w/7QdnCF0CmMmOD1m7VSkBR44PWrMHU2l6r8YEQHMgg==", - "dev": true - }, - "node_modules/@stablelib/hkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/hkdf/-/hkdf-1.0.1.tgz", - "integrity": "sha512-SBEHYE16ZXlHuaW5RcGk533YlBj4grMeg5TooN80W3NpcHRtLZLLXvKyX0qcRFxf+BGDobJLnwkvgEwHIDBR6g==", - "dev": true, - "dependencies": { - "@stablelib/hash": "^1.0.1", - "@stablelib/hmac": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/hmac": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/hmac/-/hmac-1.0.1.tgz", - "integrity": "sha512-V2APD9NSnhVpV/QMYgCVMIYKiYG6LSqw1S65wxVoirhU/51ACio6D4yDVSwMzuTJXWZoVHbDdINioBwKy5kVmA==", - "dev": true, - "dependencies": { - "@stablelib/constant-time": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/int": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/int/-/int-1.0.1.tgz", - "integrity": "sha512-byr69X/sDtDiIjIV6m4roLVWnNNlRGzsvxw+agj8CIEazqWGOQp2dTYgQhtyVXV9wpO6WyXRQUzLV/JRNumT2w==", - "dev": true - }, - "node_modules/@stablelib/keyagreement": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/keyagreement/-/keyagreement-1.0.1.tgz", - "integrity": "sha512-VKL6xBwgJnI6l1jKrBAfn265cspaWBPAPEc62VBQrWHLqVgNRE09gQ/AnOEyKUWrrqfD+xSQ3u42gJjLDdMDQg==", - "dev": true, - "dependencies": { - "@stablelib/bytes": "^1.0.1" - } - }, - "node_modules/@stablelib/poly1305": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/poly1305/-/poly1305-1.0.1.tgz", - "integrity": "sha512-1HlG3oTSuQDOhSnLwJRKeTRSAdFNVB/1djy2ZbS35rBSJ/PFqx9cf9qatinWghC2UbfOYD8AcrtbUQl8WoxabA==", - "dev": true, - "dependencies": { - "@stablelib/constant-time": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/random": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@stablelib/random/-/random-1.0.2.tgz", - "integrity": "sha512-rIsE83Xpb7clHPVRlBj8qNe5L8ISQOzjghYQm/dZ7VaM2KHYwMW5adjQjrzTZCchFnNCNhkwtnOBa9HTMJCI8w==", - "dev": true, - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/sha256": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/sha256/-/sha256-1.0.1.tgz", - "integrity": "sha512-GIIH3e6KH+91FqGV42Kcj71Uefd/QEe7Dy42sBTeqppXV95ggCcxLTk39bEr+lZfJmp+ghsR07J++ORkRELsBQ==", - "dev": true, - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/sha512": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/sha512/-/sha512-1.0.1.tgz", - "integrity": "sha512-13gl/iawHV9zvDKciLo1fQ8Bgn2Pvf7OV6amaRVKiq3pjQ3UmEpXxWiAfV8tYjUpeZroBxtyrwtdooQT/i3hzw==", - "dev": true, - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/wipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", - "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==", - "dev": true - }, - "node_modules/@stablelib/x25519": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@stablelib/x25519/-/x25519-1.0.3.tgz", - "integrity": "sha512-KnTbKmUhPhHavzobclVJQG5kuivH+qDLpe84iRqX3CLrKp881cF160JvXJ+hjn1aMyCwYOKeIZefIH/P5cJoRw==", - "dev": true, - "dependencies": { - "@stablelib/keyagreement": "^1.0.1", - "@stablelib/random": "^1.0.2", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@types/estree": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", - "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", - "dev": true - }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true - }, - "node_modules/@types/node": { - "version": "22.8.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.6.tgz", - "integrity": "sha512-tosuJYKrIqjQIlVCM4PEGxOmyg3FCPa/fViuJChnGeEIhjA46oy8FMVoF9su1/v8PNs2a8Q0iFNyOx0uOF91nw==", - "dev": true, - "dependencies": { - "undici-types": "~6.19.8" - } - }, - "node_modules/@types/qrcode": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.5.tgz", - "integrity": "sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/serve-handler": { - "version": "6.1.4", - "resolved": "https://registry.npmjs.org/@types/serve-handler/-/serve-handler-6.1.4.tgz", - "integrity": "sha512-aXy58tNie0NkuSCY291xUxl0X+kGYy986l4kqW6Gi4kEXgr6Tx0fpSH7YwUSa5usPpG3s9DBeIR6hHcDtL2IvQ==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.12.2.tgz", - "integrity": "sha512-gQxbxM8mcxBwaEmWdtLCIGLfixBMHhQjBqR8sVWNTPpcj45WlYL2IObS/DNMLH1DBP0n8qz+aiiLTGfopPEebw==", - "dev": true, - "dependencies": { - "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.12.2", - "@typescript-eslint/type-utils": "8.12.2", - "@typescript-eslint/utils": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2", - "graphemer": "^1.4.0", - "ignore": "^5.3.1", - "natural-compare": "^1.4.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", - "eslint": "^8.57.0 || ^9.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/parser": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.12.2.tgz", - "integrity": "sha512-MrvlXNfGPLH3Z+r7Tk+Z5moZAc0dzdVjTgUgwsdGweH7lydysQsnSww3nAmsq8blFuRD5VRlAr9YdEFw3e6PBw==", - "dev": true, - "dependencies": { - "@typescript-eslint/scope-manager": "8.12.2", - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/typescript-estree": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2", - "debug": "^4.3.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.12.2.tgz", - "integrity": "sha512-gPLpLtrj9aMHOvxJkSbDBmbRuYdtiEbnvO25bCMza3DhMjTQw0u7Y1M+YR5JPbMsXXnSPuCf5hfq0nEkQDL/JQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/type-utils": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.12.2.tgz", - "integrity": "sha512-bwuU4TAogPI+1q/IJSKuD4shBLc/d2vGcRT588q+jzayQyjVK2X6v/fbR4InY2U2sgf8MEvVCqEWUzYzgBNcGQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/typescript-estree": "8.12.2", - "@typescript-eslint/utils": "8.12.2", - "debug": "^4.3.4", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/types": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.12.2.tgz", - "integrity": "sha512-VwDwMF1SZ7wPBUZwmMdnDJ6sIFk4K4s+ALKLP6aIQsISkPv8jhiw65sAK6SuWODN/ix+m+HgbYDkH+zLjrzvOA==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.12.2.tgz", - "integrity": "sha512-mME5MDwGe30Pq9zKPvyduyU86PH7aixwqYR2grTglAdB+AN8xXQ1vFGpYaUSJ5o5P/5znsSBeNcs5g5/2aQwow==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2", - "debug": "^4.3.4", - "fast-glob": "^3.3.2", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/@typescript-eslint/utils": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.12.2.tgz", - "integrity": "sha512-UTTuDIX3fkfAz6iSVa5rTuSfWIYZ6ATtEocQ/umkRSyC9O919lbZ8dcH7mysshrCdrAM03skJOEYaBugxN+M6A==", - "dev": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.12.2", - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/typescript-estree": "8.12.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" - } - }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.12.2.tgz", - "integrity": "sha512-PChz8UaKQAVNHghsHcPyx1OMHoFRUEA7rJSK/mDhdq85bk+PLsUHUBqTQTFt18VJZbmxBovM65fezlheQRsSDA==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "8.12.2", - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@walletconnect/core": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.17.1.tgz", - "integrity": "sha512-SMgJR5hEyEE/tENIuvlEb4aB9tmMXPzQ38Y61VgYBmwAFEhOHtpt8EDfnfRWqEhMyXuBXG4K70Yh8c67Yry+Xw==", - "dev": true, - "dependencies": { - "@walletconnect/heartbeat": "1.2.2", - "@walletconnect/jsonrpc-provider": "1.0.14", - "@walletconnect/jsonrpc-types": "1.0.4", - "@walletconnect/jsonrpc-utils": "1.0.8", - "@walletconnect/jsonrpc-ws-connection": "1.0.14", - "@walletconnect/keyvaluestorage": "1.1.1", - "@walletconnect/logger": "2.1.2", - "@walletconnect/relay-api": "1.0.11", - "@walletconnect/relay-auth": "1.0.4", - "@walletconnect/safe-json": "1.0.2", - "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", - "@walletconnect/window-getters": "1.0.1", - "events": "3.3.0", - "lodash.isequal": "4.5.0", - "uint8arrays": "3.1.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@walletconnect/environment": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@walletconnect/environment/-/environment-1.0.1.tgz", - "integrity": "sha512-T426LLZtHj8e8rYnKfzsw1aG6+M0BT1ZxayMdv/p8yM0MU+eJDISqNY3/bccxRr4LrF9csq02Rhqt08Ibl0VRg==", - "dev": true, - "dependencies": { - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/events": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@walletconnect/events/-/events-1.0.1.tgz", - "integrity": "sha512-NPTqaoi0oPBVNuLv7qPaJazmGHs5JGyO8eEAk5VGKmJzDR7AHzD4k6ilox5kxk1iwiOnFopBOOMLs86Oa76HpQ==", - "dev": true, - "dependencies": { - "keyvaluestorage-interface": "^1.0.0", - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/heartbeat": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/@walletconnect/heartbeat/-/heartbeat-1.2.2.tgz", - "integrity": "sha512-uASiRmC5MwhuRuf05vq4AT48Pq8RMi876zV8rr8cV969uTOzWdB/k+Lj5yI2PBtB1bGQisGen7MM1GcZlQTBXw==", - "dev": true, - "dependencies": { - "@walletconnect/events": "^1.0.1", - "@walletconnect/time": "^1.0.2", - "events": "^3.3.0" - } - }, - "node_modules/@walletconnect/jsonrpc-provider": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-provider/-/jsonrpc-provider-1.0.14.tgz", - "integrity": "sha512-rtsNY1XqHvWj0EtITNeuf8PHMvlCLiS3EjQL+WOkxEOA4KPxsohFnBDeyPYiNm4ZvkQdLnece36opYidmtbmow==", - "dev": true, - "dependencies": { - "@walletconnect/jsonrpc-utils": "^1.0.8", - "@walletconnect/safe-json": "^1.0.2", - "events": "^3.3.0" - } - }, - "node_modules/@walletconnect/jsonrpc-types": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-types/-/jsonrpc-types-1.0.4.tgz", - "integrity": "sha512-P6679fG/M+wuWg9TY8mh6xFSdYnFyFjwFelxyISxMDrlbXokorEVXYOxiqEbrU3x1BmBoCAJJ+vtEaEoMlpCBQ==", - "dev": true, - "dependencies": { - "events": "^3.3.0", - "keyvaluestorage-interface": "^1.0.0" - } - }, - "node_modules/@walletconnect/jsonrpc-utils": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-utils/-/jsonrpc-utils-1.0.8.tgz", - "integrity": "sha512-vdeb03bD8VzJUL6ZtzRYsFMq1eZQcM3EAzT0a3st59dyLfJ0wq+tKMpmGH7HlB7waD858UWgfIcudbPFsbzVdw==", - "dev": true, - "dependencies": { - "@walletconnect/environment": "^1.0.1", - "@walletconnect/jsonrpc-types": "^1.0.3", - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/jsonrpc-ws-connection": { - "version": "1.0.14", - "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.14.tgz", - "integrity": "sha512-Jsl6fC55AYcbkNVkwNM6Jo+ufsuCQRqViOQ8ZBPH9pRREHH9welbBiszuTLqEJiQcO/6XfFDl6bzCJIkrEi8XA==", - "dev": true, - "dependencies": { - "@walletconnect/jsonrpc-utils": "^1.0.6", - "@walletconnect/safe-json": "^1.0.2", - "events": "^3.3.0", - "ws": "^7.5.1" - } - }, - "node_modules/@walletconnect/keyvaluestorage": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@walletconnect/keyvaluestorage/-/keyvaluestorage-1.1.1.tgz", - "integrity": "sha512-V7ZQq2+mSxAq7MrRqDxanTzu2RcElfK1PfNYiaVnJgJ7Q7G7hTVwF8voIBx92qsRyGHZihrwNPHuZd1aKkd0rA==", - "dev": true, - "dependencies": { - "@walletconnect/safe-json": "^1.0.1", - "idb-keyval": "^6.2.1", - "unstorage": "^1.9.0" - }, - "peerDependencies": { - "@react-native-async-storage/async-storage": "1.x" - }, - "peerDependenciesMeta": { - "@react-native-async-storage/async-storage": { - "optional": true - } - } - }, - "node_modules/@walletconnect/logger": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@walletconnect/logger/-/logger-2.1.2.tgz", - "integrity": "sha512-aAb28I3S6pYXZHQm5ESB+V6rDqIYfsnHaQyzFbwUUBFY4H0OXx/YtTl8lvhUNhMMfb9UxbwEBS253TlXUYJWSw==", - "dev": true, - "dependencies": { - "@walletconnect/safe-json": "^1.0.2", - "pino": "7.11.0" - } - }, - "node_modules/@walletconnect/relay-api": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@walletconnect/relay-api/-/relay-api-1.0.11.tgz", - "integrity": "sha512-tLPErkze/HmC9aCmdZOhtVmYZq1wKfWTJtygQHoWtgg722Jd4homo54Cs4ak2RUFUZIGO2RsOpIcWipaua5D5Q==", - "dev": true, - "dependencies": { - "@walletconnect/jsonrpc-types": "^1.0.2" - } - }, - "node_modules/@walletconnect/relay-auth": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@walletconnect/relay-auth/-/relay-auth-1.0.4.tgz", - "integrity": "sha512-kKJcS6+WxYq5kshpPaxGHdwf5y98ZwbfuS4EE/NkQzqrDFm5Cj+dP8LofzWvjrrLkZq7Afy7WrQMXdLy8Sx7HQ==", - "dev": true, - "dependencies": { - "@stablelib/ed25519": "^1.0.2", - "@stablelib/random": "^1.0.1", - "@walletconnect/safe-json": "^1.0.1", - "@walletconnect/time": "^1.0.2", - "tslib": "1.14.1", - "uint8arrays": "^3.0.0" - } - }, - "node_modules/@walletconnect/safe-json": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@walletconnect/safe-json/-/safe-json-1.0.2.tgz", - "integrity": "sha512-Ogb7I27kZ3LPC3ibn8ldyUr5544t3/STow9+lzz7Sfo808YD7SBWk7SAsdBFlYgP2zDRy2hS3sKRcuSRM0OTmA==", - "dev": true, - "dependencies": { - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/sign-client": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.17.1.tgz", - "integrity": "sha512-6rLw6YNy0smslH9wrFTbNiYrGsL3DrOsS5FcuU4gIN6oh8pGYOFZ5FiSyTTroc5tngOk3/Sd7dlGY9S7O4nveg==", - "dev": true, - "dependencies": { - "@walletconnect/core": "2.17.1", - "@walletconnect/events": "1.0.1", - "@walletconnect/heartbeat": "1.2.2", - "@walletconnect/jsonrpc-utils": "1.0.8", - "@walletconnect/logger": "2.1.2", - "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", - "events": "3.3.0" - } - }, - "node_modules/@walletconnect/time": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@walletconnect/time/-/time-1.0.2.tgz", - "integrity": "sha512-uzdd9woDcJ1AaBZRhqy5rNC9laqWGErfc4dxA9a87mPdKOgWMD85mcFo9dIYIts/Jwocfwn07EC6EzclKubk/g==", - "dev": true, - "dependencies": { - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/types": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.17.1.tgz", - "integrity": "sha512-aiUeBE3EZZTsZBv5Cju3D0PWAsZCMks1g3hzQs9oNtrbuLL6pKKU0/zpKwk4vGywszxPvC3U0tBCku9LLsH/0A==", - "dev": true, - "dependencies": { - "@walletconnect/events": "1.0.1", - "@walletconnect/heartbeat": "1.2.2", - "@walletconnect/jsonrpc-types": "1.0.4", - "@walletconnect/keyvaluestorage": "1.1.1", - "@walletconnect/logger": "2.1.2", - "events": "3.3.0" - } - }, - "node_modules/@walletconnect/utils": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.17.1.tgz", - "integrity": "sha512-KL7pPwq7qUC+zcTmvxGqIyYanfHgBQ+PFd0TEblg88jM7EjuDLhjyyjtkhyE/2q7QgR7OanIK7pCpilhWvBsBQ==", - "dev": true, - "dependencies": { - "@ethersproject/hash": "5.7.0", - "@ethersproject/transactions": "5.7.0", - "@stablelib/chacha20poly1305": "1.0.1", - "@stablelib/hkdf": "1.0.1", - "@stablelib/random": "1.0.2", - "@stablelib/sha256": "1.0.1", - "@stablelib/x25519": "1.0.3", - "@walletconnect/jsonrpc-utils": "1.0.8", - "@walletconnect/keyvaluestorage": "1.1.1", - "@walletconnect/relay-api": "1.0.11", - "@walletconnect/relay-auth": "1.0.4", - "@walletconnect/safe-json": "1.0.2", - "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", - "@walletconnect/window-getters": "1.0.1", - "@walletconnect/window-metadata": "1.0.1", - "detect-browser": "5.3.0", - "elliptic": "6.5.7", - "query-string": "7.1.3", - "uint8arrays": "3.1.0" - } - }, - "node_modules/@walletconnect/window-getters": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@walletconnect/window-getters/-/window-getters-1.0.1.tgz", - "integrity": "sha512-vHp+HqzGxORPAN8gY03qnbTMnhqIwjeRJNOMOAzePRg4xVEEE2WvYsI9G2NMjOknA8hnuYbU3/hwLcKbjhc8+Q==", - "dev": true, - "dependencies": { - "tslib": "1.14.1" - } - }, - "node_modules/@walletconnect/window-metadata": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@walletconnect/window-metadata/-/window-metadata-1.0.1.tgz", - "integrity": "sha512-9koTqyGrM2cqFRW517BPY/iEtUDx2r1+Pwwu5m7sJ7ka79wi3EyqhqcICk/yDmv6jAS1rjKgTKXlEhanYjijcA==", - "dev": true, - "dependencies": { - "@walletconnect/window-getters": "^1.0.1", - "tslib": "1.14.1" - } - }, - "node_modules/acorn": { - "version": "8.14.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", - "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", - "dev": true, - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "peerDependencies": { - "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/argparse": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true - }, - "node_modules/atomic-sleep": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", - "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", - "dev": true, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true - }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "dev": true - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", - "dev": true - }, - "node_modules/bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", - "dev": true, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/callsites": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/chokidar/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/citty": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/citty/-/citty-0.1.6.tgz", - "integrity": "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==", - "dev": true, - "dependencies": { - "consola": "^3.2.3" - } - }, - "node_modules/clipboardy": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-4.0.0.tgz", - "integrity": "sha512-5mOlNS0mhX0707P2I0aZ2V/cmHUEO/fL7VFLqszkhUsxt7RwnmrInf/eEQKlf5GzvYeHIjT+Ov1HRfNmymlG0w==", - "dev": true, - "dependencies": { - "execa": "^8.0.1", - "is-wsl": "^3.1.0", - "is64bit": "^2.0.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true - }, - "node_modules/confbox": { - "version": "0.1.8", - "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", - "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==", - "dev": true - }, - "node_modules/consola": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/consola/-/consola-3.2.3.tgz", - "integrity": "sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==", - "dev": true, - "engines": { - "node": "^14.18.0 || >=16.10.0" - } - }, - "node_modules/content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-es": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/cookie-es/-/cookie-es-1.2.2.tgz", - "integrity": "sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==", - "dev": true - }, - "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/crossws": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/crossws/-/crossws-0.3.1.tgz", - "integrity": "sha512-HsZgeVYaG+b5zA+9PbIPGq4+J/CJynJuearykPsXx4V/eMhyQ5EDVg3Ak2FBZtVXCiOLu/U7IiwDHTr9MA+IKw==", - "dev": true, - "dependencies": { - "uncrypto": "^0.1.3" - } - }, - "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/decode-uri-component": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", - "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", - "dev": true, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true - }, - "node_modules/defu": { - "version": "6.1.4", - "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", - "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==", - "dev": true - }, - "node_modules/destr": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.3.tgz", - "integrity": "sha512-2N3BOUU4gYMpTP24s5rF5iP7BDr7uNTCs4ozw3kf/eKfvWSIu93GEBi5m427YoyJoeOzQ5smuu4nNAPGb8idSQ==", - "dev": true - }, - "node_modules/detect-browser": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/detect-browser/-/detect-browser-5.3.0.tgz", - "integrity": "sha512-53rsFbGdwMwlF7qvCt0ypLM5V5/Mbl0szB7GPN8y9NCcbknYOeVVXdrXEq+90IwAfrrzt6Hd+u2E2ntakICU8w==", - "dev": true - }, - "node_modules/detect-libc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", - "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", - "dev": true, - "bin": { - "detect-libc": "bin/detect-libc.js" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/dijkstrajs": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", - "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", - "dev": true - }, - "node_modules/duplexify": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz", - "integrity": "sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==", - "dev": true, - "dependencies": { - "end-of-stream": "^1.4.1", - "inherits": "^2.0.3", - "readable-stream": "^3.1.1", - "stream-shift": "^1.0.2" - } - }, - "node_modules/eastasianwidth": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", - "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true - }, - "node_modules/elliptic": { - "version": "6.5.7", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", - "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", - "dev": true, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, - "node_modules/emoji-regex": { - "version": "9.2.2", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", - "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true - }, - "node_modules/end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, - "dependencies": { - "once": "^1.4.0" - } - }, - "node_modules/esbuild": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz", - "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==", - "dev": true, - "hasInstallScript": true, - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.24.0", - "@esbuild/android-arm": "0.24.0", - "@esbuild/android-arm64": "0.24.0", - "@esbuild/android-x64": "0.24.0", - "@esbuild/darwin-arm64": "0.24.0", - "@esbuild/darwin-x64": "0.24.0", - "@esbuild/freebsd-arm64": "0.24.0", - "@esbuild/freebsd-x64": "0.24.0", - "@esbuild/linux-arm": "0.24.0", - "@esbuild/linux-arm64": "0.24.0", - "@esbuild/linux-ia32": "0.24.0", - "@esbuild/linux-loong64": "0.24.0", - "@esbuild/linux-mips64el": "0.24.0", - "@esbuild/linux-ppc64": "0.24.0", - "@esbuild/linux-riscv64": "0.24.0", - "@esbuild/linux-s390x": "0.24.0", - "@esbuild/linux-x64": "0.24.0", - "@esbuild/netbsd-x64": "0.24.0", - "@esbuild/openbsd-arm64": "0.24.0", - "@esbuild/openbsd-x64": "0.24.0", - "@esbuild/sunos-x64": "0.24.0", - "@esbuild/win32-arm64": "0.24.0", - "@esbuild/win32-ia32": "0.24.0", - "@esbuild/win32-x64": "0.24.0" - } - }, - "node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/eslint": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", - "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", - "dev": true, - "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.18.0", - "@eslint/core": "^0.7.0", - "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.14.0", - "@eslint/plugin-kit": "^0.2.0", - "@humanfs/node": "^0.16.6", - "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.0", - "@types/estree": "^1.0.6", - "@types/json-schema": "^7.0.15", - "ajv": "^6.12.4", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.3.2", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^8.2.0", - "eslint-visitor-keys": "^4.2.0", - "espree": "^10.3.0", - "esquery": "^1.5.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^8.0.0", - "find-up": "^5.0.0", - "glob-parent": "^6.0.2", - "ignore": "^5.2.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.1.2", - "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "text-table": "^0.2.0" - }, - "bin": { - "eslint": "bin/eslint.js" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://eslint.org/donate" - }, - "peerDependencies": { - "jiti": "*" - }, - "peerDependenciesMeta": { - "jiti": { - "optional": true - } - } - }, - "node_modules/eslint-config-prettier": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", - "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", - "dev": true, - "bin": { - "eslint-config-prettier": "bin/cli.js" - }, - "peerDependencies": { - "eslint": ">=7.0.0" - } - }, - "node_modules/eslint-plugin-prettier": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", - "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", - "dev": true, - "dependencies": { - "prettier-linter-helpers": "^1.0.0", - "synckit": "^0.9.1" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint-plugin-prettier" - }, - "peerDependencies": { - "@types/eslint": ">=8.0.0", - "eslint": ">=8.0.0", - "eslint-config-prettier": "*", - "prettier": ">=3.0.0" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "eslint-config-prettier": { - "optional": true - } - } - }, - "node_modules/eslint-scope": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", - "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/espree": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", - "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", - "dev": true, - "dependencies": { - "acorn": "^8.14.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.2.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/esquery": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", - "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", - "dev": true, - "dependencies": { - "estraverse": "^5.1.0" - }, - "engines": { - "node": ">=0.10" - } - }, - "node_modules/esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", - "dev": true, - "dependencies": { - "estraverse": "^5.2.0" - }, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/events": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", - "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true, - "engines": { - "node": ">=0.8.x" - } - }, - "node_modules/execa": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", - "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.3", - "get-stream": "^8.0.1", - "human-signals": "^5.0.0", - "is-stream": "^3.0.0", - "merge-stream": "^2.0.0", - "npm-run-path": "^5.1.0", - "onetime": "^6.0.0", - "signal-exit": "^4.1.0", - "strip-final-newline": "^3.0.0" - }, - "engines": { - "node": ">=16.17" - }, - "funding": { - "url": "https://github.com/sindresorhus/execa?sponsor=1" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "node_modules/fast-diff": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", - "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", - "dev": true - }, - "node_modules/fast-glob": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", - "dev": true, - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "node_modules/fast-glob/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true - }, - "node_modules/fast-redact": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz", - "integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/fastq": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", - "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", - "dev": true, - "dependencies": { - "reusify": "^1.0.4" - } - }, - "node_modules/file-entry-cache": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", - "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", - "dev": true, - "dependencies": { - "flat-cache": "^4.0.0" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/filter-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", - "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/find-up": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", - "dev": true, - "dependencies": { - "locate-path": "^6.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/flat-cache": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", - "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", - "dev": true, - "dependencies": { - "flatted": "^3.2.9", - "keyv": "^4.5.4" - }, - "engines": { - "node": ">=16" - } - }, - "node_modules/flatted": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", - "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", - "dev": true - }, - "node_modules/foreground-child": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", - "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", - "dev": true, - "dependencies": { - "cross-spawn": "^7.0.0", - "signal-exit": "^4.0.1" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/get-port-please": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/get-port-please/-/get-port-please-3.1.2.tgz", - "integrity": "sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ==", - "dev": true - }, - "node_modules/get-stream": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", - "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", - "dev": true, - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/glob": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", - "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", - "dev": true, - "dependencies": { - "foreground-child": "^3.1.0", - "jackspeak": "^4.0.1", - "minimatch": "^10.0.0", - "minipass": "^7.1.2", - "package-json-from-dist": "^1.0.0", - "path-scurry": "^2.0.0" - }, - "bin": { - "glob": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/glob-parent": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", - "dev": true, - "dependencies": { - "is-glob": "^4.0.3" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/glob/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/glob/node_modules/minimatch": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", - "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/globals": { - "version": "15.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.11.0.tgz", - "integrity": "sha512-yeyNSjdbyVaWurlwCpcA6XNBrHTMIeDdj0/hnvX/OLJ9ekOXYbLsLinH/MucQyGvNnXhidTdNhTtJaffL2sMfw==", - "dev": true, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/graphemer": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", - "dev": true - }, - "node_modules/h3": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/h3/-/h3-1.13.0.tgz", - "integrity": "sha512-vFEAu/yf8UMUcB4s43OaDaigcqpQd14yanmOsn+NcRX3/guSKncyE2rOYhq8RIchgJrPSs/QiIddnTTR1ddiAg==", - "dev": true, - "dependencies": { - "cookie-es": "^1.2.2", - "crossws": ">=0.2.0 <0.4.0", - "defu": "^6.1.4", - "destr": "^2.0.3", - "iron-webcrypto": "^1.2.1", - "ohash": "^1.1.4", - "radix3": "^1.1.2", - "ufo": "^1.5.4", - "uncrypto": "^0.1.3", - "unenv": "^1.10.0" - } - }, - "node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/hash.js": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", - "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.1" - } - }, - "node_modules/hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", - "dev": true, - "dependencies": { - "hash.js": "^1.0.3", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/http-shutdown": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/http-shutdown/-/http-shutdown-1.2.2.tgz", - "integrity": "sha512-S9wWkJ/VSY9/k4qcjG318bqJNruzE4HySUhFYknwmu6LBP97KLLfwNf+n4V1BHurvFNkSKLFnK/RsuUnRTf9Vw==", - "dev": true, - "engines": { - "iojs": ">= 1.0.0", - "node": ">= 0.12.0" - } - }, - "node_modules/human-signals": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", - "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", - "dev": true, - "engines": { - "node": ">=16.17.0" - } - }, - "node_modules/idb-keyval": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-6.2.1.tgz", - "integrity": "sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg==", - "dev": true - }, - "node_modules/ignore": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", - "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, - "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", - "dev": true, - "dependencies": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", - "dev": true, - "engines": { - "node": ">=0.8.19" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "node_modules/iron-webcrypto": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/iron-webcrypto/-/iron-webcrypto-1.2.1.tgz", - "integrity": "sha512-feOM6FaSr6rEABp/eDfVseKyTMDt+KGpeB35SkVn9Tyn0CqvVsY3EwI0v5i8nMHyJnzCIQf7nsy3p41TPkJZhg==", - "dev": true, - "funding": { - "url": "https://github.com/sponsors/brc-dd" - } - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-docker": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", - "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", - "dev": true, - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-inside-container": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", - "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", - "dev": true, - "dependencies": { - "is-docker": "^3.0.0" - }, - "bin": { - "is-inside-container": "cli.js" - }, - "engines": { - "node": ">=14.16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", - "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", - "dev": true, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-wsl": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", - "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", - "dev": true, - "dependencies": { - "is-inside-container": "^1.0.0" - }, - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is64bit": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is64bit/-/is64bit-2.0.0.tgz", - "integrity": "sha512-jv+8jaWCl0g2lSBkNSVXdzfBA0npK1HGC2KtWM9FumFRoGS94g3NbCCLVnCYHLjp4GrW2KZeeSTMo5ddtznmGw==", - "dev": true, - "dependencies": { - "system-architecture": "^0.1.0" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true - }, - "node_modules/jackspeak": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", - "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", - "dev": true, - "dependencies": { - "@isaacs/cliui": "^8.0.2" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/jiti": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.0.tgz", - "integrity": "sha512-H5UpaUI+aHOqZXlYOaFP/8AzKsg+guWu+Pr3Y8i7+Y3zr1aXAvCvTAQ1RxSc6oVD8R8c7brgNtTVP91E7upH/g==", - "dev": true, - "bin": { - "jiti": "lib/jiti-cli.mjs" - } - }, - "node_modules/js-sha3": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", - "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==", - "dev": true - }, - "node_modules/js-yaml": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", - "dev": true, - "dependencies": { - "argparse": "^2.0.1" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/json-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", - "dev": true - }, - "node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "node_modules/json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", - "dev": true - }, - "node_modules/keyv": { - "version": "4.5.4", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", - "dev": true, - "dependencies": { - "json-buffer": "3.0.1" - } - }, - "node_modules/keyvaluestorage-interface": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/keyvaluestorage-interface/-/keyvaluestorage-interface-1.0.0.tgz", - "integrity": "sha512-8t6Q3TclQ4uZynJY9IGr2+SsIGwK9JHcO6ootkHCGA0CrQCRy+VkouYNO2xicET6b9al7QKzpebNow+gkpCL8g==", - "dev": true - }, - "node_modules/levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "dependencies": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/listhen": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/listhen/-/listhen-1.9.0.tgz", - "integrity": "sha512-I8oW2+QL5KJo8zXNWX046M134WchxsXC7SawLPvRQpogCbkyQIaFxPE89A2HiwR7vAK2Dm2ERBAmyjTYGYEpBg==", - "dev": true, - "dependencies": { - "@parcel/watcher": "^2.4.1", - "@parcel/watcher-wasm": "^2.4.1", - "citty": "^0.1.6", - "clipboardy": "^4.0.0", - "consola": "^3.2.3", - "crossws": ">=0.2.0 <0.4.0", - "defu": "^6.1.4", - "get-port-please": "^3.1.2", - "h3": "^1.12.0", - "http-shutdown": "^1.2.2", - "jiti": "^2.1.2", - "mlly": "^1.7.1", - "node-forge": "^1.3.1", - "pathe": "^1.1.2", - "std-env": "^3.7.0", - "ufo": "^1.5.4", - "untun": "^0.1.3", - "uqr": "^0.1.2" - }, - "bin": { - "listen": "bin/listhen.mjs", - "listhen": "bin/listhen.mjs" - } - }, - "node_modules/locate-path": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", - "dev": true, - "dependencies": { - "p-locate": "^5.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", - "dev": true - }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", - "dev": true - }, - "node_modules/lru-cache": { - "version": "11.0.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.2.tgz", - "integrity": "sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==", - "dev": true, - "engines": { - "node": "20 || >=22" - } - }, - "node_modules/merge-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", - "dev": true - }, - "node_modules/merge2": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", - "dev": true, - "engines": { - "node": ">= 8" - } - }, - "node_modules/micromatch": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", - "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", - "dev": true, - "dependencies": { - "braces": "^3.0.3", - "picomatch": "^2.3.1" - }, - "engines": { - "node": ">=8.6" - } - }, - "node_modules/mime": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", - "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", - "dev": true, - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/mime-db": { - "version": "1.33.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", - "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.18", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", - "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", - "dev": true, - "dependencies": { - "mime-db": "~1.33.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mimic-fn": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", - "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true - }, - "node_modules/minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", - "dev": true - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minipass": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", - "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, - "engines": { - "node": ">=16 || 14 >=14.17" - } - }, - "node_modules/mlly": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.2.tgz", - "integrity": "sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==", - "dev": true, - "dependencies": { - "acorn": "^8.12.1", - "pathe": "^1.1.2", - "pkg-types": "^1.2.0", - "ufo": "^1.5.4" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true - }, - "node_modules/multiformats": { - "version": "9.9.0", - "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz", - "integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==", - "dev": true - }, - "node_modules/natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", - "dev": true - }, - "node_modules/node-addon-api": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", - "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", - "dev": true - }, - "node_modules/node-fetch-native": { - "version": "1.6.4", - "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.4.tgz", - "integrity": "sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==", - "dev": true - }, - "node_modules/node-forge": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", - "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", - "dev": true, - "engines": { - "node": ">= 6.13.0" - } - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/npm-run-path": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", - "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", - "dev": true, - "dependencies": { - "path-key": "^4.0.0" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/npm-run-path/node_modules/path-key": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", - "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ofetch": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.4.1.tgz", - "integrity": "sha512-QZj2DfGplQAr2oj9KzceK9Hwz6Whxazmn85yYeVuS3u9XTMOGMRx0kO95MQ+vLsj/S/NwBDMMLU5hpxvI6Tklw==", - "dev": true, - "dependencies": { - "destr": "^2.0.3", - "node-fetch-native": "^1.6.4", - "ufo": "^1.5.4" - } - }, - "node_modules/ohash": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/ohash/-/ohash-1.1.4.tgz", - "integrity": "sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==", - "dev": true - }, - "node_modules/on-exit-leak-free": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", - "integrity": "sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg==", - "dev": true - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/onetime": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", - "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", - "dev": true, - "dependencies": { - "mimic-fn": "^4.0.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/optionator": { - "version": "0.9.4", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", - "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", - "dev": true, - "dependencies": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.5" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/p-limit": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", - "dev": true, - "dependencies": { - "yocto-queue": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-locate": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", - "dev": true, - "dependencies": { - "p-limit": "^3.0.2" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/package-json-from-dist": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", - "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", - "dev": true - }, - "node_modules/parent-module": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", - "dev": true, - "dependencies": { - "callsites": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w==", - "dev": true - }, - "node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/path-scurry": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", - "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", - "dev": true, - "dependencies": { - "lru-cache": "^11.0.0", - "minipass": "^7.1.2" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/path-to-regexp": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", - "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==", - "dev": true - }, - "node_modules/pathe": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", - "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", - "dev": true - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/pino": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/pino/-/pino-7.11.0.tgz", - "integrity": "sha512-dMACeu63HtRLmCG8VKdy4cShCPKaYDR4youZqoSWLxl5Gu99HUw8bw75thbPv9Nip+H+QYX8o3ZJbTdVZZ2TVg==", - "dev": true, - "dependencies": { - "atomic-sleep": "^1.0.0", - "fast-redact": "^3.0.0", - "on-exit-leak-free": "^0.2.0", - "pino-abstract-transport": "v0.5.0", - "pino-std-serializers": "^4.0.0", - "process-warning": "^1.0.0", - "quick-format-unescaped": "^4.0.3", - "real-require": "^0.1.0", - "safe-stable-stringify": "^2.1.0", - "sonic-boom": "^2.2.1", - "thread-stream": "^0.15.1" - }, - "bin": { - "pino": "bin.js" - } - }, - "node_modules/pino-abstract-transport": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz", - "integrity": "sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ==", - "dev": true, - "dependencies": { - "duplexify": "^4.1.2", - "split2": "^4.0.0" - } - }, - "node_modules/pino-std-serializers": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz", - "integrity": "sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q==", - "dev": true - }, - "node_modules/pkg-types": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.2.1.tgz", - "integrity": "sha512-sQoqa8alT3nHjGuTjuKgOnvjo4cljkufdtLMnO2LBP/wRwuDlo1tkaEdMxCRhyGRPacv/ztlZgDPm2b7FAmEvw==", - "dev": true, - "dependencies": { - "confbox": "^0.1.8", - "mlly": "^1.7.2", - "pathe": "^1.1.2" - } - }, - "node_modules/pngjs": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", - "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", - "dev": true, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/prettier": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", - "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", - "dev": true, - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, - "node_modules/prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", - "dev": true, - "dependencies": { - "fast-diff": "^1.1.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/process-warning": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", - "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==", - "dev": true - }, - "node_modules/punycode": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/qrcode": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", - "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==", - "dev": true, - "dependencies": { - "dijkstrajs": "^1.0.1", - "pngjs": "^5.0.0", - "yargs": "^15.3.1" - }, - "bin": { - "qrcode": "bin/qrcode" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/query-string": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.3.tgz", - "integrity": "sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg==", - "dev": true, - "dependencies": { - "decode-uri-component": "^0.2.2", - "filter-obj": "^1.1.0", - "split-on-first": "^1.0.0", - "strict-uri-encode": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/queue-microtask": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/quick-format-unescaped": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", - "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", - "dev": true - }, - "node_modules/radix3": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/radix3/-/radix3-1.1.2.tgz", - "integrity": "sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==", - "dev": true - }, - "node_modules/range-parser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", - "integrity": "sha512-kA5WQoNVo4t9lNx2kQNFCxKeBl5IbbSNBl1M/tLkw9WCn+hxNBAW5Qh8gdhs63CJnhjJ2zQWFoqPJP2sK1AV5A==", - "dev": true, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/real-require": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.1.0.tgz", - "integrity": "sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg==", - "dev": true, - "engines": { - "node": ">= 12.13.0" - } - }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, - "node_modules/resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", - "dev": true, - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "node_modules/rimraf": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", - "integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==", - "dev": true, - "dependencies": { - "glob": "^11.0.0", - "package-json-from-dist": "^1.0.0" - }, - "bin": { - "rimraf": "dist/esm/bin.mjs" - }, - "engines": { - "node": "20 || >=22" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] - }, - "node_modules/safe-stable-stringify": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", - "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "dev": true, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/serve-handler": { - "version": "6.1.6", - "resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.6.tgz", - "integrity": "sha512-x5RL9Y2p5+Sh3D38Fh9i/iQ5ZK+e4xuXRd/pGbM4D13tgo/MGwbttUk8emytcr1YYzBYs+apnUngBDFYfpjPuQ==", - "dev": true, - "dependencies": { - "bytes": "3.0.0", - "content-disposition": "0.5.2", - "mime-types": "2.1.18", - "minimatch": "3.1.2", - "path-is-inside": "1.0.2", - "path-to-regexp": "3.3.0", - "range-parser": "1.2.0" - } - }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", - "dev": true - }, - "node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/sonic-boom": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.8.0.tgz", - "integrity": "sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==", - "dev": true, - "dependencies": { - "atomic-sleep": "^1.0.0" - } - }, - "node_modules/split-on-first": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", - "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/split2": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", - "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", - "dev": true, - "engines": { - "node": ">= 10.x" - } - }, - "node_modules/std-env": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", - "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", - "dev": true - }, - "node_modules/stream-shift": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", - "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", - "dev": true - }, - "node_modules/strict-uri-encode": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", - "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/string-width": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", - "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", - "dev": true, - "dependencies": { - "eastasianwidth": "^0.2.0", - "emoji-regex": "^9.2.2", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/string-width-cjs": { - "name": "string-width", - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/string-width-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/strip-final-newline": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", - "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/synckit": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", - "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", - "dev": true, - "dependencies": { - "@pkgr/core": "^0.1.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, - "node_modules/synckit/node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true - }, - "node_modules/system-architecture": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz", - "integrity": "sha512-ulAk51I9UVUyJgxlv9M6lFot2WP3e7t8Kz9+IS6D4rVba1tR9kON+Ey69f+1R4Q8cd45Lod6a4IcJIxnzGc/zA==", - "dev": true, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true - }, - "node_modules/thread-stream": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", - "integrity": "sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==", - "dev": true, - "dependencies": { - "real-require": "^0.1.0" - } - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/ts-api-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz", - "integrity": "sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==", - "dev": true, - "engines": { - "node": ">=16" - }, - "peerDependencies": { - "typescript": ">=4.2.0" - } - }, - "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true - }, - "node_modules/type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "dependencies": { - "prelude-ls": "^1.2.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/typescript": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", - "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/ufo": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.5.4.tgz", - "integrity": "sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==", - "dev": true - }, - "node_modules/uint8arrays": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.1.0.tgz", - "integrity": "sha512-ei5rfKtoRO8OyOIor2Rz5fhzjThwIHJZ3uyDPnDHTXbP0aMQ1RN/6AI5B5d9dBxJOU+BvOAk7ZQ1xphsX8Lrog==", - "dev": true, - "dependencies": { - "multiformats": "^9.4.2" - } - }, - "node_modules/uncrypto": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/uncrypto/-/uncrypto-0.1.3.tgz", - "integrity": "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==", - "dev": true - }, - "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true - }, - "node_modules/unenv": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/unenv/-/unenv-1.10.0.tgz", - "integrity": "sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==", - "dev": true, - "dependencies": { - "consola": "^3.2.3", - "defu": "^6.1.4", - "mime": "^3.0.0", - "node-fetch-native": "^1.6.4", - "pathe": "^1.1.2" - } - }, - "node_modules/unstorage": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/unstorage/-/unstorage-1.13.1.tgz", - "integrity": "sha512-ELexQHUrG05QVIM/iUeQNdl9FXDZhqLJ4yP59fnmn2jGUh0TEulwOgov1ubOb3Gt2ZGK/VMchJwPDNVEGWQpRg==", - "dev": true, - "dependencies": { - "anymatch": "^3.1.3", - "chokidar": "^3.6.0", - "citty": "^0.1.6", - "destr": "^2.0.3", - "h3": "^1.13.0", - "listhen": "^1.9.0", - "lru-cache": "^10.4.3", - "node-fetch-native": "^1.6.4", - "ofetch": "^1.4.1", - "ufo": "^1.5.4" - }, - "peerDependencies": { - "@azure/app-configuration": "^1.7.0", - "@azure/cosmos": "^4.1.1", - "@azure/data-tables": "^13.2.2", - "@azure/identity": "^4.5.0", - "@azure/keyvault-secrets": "^4.9.0", - "@azure/storage-blob": "^12.25.0", - "@capacitor/preferences": "^6.0.2", - "@netlify/blobs": "^6.5.0 || ^7.0.0 || ^8.1.0", - "@planetscale/database": "^1.19.0", - "@upstash/redis": "^1.34.3", - "@vercel/kv": "^1.0.1", - "idb-keyval": "^6.2.1", - "ioredis": "^5.4.1" - }, - "peerDependenciesMeta": { - "@azure/app-configuration": { - "optional": true - }, - "@azure/cosmos": { - "optional": true - }, - "@azure/data-tables": { - "optional": true - }, - "@azure/identity": { - "optional": true - }, - "@azure/keyvault-secrets": { - "optional": true - }, - "@azure/storage-blob": { - "optional": true - }, - "@capacitor/preferences": { - "optional": true - }, - "@netlify/blobs": { - "optional": true - }, - "@planetscale/database": { - "optional": true - }, - "@upstash/redis": { - "optional": true - }, - "@vercel/kv": { - "optional": true - }, - "idb-keyval": { - "optional": true - }, - "ioredis": { - "optional": true - } - } - }, - "node_modules/unstorage/node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true - }, - "node_modules/untun": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/untun/-/untun-0.1.3.tgz", - "integrity": "sha512-4luGP9LMYszMRZwsvyUd9MrxgEGZdZuZgpVQHEEX0lCYFESasVRvZd0EYpCkOIbJKHMuv0LskpXc/8Un+MJzEQ==", - "dev": true, - "dependencies": { - "citty": "^0.1.5", - "consola": "^3.2.3", - "pathe": "^1.1.1" - }, - "bin": { - "untun": "bin/untun.mjs" - } - }, - "node_modules/uqr": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/uqr/-/uqr-0.1.2.tgz", - "integrity": "sha512-MJu7ypHq6QasgF5YRTjqscSzQp/W11zoUk6kvmlH+fmWEs63Y0Eib13hYFwAzagRJcVY8WVnlV+eBDUGMJ5IbA==", - "dev": true - }, - "node_modules/uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", - "dev": true, - "dependencies": { - "punycode": "^2.1.0" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true - }, - "node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/which-module": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", - "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", - "dev": true - }, - "node_modules/word-wrap": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/wrap-ansi": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", - "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", - "dev": true, - "dependencies": { - "ansi-styles": "^6.1.0", - "string-width": "^5.0.1", - "strip-ansi": "^7.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs": { - "name": "wrap-ansi", - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/wrap-ansi-cjs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", - "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true - }, - "node_modules/ws": { - "version": "7.5.10", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", - "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", - "dev": true, - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true - }, - "node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, - "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/yargs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/yargs/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/yargs/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yocto-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - } - } -} diff --git a/package.json b/package.json index a759c95..4c5358a 100644 --- a/package.json +++ b/package.json @@ -1,62 +1,21 @@ { - "name": "elven.js", - "version": "1.0.0", - "description": "Sync, sign and send transactions on the MultiversX blockchain in the browser.", - "type": "module", - "module": "build/elven.js", - "types": "build/types/elven.d.ts", - "exports": { - ".": { - "types": "./build/types/elven.d.ts", - "import": "./build/elven.js", - "browser": "./build/elven.js", - "default": "./build/elven.js" - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "author": "Julian Ćwirko ", - "license": "MIT", - "homepage": "https://www.elvenjs.com", - "repository": { - "type": "git", - "url": "git+https://github.com/elven-js/elven.js.git" - }, - "keywords": [ - "elrond", - "multiversx", - "xPortal", - "blockchain", - "sdk", - "javascript", - "browser", - "xalias" + "private": true, + "workspaces": [ + "packages/*", + "configs/*" ], "scripts": { - "build": "rimraf build && node ./esbuild.config.cjs && tsc && cp build/elven.js example/elven.js", - "dev:server": "node dev-server.mjs", - "lint": "eslint src/** --fix", - "prettier": "prettier --write 'src/**/*.{js,ts,json}'", - "check-types": "tsc", - "prepublishOnly": "npm run build" + "build": "turbo run build", + "dev": "turbo run dev", + "lint": "turbo run lint", + "check-types": "turbo run check-types", + "prettier": "turbo run prettier", + "clean": "turbo run clean && rm -rf node_modules" }, "devDependencies": { - "@eslint/eslintrc": "3.1.0", - "@eslint/js": "9.14.0", - "@types/qrcode": "1.5.5", - "@types/serve-handler": "6.1.4", - "@typescript-eslint/eslint-plugin": "8.12.2", - "@typescript-eslint/parser": "8.12.2", - "@walletconnect/sign-client": "^2.17.1", - "esbuild": "0.24.0", - "eslint": "9.14.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.2.1", - "globals": "15.11.0", - "prettier": "3.3.3", - "qrcode": "1.5.4", - "rimraf": "6.0.1", - "serve-handler": "6.1.6", - "typescript": "5.6.3" + "turbo": "2.2.3", + "@configs/eslint-config": "workspace:*", + "@configs/tsconfig": "workspace:*", + "@configs/esbuild": "workspace:*" } } \ No newline at end of file diff --git a/packages/@elven.js/mobile-signing-provider/esbuild.config.js b/packages/@elven.js/mobile-signing-provider/esbuild.config.js new file mode 100644 index 0000000..7893a57 --- /dev/null +++ b/packages/@elven.js/mobile-signing-provider/esbuild.config.js @@ -0,0 +1,21 @@ +import { baseConfig } from '@configs/esbuild'; +import esbuild from 'esbuild'; +import fs from 'fs'; + +esbuild + .build({ + ...baseConfig, + entryPoints: ['./src/mobile-signing-provider.ts'], + outfile: './build/mobile-signing-provider.js', + }) + .then((result) => { + fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); + return result; + }) + .then((result) => { + return esbuild.analyzeMetafile(result.metafile); + }) + .then((result) => { + fs.writeFileSync('./build/meta.txt', result); + }) + .catch(() => process.exit(1)); diff --git a/packages/@elven.js/mobile-signing-provider/package.json b/packages/@elven.js/mobile-signing-provider/package.json new file mode 100644 index 0000000..d88c9d3 --- /dev/null +++ b/packages/@elven.js/mobile-signing-provider/package.json @@ -0,0 +1,24 @@ +{ + "name": "@elven.js/mobile-signing-provider", + "version": "1.0.0", + "description": "Mobile signing provider for Elven.js.", + "type": "module", + "module": "build/mobile-signing-provider.js", + "types": "build/types/mobile-signing-provider.d.ts", + "exports": { + ".": { + "types": "./build/types/mobile-signing-provider.d.ts", + "import": "./build/mobile-signing-provider.js", + "browser": "./build/mobile-signing-provider.js", + "default": "./build/mobile-signing-provider.js" + }, + "./package.json": "./package.json" + }, + "scripts": { + "build": "rimraf build && node ./esbuild.config.cjs && tsc", + "lint": "eslint src/** --fix", + "prettier": "prettier --write 'src/**/*.{js,ts,json}'", + "check-types": "tsc --noEmit", + "clean": "rimraf build node_modules" + } +} \ No newline at end of file diff --git a/packages/@elven.js/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/@elven.js/mobile-signing-provider/src/mobile-signing-provider.ts new file mode 100644 index 0000000..68eebf6 --- /dev/null +++ b/packages/@elven.js/mobile-signing-provider/src/mobile-signing-provider.ts @@ -0,0 +1,5 @@ +const nothingHereForNow = () => { + console.log('nothing here for now'); +}; + +export default nothingHereForNow; diff --git a/packages/elven.js/esbuild.config.js b/packages/elven.js/esbuild.config.js new file mode 100644 index 0000000..ab8c928 --- /dev/null +++ b/packages/elven.js/esbuild.config.js @@ -0,0 +1,21 @@ +import { baseConfig } from '@configs/esbuild'; +import esbuild from 'esbuild'; +import fs from 'fs'; + +esbuild + .build({ + ...baseConfig, + entryPoints: ['./src/elven.ts'], + outfile: './build/elven.js', + }) + .then((result) => { + fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); + return result; + }) + .then((result) => { + return esbuild.analyzeMetafile(result.metafile); + }) + .then((result) => { + fs.writeFileSync('./build/meta.txt', result); + }) + .catch(() => process.exit(1)); diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json new file mode 100644 index 0000000..b2203b1 --- /dev/null +++ b/packages/elven.js/package.json @@ -0,0 +1,24 @@ +{ + "name": "elven.js", + "version": "1.0.0", + "description": "Sync, sign and send transactions on the MultiversX blockchain in the browser.", + "type": "module", + "module": "build/elven.js", + "types": "build/types/elven.d.ts", + "exports": { + ".": { + "types": "./build/types/elven.d.ts", + "import": "./build/elven.js", + "browser": "./build/elven.js", + "default": "./build/elven.js" + }, + "./package.json": "./package.json" + }, + "scripts": { + "build": "rimraf build && node ./esbuild.config.cjs && tsc", + "lint": "eslint src/** --fix", + "prettier": "prettier --write 'src/**/*.{js,ts,json}'", + "check-types": "tsc --noEmit", + "clean": "rimraf build node_modules" + } +} \ No newline at end of file diff --git a/src/auth/account-sync.ts b/packages/elven.js/src/auth/account-sync.ts similarity index 100% rename from src/auth/account-sync.ts rename to packages/elven.js/src/auth/account-sync.ts diff --git a/src/auth/expires-at.ts b/packages/elven.js/src/auth/expires-at.ts similarity index 100% rename from src/auth/expires-at.ts rename to packages/elven.js/src/auth/expires-at.ts diff --git a/src/auth/init-extension-provider.ts b/packages/elven.js/src/auth/init-extension-provider.ts similarity index 100% rename from src/auth/init-extension-provider.ts rename to packages/elven.js/src/auth/init-extension-provider.ts diff --git a/src/auth/init-mobile-provider.ts b/packages/elven.js/src/auth/init-mobile-provider.ts similarity index 100% rename from src/auth/init-mobile-provider.ts rename to packages/elven.js/src/auth/init-mobile-provider.ts diff --git a/src/auth/init-web-wallet-provider.ts b/packages/elven.js/src/auth/init-web-wallet-provider.ts similarity index 100% rename from src/auth/init-web-wallet-provider.ts rename to packages/elven.js/src/auth/init-web-wallet-provider.ts diff --git a/src/auth/login-with-extension.ts b/packages/elven.js/src/auth/login-with-extension.ts similarity index 100% rename from src/auth/login-with-extension.ts rename to packages/elven.js/src/auth/login-with-extension.ts diff --git a/src/auth/login-with-mobile.ts b/packages/elven.js/src/auth/login-with-mobile.ts similarity index 100% rename from src/auth/login-with-mobile.ts rename to packages/elven.js/src/auth/login-with-mobile.ts diff --git a/src/auth/login-with-native-auth-token.ts b/packages/elven.js/src/auth/login-with-native-auth-token.ts similarity index 100% rename from src/auth/login-with-native-auth-token.ts rename to packages/elven.js/src/auth/login-with-native-auth-token.ts diff --git a/src/auth/login-with-web-wallet.ts b/packages/elven.js/src/auth/login-with-web-wallet.ts similarity index 100% rename from src/auth/login-with-web-wallet.ts rename to packages/elven.js/src/auth/login-with-web-wallet.ts diff --git a/src/auth/logout.ts b/packages/elven.js/src/auth/logout.ts similarity index 100% rename from src/auth/logout.ts rename to packages/elven.js/src/auth/logout.ts diff --git a/src/auth/qr-code-and-pairings-builder.ts b/packages/elven.js/src/auth/qr-code-and-pairings-builder.ts similarity index 100% rename from src/auth/qr-code-and-pairings-builder.ts rename to packages/elven.js/src/auth/qr-code-and-pairings-builder.ts diff --git a/src/core/account.ts b/packages/elven.js/src/core/account.ts similarity index 100% rename from src/core/account.ts rename to packages/elven.js/src/core/account.ts diff --git a/src/core/async-timer.ts b/packages/elven.js/src/core/async-timer.ts similarity index 100% rename from src/core/async-timer.ts rename to packages/elven.js/src/core/async-timer.ts diff --git a/src/core/browser-extension-signing.ts b/packages/elven.js/src/core/browser-extension-signing.ts similarity index 100% rename from src/core/browser-extension-signing.ts rename to packages/elven.js/src/core/browser-extension-signing.ts diff --git a/src/core/constants.ts b/packages/elven.js/src/core/constants.ts similarity index 100% rename from src/core/constants.ts rename to packages/elven.js/src/core/constants.ts diff --git a/src/core/errors.ts b/packages/elven.js/src/core/errors.ts similarity index 100% rename from src/core/errors.ts rename to packages/elven.js/src/core/errors.ts diff --git a/src/core/keccak256.ts b/packages/elven.js/src/core/keccak256.ts similarity index 100% rename from src/core/keccak256.ts rename to packages/elven.js/src/core/keccak256.ts diff --git a/src/core/message.ts b/packages/elven.js/src/core/message.ts similarity index 100% rename from src/core/message.ts rename to packages/elven.js/src/core/message.ts diff --git a/src/core/native-auth-client.ts b/packages/elven.js/src/core/native-auth-client.ts similarity index 100% rename from src/core/native-auth-client.ts rename to packages/elven.js/src/core/native-auth-client.ts diff --git a/src/core/network-provider.ts b/packages/elven.js/src/core/network-provider.ts similarity index 100% rename from src/core/network-provider.ts rename to packages/elven.js/src/core/network-provider.ts diff --git a/src/core/transaction-converter.ts b/packages/elven.js/src/core/transaction-converter.ts similarity index 100% rename from src/core/transaction-converter.ts rename to packages/elven.js/src/core/transaction-converter.ts diff --git a/src/core/transaction-status.ts b/packages/elven.js/src/core/transaction-status.ts similarity index 100% rename from src/core/transaction-status.ts rename to packages/elven.js/src/core/transaction-status.ts diff --git a/src/core/transaction-watcher.ts b/packages/elven.js/src/core/transaction-watcher.ts similarity index 100% rename from src/core/transaction-watcher.ts rename to packages/elven.js/src/core/transaction-watcher.ts diff --git a/src/core/transaction.ts b/packages/elven.js/src/core/transaction.ts similarity index 100% rename from src/core/transaction.ts rename to packages/elven.js/src/core/transaction.ts diff --git a/src/core/types.ts b/packages/elven.js/src/core/types.ts similarity index 100% rename from src/core/types.ts rename to packages/elven.js/src/core/types.ts diff --git a/src/core/utils.ts b/packages/elven.js/src/core/utils.ts similarity index 100% rename from src/core/utils.ts rename to packages/elven.js/src/core/utils.ts diff --git a/src/core/walletconnect-signing.ts b/packages/elven.js/src/core/walletconnect-signing.ts similarity index 100% rename from src/core/walletconnect-signing.ts rename to packages/elven.js/src/core/walletconnect-signing.ts diff --git a/src/core/walletconnect-utils.ts b/packages/elven.js/src/core/walletconnect-utils.ts similarity index 100% rename from src/core/walletconnect-utils.ts rename to packages/elven.js/src/core/walletconnect-utils.ts diff --git a/src/core/web-wallet-signing.ts b/packages/elven.js/src/core/web-wallet-signing.ts similarity index 100% rename from src/core/web-wallet-signing.ts rename to packages/elven.js/src/core/web-wallet-signing.ts diff --git a/src/core/webview-event-handler.ts b/packages/elven.js/src/core/webview-event-handler.ts similarity index 100% rename from src/core/webview-event-handler.ts rename to packages/elven.js/src/core/webview-event-handler.ts diff --git a/src/core/webview-signing.ts b/packages/elven.js/src/core/webview-signing.ts similarity index 100% rename from src/core/webview-signing.ts rename to packages/elven.js/src/core/webview-signing.ts diff --git a/src/elven.ts b/packages/elven.js/src/elven.ts similarity index 100% rename from src/elven.ts rename to packages/elven.js/src/elven.ts diff --git a/src/events-store.ts b/packages/elven.js/src/events-store.ts similarity index 100% rename from src/events-store.ts rename to packages/elven.js/src/events-store.ts diff --git a/src/initialize-events-store.ts b/packages/elven.js/src/initialize-events-store.ts similarity index 100% rename from src/initialize-events-store.ts rename to packages/elven.js/src/initialize-events-store.ts diff --git a/src/interaction/guardian-operations.ts b/packages/elven.js/src/interaction/guardian-operations.ts similarity index 100% rename from src/interaction/guardian-operations.ts rename to packages/elven.js/src/interaction/guardian-operations.ts diff --git a/src/interaction/post-send-tx.ts b/packages/elven.js/src/interaction/post-send-tx.ts similarity index 100% rename from src/interaction/post-send-tx.ts rename to packages/elven.js/src/interaction/post-send-tx.ts diff --git a/src/interaction/pre-send-tx.ts b/packages/elven.js/src/interaction/pre-send-tx.ts similarity index 100% rename from src/interaction/pre-send-tx.ts rename to packages/elven.js/src/interaction/pre-send-tx.ts diff --git a/src/interaction/web-wallet-sign-message-finalize.ts b/packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts similarity index 100% rename from src/interaction/web-wallet-sign-message-finalize.ts rename to packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts diff --git a/src/interaction/web-wallet-tx-finalize.ts b/packages/elven.js/src/interaction/web-wallet-tx-finalize.ts similarity index 100% rename from src/interaction/web-wallet-tx-finalize.ts rename to packages/elven.js/src/interaction/web-wallet-tx-finalize.ts diff --git a/src/main.ts b/packages/elven.js/src/main.ts similarity index 100% rename from src/main.ts rename to packages/elven.js/src/main.ts diff --git a/src/types.ts b/packages/elven.js/src/types.ts similarity index 100% rename from src/types.ts rename to packages/elven.js/src/types.ts diff --git a/src/utils/amount.ts b/packages/elven.js/src/utils/amount.ts similarity index 100% rename from src/utils/amount.ts rename to packages/elven.js/src/utils/amount.ts diff --git a/src/utils/constants.ts b/packages/elven.js/src/utils/constants.ts similarity index 100% rename from src/utils/constants.ts rename to packages/elven.js/src/utils/constants.ts diff --git a/src/utils/error-parse.ts b/packages/elven.js/src/utils/error-parse.ts similarity index 100% rename from src/utils/error-parse.ts rename to packages/elven.js/src/utils/error-parse.ts diff --git a/src/utils/get-param-from-url.ts b/packages/elven.js/src/utils/get-param-from-url.ts similarity index 100% rename from src/utils/get-param-from-url.ts rename to packages/elven.js/src/utils/get-param-from-url.ts diff --git a/src/utils/get-random-address-from-network.ts b/packages/elven.js/src/utils/get-random-address-from-network.ts similarity index 100% rename from src/utils/get-random-address-from-network.ts rename to packages/elven.js/src/utils/get-random-address-from-network.ts diff --git a/src/utils/ls-helpers.ts b/packages/elven.js/src/utils/ls-helpers.ts similarity index 100% rename from src/utils/ls-helpers.ts rename to packages/elven.js/src/utils/ls-helpers.ts diff --git a/src/utils/with-login-events.ts b/packages/elven.js/src/utils/with-login-events.ts similarity index 100% rename from src/utils/with-login-events.ts rename to packages/elven.js/src/utils/with-login-events.ts diff --git a/src/webview-provider/base64-utils.ts b/packages/elven.js/src/webview-provider/base64-utils.ts similarity index 100% rename from src/webview-provider/base64-utils.ts rename to packages/elven.js/src/webview-provider/base64-utils.ts diff --git a/src/webview-provider/decode-login-token.ts b/packages/elven.js/src/webview-provider/decode-login-token.ts similarity index 100% rename from src/webview-provider/decode-login-token.ts rename to packages/elven.js/src/webview-provider/decode-login-token.ts diff --git a/src/webview-provider/decode-native-auth-token.ts b/packages/elven.js/src/webview-provider/decode-native-auth-token.ts similarity index 100% rename from src/webview-provider/decode-native-auth-token.ts rename to packages/elven.js/src/webview-provider/decode-native-auth-token.ts diff --git a/src/webview-provider/utils.ts b/packages/elven.js/src/webview-provider/utils.ts similarity index 100% rename from src/webview-provider/utils.ts rename to packages/elven.js/src/webview-provider/utils.ts diff --git a/tsconfig.json b/tsconfig.json index 22e8b9c..1d1630f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,12 @@ { - "include": ["src/**/*"], + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./configs/tsconfig/base.json", "compilerOptions": { - "strict": true, - "target": "ES2020", - "module": "ES2020", - "declaration": true, - "declarationDir": "build/types", - "emitDeclarationOnly": true, - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true, - "resolveJsonModule": true, - "types": ["node"], - "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "elven.js(/*)": ["packages/elven.js/src$1"], + "@elven.js/mobile-signing-provider(/*)": ["packages/@elven.js/mobile-signing-provider/src$1"] + } }, + "exclude": ["node_modules"] } diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..2e3e89f --- /dev/null +++ b/turbo.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": [ + ".env" + ], + "tasks": { + "build": { + "dependsOn": [ + "^build" + ], + "outputs": [ + "build/**" + ] + }, + "lint": { + "outputs": [], + "cache": true + }, + "dev": { + "cache": false, + "persistent": true + }, + "check-types": { + "cache": true, + "outputs": [] + }, + "prettier": { + "cache": true, + "outputs": [] + }, + "clean": { + "cache": false + } + } +} \ No newline at end of file From 22b7a78c82dcf5fe7fa74dc70c6740a2324ab37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 12:01:48 +0100 Subject: [PATCH 02/13] with working lint, prettier, clean, type check --- configs/esbuild/package.json | 6 +- configs/eslint-config/package.json | 11 +- configs/tsconfig/package.json | 5 +- eslint.config.js | 9 + eslint.config.mjs | 5 - package-lock.json | 4655 +++++++++++++++++ package.json | 14 +- packages/elven.js/package.json | 13 +- packages/elven.js/tsconfig.json | 5 + .../mobile-signing-provider/esbuild.config.js | 0 .../mobile-signing-provider/package.json | 4 +- .../src/mobile-signing-provider.ts | 0 .../mobile-signing-provider/tsconfig.json | 5 + tsconfig.json | 6 +- 14 files changed, 4714 insertions(+), 24 deletions(-) create mode 100644 eslint.config.js delete mode 100644 eslint.config.mjs create mode 100644 package-lock.json create mode 100644 packages/elven.js/tsconfig.json rename packages/{@elven.js => }/mobile-signing-provider/esbuild.config.js (100%) rename packages/{@elven.js => }/mobile-signing-provider/package.json (85%) rename packages/{@elven.js => }/mobile-signing-provider/src/mobile-signing-provider.ts (100%) create mode 100644 packages/mobile-signing-provider/tsconfig.json diff --git a/configs/esbuild/package.json b/configs/esbuild/package.json index 089cb05..09080b9 100644 --- a/configs/esbuild/package.json +++ b/configs/esbuild/package.json @@ -5,5 +5,9 @@ "main": "index.js", "devDependencies": { "esbuild": "0.24.0" + }, + "scripts": { + "lint": "eslint \"**/*.{ts,tsx,js,jsx}\" --fix", + "prettier": "prettier --write '**/*.{js,ts,json}'" } -} \ No newline at end of file +} diff --git a/configs/eslint-config/package.json b/configs/eslint-config/package.json index c73371b..aec5a87 100644 --- a/configs/eslint-config/package.json +++ b/configs/eslint-config/package.json @@ -1,6 +1,7 @@ { "name": "@configs/eslint-config", "version": "0.0.0", + "type": "module", "private": true, "main": "index.js", "devDependencies": { @@ -8,9 +9,11 @@ "@eslint/js": "9.14.0", "@typescript-eslint/eslint-plugin": "8.12.2", "@typescript-eslint/parser": "8.12.2", - "eslint": "9.14.0", "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.2.1", - "prettier": "3.3.3" + "eslint-plugin-prettier": "5.2.1" + }, + "scripts": { + "lint": "eslint \"**/*.{ts,tsx,js,jsx}\" --fix", + "prettier": "prettier --write '**/*.{js,ts,json}'" } -} \ No newline at end of file +} diff --git a/configs/tsconfig/package.json b/configs/tsconfig/package.json index 051ecf2..edfdd76 100644 --- a/configs/tsconfig/package.json +++ b/configs/tsconfig/package.json @@ -4,8 +4,5 @@ "private": true, "files": [ "base.json" - ], - "devDependencies": { - "typescript": "5.6.3" - } + ] } \ No newline at end of file diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..0358aaa --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,9 @@ +import eslintConfig from './configs/eslint-config/index.js'; + +export default [ + { + ignores: ['**/node_modules/**', '**/build/**', '**/.turbo/**'], + files: ['**/*.{js,jsx,ts,tsx}'], + }, + ...eslintConfig, +]; diff --git a/eslint.config.mjs b/eslint.config.mjs deleted file mode 100644 index c75ba51..0000000 --- a/eslint.config.mjs +++ /dev/null @@ -1,5 +0,0 @@ -export default { - root: true, - extends: ["./configs/eslint-config/index.js"], - ignorePatterns: ["node_modules", "build", "dist", ".turbo"] -}; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..dde9b77 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,4655 @@ +{ + "name": "elven.js-monorepo", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "elven.js-monorepo", + "workspaces": [ + "packages/*", + "configs/*" + ], + "devDependencies": { + "@configs/esbuild": "workspace:*", + "@configs/eslint-config": "workspace:*", + "@configs/tsconfig": "workspace:*", + "@types/node": "22.8.7", + "eslint": "9.14.0", + "prettier": "3.3.3", + "rimraf": "6.0.1", + "turbo": "2.2.3", + "typescript": "5.6.3" + } + }, + "configs/esbuild": { + "name": "@configs/esbuild", + "devDependencies": { + "esbuild": "0.24.0" + } + }, + "configs/esbuild/node_modules/@esbuild/linux-x64": { + "version": "0.24.0", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "configs/esbuild/node_modules/esbuild": { + "version": "0.24.0", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.24.0", + "@esbuild/android-arm": "0.24.0", + "@esbuild/android-arm64": "0.24.0", + "@esbuild/android-x64": "0.24.0", + "@esbuild/darwin-arm64": "0.24.0", + "@esbuild/darwin-x64": "0.24.0", + "@esbuild/freebsd-arm64": "0.24.0", + "@esbuild/freebsd-x64": "0.24.0", + "@esbuild/linux-arm": "0.24.0", + "@esbuild/linux-arm64": "0.24.0", + "@esbuild/linux-ia32": "0.24.0", + "@esbuild/linux-loong64": "0.24.0", + "@esbuild/linux-mips64el": "0.24.0", + "@esbuild/linux-ppc64": "0.24.0", + "@esbuild/linux-riscv64": "0.24.0", + "@esbuild/linux-s390x": "0.24.0", + "@esbuild/linux-x64": "0.24.0", + "@esbuild/netbsd-x64": "0.24.0", + "@esbuild/openbsd-arm64": "0.24.0", + "@esbuild/openbsd-x64": "0.24.0", + "@esbuild/sunos-x64": "0.24.0", + "@esbuild/win32-arm64": "0.24.0", + "@esbuild/win32-ia32": "0.24.0", + "@esbuild/win32-x64": "0.24.0" + } + }, + "configs/eslint-config": { + "name": "@configs/eslint-config", + "version": "0.0.0", + "devDependencies": { + "@eslint/eslintrc": "3.1.0", + "@eslint/js": "9.14.0", + "@typescript-eslint/eslint-plugin": "8.12.2", + "@typescript-eslint/parser": "8.12.2", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.2.1" + } + }, + "configs/eslint-config/node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "configs/eslint-config/node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "configs/eslint-config/node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "configs/eslint-config/node_modules/@pkgr/core": { + "version": "0.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.12.2", + "@typescript-eslint/type-utils": "8.12.2", + "@typescript-eslint/utils": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/parser": { + "version": "8.12.2", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/scope-manager": "8.12.2", + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/typescript-estree": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/scope-manager": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/type-utils": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.12.2", + "@typescript-eslint/utils": "8.12.2", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/types": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.12.2", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/utils": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.12.2", + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/typescript-estree": "8.12.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.12.2", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "configs/eslint-config/node_modules/eslint-config-prettier": { + "version": "9.1.0", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "configs/eslint-config/node_modules/eslint-plugin-prettier": { + "version": "5.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "configs/eslint-config/node_modules/fast-diff": { + "version": "1.3.0", + "dev": true, + "license": "Apache-2.0" + }, + "configs/eslint-config/node_modules/fast-glob": { + "version": "3.3.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "configs/eslint-config/node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "configs/eslint-config/node_modules/fastq": { + "version": "1.17.1", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "configs/eslint-config/node_modules/graphemer": { + "version": "1.4.0", + "dev": true, + "license": "MIT" + }, + "configs/eslint-config/node_modules/merge2": { + "version": "1.4.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "configs/eslint-config/node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "configs/eslint-config/node_modules/queue-microtask": { + "version": "1.2.3", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "configs/eslint-config/node_modules/reusify": { + "version": "1.0.4", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "configs/eslint-config/node_modules/run-parallel": { + "version": "1.2.0", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "configs/eslint-config/node_modules/semver": { + "version": "7.6.3", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "configs/eslint-config/node_modules/synckit": { + "version": "0.9.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "configs/eslint-config/node_modules/ts-api-utils": { + "version": "1.4.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, + "configs/eslint-config/node_modules/tslib": { + "version": "2.8.1", + "dev": true, + "license": "0BSD" + }, + "configs/tsconfig": { + "name": "@configs/tsconfig", + "version": "0.0.0" + }, + "node_modules/@configs/esbuild": { + "resolved": "configs/esbuild", + "link": true + }, + "node_modules/@configs/eslint-config": { + "resolved": "configs/eslint-config", + "link": true + }, + "node_modules/@configs/tsconfig": { + "resolved": "configs/tsconfig", + "link": true + }, + "node_modules/@elven.js/mobile-signing-provider": { + "resolved": "packages/mobile-signing-provider", + "link": true + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "dev": true, + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", + "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/js": { + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", + "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", + "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", + "dev": true, + "dependencies": { + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@ethersproject/abstract-provider": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.7.0.tgz", + "integrity": "sha512-R41c9UkchKCpAqStMYUpdunjo3pkEvZC3FAwZn5S5MGbXoMQOHIdHItezTETxAO5bevtMApSyEhn9+CHcDsWBw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/networks": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", + "@ethersproject/web": "^5.7.0" + } + }, + "node_modules/@ethersproject/abstract-signer": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.7.0.tgz", + "integrity": "sha512-a16V8bq1/Cz+TGCkE2OPMTOUDLS3grCpdjoJCYNnVBbdYEMSgKrU0+B90s8b6H+ByYTBZN7a3g76jdIJi7UfKQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/abstract-provider": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0" + } + }, + "node_modules/@ethersproject/address": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.7.0.tgz", + "integrity": "sha512-9wYhYt7aghVGo758POM5nqcOMaE168Q6aRLJZwUmiqSrAungkG74gSSeKEIR7ukixesdRZGPgVqme6vmxs1fkA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/rlp": "^5.7.0" + } + }, + "node_modules/@ethersproject/base64": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.7.0.tgz", + "integrity": "sha512-Dr8tcHt2mEbsZr/mwTPIQAf3Ai0Bks/7gTw9dSqk1mQvhW3XvRlmDJr/4n+wg1JmCl16NZue17CDh8xb/vZ0sQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0" + } + }, + "node_modules/@ethersproject/bignumber": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.7.0.tgz", + "integrity": "sha512-n1CAdIHRWjSucQO3MC1zPSVgV/6dy/fjL9pMrPP9peL+QxEg9wOsVqwD4+818B6LUEtaXzVHQiuivzRoxPxUGw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "bn.js": "^5.2.1" + } + }, + "node_modules/@ethersproject/bytes": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.7.0.tgz", + "integrity": "sha512-nsbxwgFXWh9NyYWo+U8atvmMsSdKJprTcICAkvbBffT75qDocbuggBU0SJiVK2MuTrp0q+xvLkTnGMPK1+uA9A==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/constants": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/constants/-/constants-5.7.0.tgz", + "integrity": "sha512-DHI+y5dBNvkpYUMiRQyxRBYBefZkJfo70VUkUAsRjcPs47muV9evftfZ0PJVCXYbAiCgght0DtcF9srFQmIgWA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bignumber": "^5.7.0" + } + }, + "node_modules/@ethersproject/hash": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.7.0.tgz", + "integrity": "sha512-qX5WrQfnah1EFnO5zJv1v46a8HW0+E5xuBBDTwMFZLuVTx0tbU2kkx15NqdjxecrLGatQN9FGQKpb1FKdHCt+g==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/abstract-signer": "^5.7.0", + "@ethersproject/address": "^5.7.0", + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@ethersproject/keccak256": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/keccak256/-/keccak256-5.7.0.tgz", + "integrity": "sha512-2UcPboeL/iW+pSg6vZ6ydF8tCnv3Iu/8tUmLLzWWGzxWKFFqOBQFLo6uLUv6BDrLgCDfN28RJ/wtByx+jZ4KBg==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "js-sha3": "0.8.0" + } + }, + "node_modules/@ethersproject/logger": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.7.0.tgz", + "integrity": "sha512-0odtFdXu/XHtjQXJYA3u9G0G8btm0ND5Cu8M7i5vhEcE8/HmF4Lbdqanwyv4uQTr2tx6b7fQRmgLrsnpQlmnig==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ] + }, + "node_modules/@ethersproject/networks": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.7.1.tgz", + "integrity": "sha512-n/MufjFYv3yFcUyfhnXotyDlNdFb7onmkSy8aQERi2PjNcnWQ66xXxa3XlS8nCcA8aJKJjIIMNJTC7tu80GwpQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/properties": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.7.0.tgz", + "integrity": "sha512-J87jy8suntrAkIZtecpxEPxY//szqr1mlBaYlQ0r4RCaiD2hjheqF9s1LVE8vVuJCXisjIP+JgtK/Do54ej4Sw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/rlp": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/rlp/-/rlp-5.7.0.tgz", + "integrity": "sha512-rBxzX2vK8mVF7b0Tol44t5Tb8gomOHkj5guL+HhzQ1yBh/ydjGnpw6at+X6Iw0Kp3OzzzkcKp8N9r0W4kYSs9w==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/signing-key": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/signing-key/-/signing-key-5.7.0.tgz", + "integrity": "sha512-MZdy2nL3wO0u7gkB4nA/pEf8lu1TlFswPNmy8AiYkfKTdO6eXBJyUdmHO/ehm/htHw9K/qF8ujnTyUAD+Ry54Q==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "bn.js": "^5.2.1", + "elliptic": "6.5.4", + "hash.js": "1.1.7" + } + }, + "node_modules/@ethersproject/signing-key/node_modules/elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/@ethersproject/signing-key/node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/@ethersproject/strings": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", + "integrity": "sha512-/9nu+lj0YswRNSH0NXYqrh8775XNyEdUQAuf3f+SmOrnVewcJ5SBNAjF7lpgehKi4abvNNXyf+HX86czCdJ8Mg==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/logger": "^5.7.0" + } + }, + "node_modules/@ethersproject/transactions": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/@ethersproject/transactions/-/transactions-5.7.0.tgz", + "integrity": "sha512-kmcNicCp1lp8qanMTC3RIikGgoJ80ztTyvtsFvCYpSCfkjhD0jZ2LOrnbcuxuToLIUYYf+4XwD1rP+B/erDIhQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/address": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/constants": "^5.7.0", + "@ethersproject/keccak256": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/rlp": "^5.7.0", + "@ethersproject/signing-key": "^5.7.0" + } + }, + "node_modules/@ethersproject/web": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.7.1.tgz", + "integrity": "sha512-Gueu8lSvyjBWL4cYsWsjh6MtMwM0+H4HvqFPZfB6dV8ctbP9zFAO73VG1cMWae0FLPCtz0peKPpZY8/ugJJX2w==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/base64": "^5.7.0", + "@ethersproject/bytes": "^5.7.0", + "@ethersproject/logger": "^5.7.0", + "@ethersproject/properties": "^5.7.0", + "@ethersproject/strings": "^5.7.0" + } + }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "dev": true, + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.0.tgz", + "integrity": "sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==", + "dev": true, + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@parcel/watcher": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.4.1.tgz", + "integrity": "sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==", + "dev": true, + "dependencies": { + "detect-libc": "^1.0.3", + "is-glob": "^4.0.3", + "micromatch": "^4.0.5", + "node-addon-api": "^7.0.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.4.1", + "@parcel/watcher-darwin-arm64": "2.4.1", + "@parcel/watcher-darwin-x64": "2.4.1", + "@parcel/watcher-freebsd-x64": "2.4.1", + "@parcel/watcher-linux-arm-glibc": "2.4.1", + "@parcel/watcher-linux-arm64-glibc": "2.4.1", + "@parcel/watcher-linux-arm64-musl": "2.4.1", + "@parcel/watcher-linux-x64-glibc": "2.4.1", + "@parcel/watcher-linux-x64-musl": "2.4.1", + "@parcel/watcher-win32-arm64": "2.4.1", + "@parcel/watcher-win32-ia32": "2.4.1", + "@parcel/watcher-win32-x64": "2.4.1" + } + }, + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.4.1.tgz", + "integrity": "sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.4.1.tgz", + "integrity": "sha512-ln41eihm5YXIY043vBrrHfn94SIBlqOWmoROhsMVTSXGh0QahKGy77tfEywQ7v3NywyxBBkGIfrWRHm0hsKtzA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.4.1.tgz", + "integrity": "sha512-yrw81BRLjjtHyDu7J61oPuSoeYWR3lDElcPGJyOvIXmor6DEo7/G2u1o7I38cwlcoBHQFULqF6nesIX3tsEXMg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.4.1.tgz", + "integrity": "sha512-TJa3Pex/gX3CWIx/Co8k+ykNdDCLx+TuZj3f3h7eOjgpdKM+Mnix37RYsYU4LHhiYJz3DK5nFCCra81p6g050w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.4.1.tgz", + "integrity": "sha512-4rVYDlsMEYfa537BRXxJ5UF4ddNwnr2/1O4MHM5PjI9cvV2qymvhwZSFgXqbS8YoTk5i/JR0L0JDs69BUn45YA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.4.1.tgz", + "integrity": "sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.4.1.tgz", + "integrity": "sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.4.1.tgz", + "integrity": "sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.4.1.tgz", + "integrity": "sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-wasm": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.4.1.tgz", + "integrity": "sha512-/ZR0RxqxU/xxDGzbzosMjh4W6NdYFMqq2nvo2b8SLi7rsl/4jkL8S5stIikorNkdR50oVDvqb/3JT05WM+CRRA==", + "bundleDependencies": [ + "napi-wasm" + ], + "dev": true, + "dependencies": { + "is-glob": "^4.0.3", + "micromatch": "^4.0.5", + "napi-wasm": "^1.1.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-wasm/node_modules/napi-wasm": { + "version": "1.1.0", + "dev": true, + "inBundle": true, + "license": "MIT" + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.4.1.tgz", + "integrity": "sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-ia32": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.4.1.tgz", + "integrity": "sha512-maNRit5QQV2kgHFSYwftmPBxiuK5u4DXjbXx7q6eKjq5dsLXZ4FJiVvlcw35QXzk0KrUecJmuVFbj4uV9oYrcw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.4.1.tgz", + "integrity": "sha512-+DvS92F9ezicfswqrvIRM2njcYJbd5mb9CUgtrHCHmvn7pPPa+nMDRu1o1bYYz/l5IB2NVGNJWiH7h1E58IF2A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@stablelib/aead": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/aead/-/aead-1.0.1.tgz", + "integrity": "sha512-q39ik6sxGHewqtO0nP4BuSe3db5G1fEJE8ukvngS2gLkBXyy6E7pLubhbYgnkDFv6V8cWaxcE4Xn0t6LWcJkyg==", + "dev": true + }, + "node_modules/@stablelib/binary": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/binary/-/binary-1.0.1.tgz", + "integrity": "sha512-ClJWvmL6UBM/wjkvv/7m5VP3GMr9t0osr4yVgLZsLCOz4hGN9gIAFEqnJ0TsSMAN+n840nf2cHZnA5/KFqHC7Q==", + "dev": true, + "dependencies": { + "@stablelib/int": "^1.0.1" + } + }, + "node_modules/@stablelib/bytes": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/bytes/-/bytes-1.0.1.tgz", + "integrity": "sha512-Kre4Y4kdwuqL8BR2E9hV/R5sOrUj6NanZaZis0V6lX5yzqC3hBuVSDXUIBqQv/sCpmuWRiHLwqiT1pqqjuBXoQ==", + "dev": true + }, + "node_modules/@stablelib/chacha": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/chacha/-/chacha-1.0.1.tgz", + "integrity": "sha512-Pmlrswzr0pBzDofdFuVe1q7KdsHKhhU24e8gkEwnTGOmlC7PADzLVxGdn2PoNVBBabdg0l/IfLKg6sHAbTQugg==", + "dev": true, + "dependencies": { + "@stablelib/binary": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/chacha20poly1305": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/chacha20poly1305/-/chacha20poly1305-1.0.1.tgz", + "integrity": "sha512-MmViqnqHd1ymwjOQfghRKw2R/jMIGT3wySN7cthjXCBdO+qErNPUBnRzqNpnvIwg7JBCg3LdeCZZO4de/yEhVA==", + "dev": true, + "dependencies": { + "@stablelib/aead": "^1.0.1", + "@stablelib/binary": "^1.0.1", + "@stablelib/chacha": "^1.0.1", + "@stablelib/constant-time": "^1.0.1", + "@stablelib/poly1305": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/constant-time/-/constant-time-1.0.1.tgz", + "integrity": "sha512-tNOs3uD0vSJcK6z1fvef4Y+buN7DXhzHDPqRLSXUel1UfqMB1PWNsnnAezrKfEwTLpN0cGH2p9NNjs6IqeD0eg==", + "dev": true + }, + "node_modules/@stablelib/ed25519": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@stablelib/ed25519/-/ed25519-1.0.3.tgz", + "integrity": "sha512-puIMWaX9QlRsbhxfDc5i+mNPMY+0TmQEskunY1rZEBPi1acBCVQAhnsk/1Hk50DGPtVsZtAWQg4NHGlVaO9Hqg==", + "dev": true, + "dependencies": { + "@stablelib/random": "^1.0.2", + "@stablelib/sha512": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/hash": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/hash/-/hash-1.0.1.tgz", + "integrity": "sha512-eTPJc/stDkdtOcrNMZ6mcMK1e6yBbqRBaNW55XA1jU8w/7QdnCF0CmMmOD1m7VSkBR44PWrMHU2l6r8YEQHMgg==", + "dev": true + }, + "node_modules/@stablelib/hkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/hkdf/-/hkdf-1.0.1.tgz", + "integrity": "sha512-SBEHYE16ZXlHuaW5RcGk533YlBj4grMeg5TooN80W3NpcHRtLZLLXvKyX0qcRFxf+BGDobJLnwkvgEwHIDBR6g==", + "dev": true, + "dependencies": { + "@stablelib/hash": "^1.0.1", + "@stablelib/hmac": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/hmac": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/hmac/-/hmac-1.0.1.tgz", + "integrity": "sha512-V2APD9NSnhVpV/QMYgCVMIYKiYG6LSqw1S65wxVoirhU/51ACio6D4yDVSwMzuTJXWZoVHbDdINioBwKy5kVmA==", + "dev": true, + "dependencies": { + "@stablelib/constant-time": "^1.0.1", + "@stablelib/hash": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/int": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/int/-/int-1.0.1.tgz", + "integrity": "sha512-byr69X/sDtDiIjIV6m4roLVWnNNlRGzsvxw+agj8CIEazqWGOQp2dTYgQhtyVXV9wpO6WyXRQUzLV/JRNumT2w==", + "dev": true + }, + "node_modules/@stablelib/keyagreement": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/keyagreement/-/keyagreement-1.0.1.tgz", + "integrity": "sha512-VKL6xBwgJnI6l1jKrBAfn265cspaWBPAPEc62VBQrWHLqVgNRE09gQ/AnOEyKUWrrqfD+xSQ3u42gJjLDdMDQg==", + "dev": true, + "dependencies": { + "@stablelib/bytes": "^1.0.1" + } + }, + "node_modules/@stablelib/poly1305": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/poly1305/-/poly1305-1.0.1.tgz", + "integrity": "sha512-1HlG3oTSuQDOhSnLwJRKeTRSAdFNVB/1djy2ZbS35rBSJ/PFqx9cf9qatinWghC2UbfOYD8AcrtbUQl8WoxabA==", + "dev": true, + "dependencies": { + "@stablelib/constant-time": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/random": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@stablelib/random/-/random-1.0.2.tgz", + "integrity": "sha512-rIsE83Xpb7clHPVRlBj8qNe5L8ISQOzjghYQm/dZ7VaM2KHYwMW5adjQjrzTZCchFnNCNhkwtnOBa9HTMJCI8w==", + "dev": true, + "dependencies": { + "@stablelib/binary": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/sha256": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/sha256/-/sha256-1.0.1.tgz", + "integrity": "sha512-GIIH3e6KH+91FqGV42Kcj71Uefd/QEe7Dy42sBTeqppXV95ggCcxLTk39bEr+lZfJmp+ghsR07J++ORkRELsBQ==", + "dev": true, + "dependencies": { + "@stablelib/binary": "^1.0.1", + "@stablelib/hash": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/sha512": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/sha512/-/sha512-1.0.1.tgz", + "integrity": "sha512-13gl/iawHV9zvDKciLo1fQ8Bgn2Pvf7OV6amaRVKiq3pjQ3UmEpXxWiAfV8tYjUpeZroBxtyrwtdooQT/i3hzw==", + "dev": true, + "dependencies": { + "@stablelib/binary": "^1.0.1", + "@stablelib/hash": "^1.0.1", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@stablelib/wipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", + "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==", + "dev": true + }, + "node_modules/@stablelib/x25519": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@stablelib/x25519/-/x25519-1.0.3.tgz", + "integrity": "sha512-KnTbKmUhPhHavzobclVJQG5kuivH+qDLpe84iRqX3CLrKp881cF160JvXJ+hjn1aMyCwYOKeIZefIH/P5cJoRw==", + "dev": true, + "dependencies": { + "@stablelib/keyagreement": "^1.0.1", + "@stablelib/random": "^1.0.2", + "@stablelib/wipe": "^1.0.1" + } + }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, + "node_modules/@types/node": { + "version": "22.8.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.7.tgz", + "integrity": "sha512-LidcG+2UeYIWcMuMUpBKOnryBWG/rnmOHQR5apjn8myTQcx3rinFRn7DcIFhMnS0PPFSC6OafdIKEad0lj6U0Q==", + "dev": true, + "dependencies": { + "undici-types": "~6.19.8" + } + }, + "node_modules/@types/qrcode": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.5.tgz", + "integrity": "sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@walletconnect/core": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.17.1.tgz", + "integrity": "sha512-SMgJR5hEyEE/tENIuvlEb4aB9tmMXPzQ38Y61VgYBmwAFEhOHtpt8EDfnfRWqEhMyXuBXG4K70Yh8c67Yry+Xw==", + "dev": true, + "dependencies": { + "@walletconnect/heartbeat": "1.2.2", + "@walletconnect/jsonrpc-provider": "1.0.14", + "@walletconnect/jsonrpc-types": "1.0.4", + "@walletconnect/jsonrpc-utils": "1.0.8", + "@walletconnect/jsonrpc-ws-connection": "1.0.14", + "@walletconnect/keyvaluestorage": "1.1.1", + "@walletconnect/logger": "2.1.2", + "@walletconnect/relay-api": "1.0.11", + "@walletconnect/relay-auth": "1.0.4", + "@walletconnect/safe-json": "1.0.2", + "@walletconnect/time": "1.0.2", + "@walletconnect/types": "2.17.1", + "@walletconnect/utils": "2.17.1", + "@walletconnect/window-getters": "1.0.1", + "events": "3.3.0", + "lodash.isequal": "4.5.0", + "uint8arrays": "3.1.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@walletconnect/environment": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/environment/-/environment-1.0.1.tgz", + "integrity": "sha512-T426LLZtHj8e8rYnKfzsw1aG6+M0BT1ZxayMdv/p8yM0MU+eJDISqNY3/bccxRr4LrF9csq02Rhqt08Ibl0VRg==", + "dev": true, + "dependencies": { + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/events": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/events/-/events-1.0.1.tgz", + "integrity": "sha512-NPTqaoi0oPBVNuLv7qPaJazmGHs5JGyO8eEAk5VGKmJzDR7AHzD4k6ilox5kxk1iwiOnFopBOOMLs86Oa76HpQ==", + "dev": true, + "dependencies": { + "keyvaluestorage-interface": "^1.0.0", + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/heartbeat": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@walletconnect/heartbeat/-/heartbeat-1.2.2.tgz", + "integrity": "sha512-uASiRmC5MwhuRuf05vq4AT48Pq8RMi876zV8rr8cV969uTOzWdB/k+Lj5yI2PBtB1bGQisGen7MM1GcZlQTBXw==", + "dev": true, + "dependencies": { + "@walletconnect/events": "^1.0.1", + "@walletconnect/time": "^1.0.2", + "events": "^3.3.0" + } + }, + "node_modules/@walletconnect/jsonrpc-provider": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-provider/-/jsonrpc-provider-1.0.14.tgz", + "integrity": "sha512-rtsNY1XqHvWj0EtITNeuf8PHMvlCLiS3EjQL+WOkxEOA4KPxsohFnBDeyPYiNm4ZvkQdLnece36opYidmtbmow==", + "dev": true, + "dependencies": { + "@walletconnect/jsonrpc-utils": "^1.0.8", + "@walletconnect/safe-json": "^1.0.2", + "events": "^3.3.0" + } + }, + "node_modules/@walletconnect/jsonrpc-types": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-types/-/jsonrpc-types-1.0.4.tgz", + "integrity": "sha512-P6679fG/M+wuWg9TY8mh6xFSdYnFyFjwFelxyISxMDrlbXokorEVXYOxiqEbrU3x1BmBoCAJJ+vtEaEoMlpCBQ==", + "dev": true, + "dependencies": { + "events": "^3.3.0", + "keyvaluestorage-interface": "^1.0.0" + } + }, + "node_modules/@walletconnect/jsonrpc-utils": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-utils/-/jsonrpc-utils-1.0.8.tgz", + "integrity": "sha512-vdeb03bD8VzJUL6ZtzRYsFMq1eZQcM3EAzT0a3st59dyLfJ0wq+tKMpmGH7HlB7waD858UWgfIcudbPFsbzVdw==", + "dev": true, + "dependencies": { + "@walletconnect/environment": "^1.0.1", + "@walletconnect/jsonrpc-types": "^1.0.3", + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/jsonrpc-ws-connection": { + "version": "1.0.14", + "resolved": "https://registry.npmjs.org/@walletconnect/jsonrpc-ws-connection/-/jsonrpc-ws-connection-1.0.14.tgz", + "integrity": "sha512-Jsl6fC55AYcbkNVkwNM6Jo+ufsuCQRqViOQ8ZBPH9pRREHH9welbBiszuTLqEJiQcO/6XfFDl6bzCJIkrEi8XA==", + "dev": true, + "dependencies": { + "@walletconnect/jsonrpc-utils": "^1.0.6", + "@walletconnect/safe-json": "^1.0.2", + "events": "^3.3.0", + "ws": "^7.5.1" + } + }, + "node_modules/@walletconnect/keyvaluestorage": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@walletconnect/keyvaluestorage/-/keyvaluestorage-1.1.1.tgz", + "integrity": "sha512-V7ZQq2+mSxAq7MrRqDxanTzu2RcElfK1PfNYiaVnJgJ7Q7G7hTVwF8voIBx92qsRyGHZihrwNPHuZd1aKkd0rA==", + "dev": true, + "dependencies": { + "@walletconnect/safe-json": "^1.0.1", + "idb-keyval": "^6.2.1", + "unstorage": "^1.9.0" + }, + "peerDependencies": { + "@react-native-async-storage/async-storage": "1.x" + }, + "peerDependenciesMeta": { + "@react-native-async-storage/async-storage": { + "optional": true + } + } + }, + "node_modules/@walletconnect/logger": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@walletconnect/logger/-/logger-2.1.2.tgz", + "integrity": "sha512-aAb28I3S6pYXZHQm5ESB+V6rDqIYfsnHaQyzFbwUUBFY4H0OXx/YtTl8lvhUNhMMfb9UxbwEBS253TlXUYJWSw==", + "dev": true, + "dependencies": { + "@walletconnect/safe-json": "^1.0.2", + "pino": "7.11.0" + } + }, + "node_modules/@walletconnect/relay-api": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@walletconnect/relay-api/-/relay-api-1.0.11.tgz", + "integrity": "sha512-tLPErkze/HmC9aCmdZOhtVmYZq1wKfWTJtygQHoWtgg722Jd4homo54Cs4ak2RUFUZIGO2RsOpIcWipaua5D5Q==", + "dev": true, + "dependencies": { + "@walletconnect/jsonrpc-types": "^1.0.2" + } + }, + "node_modules/@walletconnect/relay-auth": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@walletconnect/relay-auth/-/relay-auth-1.0.4.tgz", + "integrity": "sha512-kKJcS6+WxYq5kshpPaxGHdwf5y98ZwbfuS4EE/NkQzqrDFm5Cj+dP8LofzWvjrrLkZq7Afy7WrQMXdLy8Sx7HQ==", + "dev": true, + "dependencies": { + "@stablelib/ed25519": "^1.0.2", + "@stablelib/random": "^1.0.1", + "@walletconnect/safe-json": "^1.0.1", + "@walletconnect/time": "^1.0.2", + "tslib": "1.14.1", + "uint8arrays": "^3.0.0" + } + }, + "node_modules/@walletconnect/safe-json": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@walletconnect/safe-json/-/safe-json-1.0.2.tgz", + "integrity": "sha512-Ogb7I27kZ3LPC3ibn8ldyUr5544t3/STow9+lzz7Sfo808YD7SBWk7SAsdBFlYgP2zDRy2hS3sKRcuSRM0OTmA==", + "dev": true, + "dependencies": { + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/sign-client": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.17.1.tgz", + "integrity": "sha512-6rLw6YNy0smslH9wrFTbNiYrGsL3DrOsS5FcuU4gIN6oh8pGYOFZ5FiSyTTroc5tngOk3/Sd7dlGY9S7O4nveg==", + "dev": true, + "dependencies": { + "@walletconnect/core": "2.17.1", + "@walletconnect/events": "1.0.1", + "@walletconnect/heartbeat": "1.2.2", + "@walletconnect/jsonrpc-utils": "1.0.8", + "@walletconnect/logger": "2.1.2", + "@walletconnect/time": "1.0.2", + "@walletconnect/types": "2.17.1", + "@walletconnect/utils": "2.17.1", + "events": "3.3.0" + } + }, + "node_modules/@walletconnect/time": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@walletconnect/time/-/time-1.0.2.tgz", + "integrity": "sha512-uzdd9woDcJ1AaBZRhqy5rNC9laqWGErfc4dxA9a87mPdKOgWMD85mcFo9dIYIts/Jwocfwn07EC6EzclKubk/g==", + "dev": true, + "dependencies": { + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/types": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.17.1.tgz", + "integrity": "sha512-aiUeBE3EZZTsZBv5Cju3D0PWAsZCMks1g3hzQs9oNtrbuLL6pKKU0/zpKwk4vGywszxPvC3U0tBCku9LLsH/0A==", + "dev": true, + "dependencies": { + "@walletconnect/events": "1.0.1", + "@walletconnect/heartbeat": "1.2.2", + "@walletconnect/jsonrpc-types": "1.0.4", + "@walletconnect/keyvaluestorage": "1.1.1", + "@walletconnect/logger": "2.1.2", + "events": "3.3.0" + } + }, + "node_modules/@walletconnect/utils": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.17.1.tgz", + "integrity": "sha512-KL7pPwq7qUC+zcTmvxGqIyYanfHgBQ+PFd0TEblg88jM7EjuDLhjyyjtkhyE/2q7QgR7OanIK7pCpilhWvBsBQ==", + "dev": true, + "dependencies": { + "@ethersproject/hash": "5.7.0", + "@ethersproject/transactions": "5.7.0", + "@stablelib/chacha20poly1305": "1.0.1", + "@stablelib/hkdf": "1.0.1", + "@stablelib/random": "1.0.2", + "@stablelib/sha256": "1.0.1", + "@stablelib/x25519": "1.0.3", + "@walletconnect/jsonrpc-utils": "1.0.8", + "@walletconnect/keyvaluestorage": "1.1.1", + "@walletconnect/relay-api": "1.0.11", + "@walletconnect/relay-auth": "1.0.4", + "@walletconnect/safe-json": "1.0.2", + "@walletconnect/time": "1.0.2", + "@walletconnect/types": "2.17.1", + "@walletconnect/window-getters": "1.0.1", + "@walletconnect/window-metadata": "1.0.1", + "detect-browser": "5.3.0", + "elliptic": "6.5.7", + "query-string": "7.1.3", + "uint8arrays": "3.1.0" + } + }, + "node_modules/@walletconnect/window-getters": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/window-getters/-/window-getters-1.0.1.tgz", + "integrity": "sha512-vHp+HqzGxORPAN8gY03qnbTMnhqIwjeRJNOMOAzePRg4xVEEE2WvYsI9G2NMjOknA8hnuYbU3/hwLcKbjhc8+Q==", + "dev": true, + "dependencies": { + "tslib": "1.14.1" + } + }, + "node_modules/@walletconnect/window-metadata": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@walletconnect/window-metadata/-/window-metadata-1.0.1.tgz", + "integrity": "sha512-9koTqyGrM2cqFRW517BPY/iEtUDx2r1+Pwwu5m7sJ7ka79wi3EyqhqcICk/yDmv6jAS1rjKgTKXlEhanYjijcA==", + "dev": true, + "dependencies": { + "@walletconnect/window-getters": "^1.0.1", + "tslib": "1.14.1" + } + }, + "node_modules/acorn": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/bn.js": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "dev": true + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/citty": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/citty/-/citty-0.1.6.tgz", + "integrity": "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==", + "dev": true, + "dependencies": { + "consola": "^3.2.3" + } + }, + "node_modules/clipboardy": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-4.0.0.tgz", + "integrity": "sha512-5mOlNS0mhX0707P2I0aZ2V/cmHUEO/fL7VFLqszkhUsxt7RwnmrInf/eEQKlf5GzvYeHIjT+Ov1HRfNmymlG0w==", + "dev": true, + "dependencies": { + "execa": "^8.0.1", + "is-wsl": "^3.1.0", + "is64bit": "^2.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "node_modules/cliui/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/cliui/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui/node_modules/wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/confbox": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", + "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==", + "dev": true + }, + "node_modules/consola": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/consola/-/consola-3.2.3.tgz", + "integrity": "sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ==", + "dev": true, + "engines": { + "node": "^14.18.0 || >=16.10.0" + } + }, + "node_modules/cookie-es": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-es/-/cookie-es-1.2.2.tgz", + "integrity": "sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crossws": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/crossws/-/crossws-0.3.1.tgz", + "integrity": "sha512-HsZgeVYaG+b5zA+9PbIPGq4+J/CJynJuearykPsXx4V/eMhyQ5EDVg3Ak2FBZtVXCiOLu/U7IiwDHTr9MA+IKw==", + "dev": true, + "dependencies": { + "uncrypto": "^0.1.3" + } + }, + "node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/decode-uri-component": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", + "integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==", + "dev": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "node_modules/defu": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", + "integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==", + "dev": true + }, + "node_modules/destr": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.3.tgz", + "integrity": "sha512-2N3BOUU4gYMpTP24s5rF5iP7BDr7uNTCs4ozw3kf/eKfvWSIu93GEBi5m427YoyJoeOzQ5smuu4nNAPGb8idSQ==", + "dev": true + }, + "node_modules/detect-browser": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/detect-browser/-/detect-browser-5.3.0.tgz", + "integrity": "sha512-53rsFbGdwMwlF7qvCt0ypLM5V5/Mbl0szB7GPN8y9NCcbknYOeVVXdrXEq+90IwAfrrzt6Hd+u2E2ntakICU8w==", + "dev": true + }, + "node_modules/detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", + "dev": true, + "bin": { + "detect-libc": "bin/detect-libc.js" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/dijkstrajs": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", + "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", + "dev": true + }, + "node_modules/duplexify": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz", + "integrity": "sha512-M3BmBhwJRZsSx38lZyhE53Csddgzl5R7xGJNk7CVddZD6CcmwMCH8J+7AprIrQKH7TonKxaCjcv27Qmf+sQ+oA==", + "dev": true, + "dependencies": { + "end-of-stream": "^1.4.1", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1", + "stream-shift": "^1.0.2" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, + "node_modules/elliptic": { + "version": "6.5.7", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", + "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", + "dev": true, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/elven.js": { + "resolved": "packages/elven.js", + "link": true + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", + "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.18.0", + "@eslint/core": "^0.7.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.14.0", + "@eslint/plugin-kit": "^0.2.0", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.0", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", + "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", + "dev": true, + "dependencies": { + "acorn": "^8.14.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/execa": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-8.0.1.tgz", + "integrity": "sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^8.0.1", + "human-signals": "^5.0.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^4.1.0", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": ">=16.17" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true + }, + "node_modules/fast-redact": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/fast-redact/-/fast-redact-3.5.0.tgz", + "integrity": "sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/filter-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-1.1.0.tgz", + "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true + }, + "node_modules/foreground-child": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-port-please": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/get-port-please/-/get-port-please-3.1.2.tgz", + "integrity": "sha512-Gxc29eLs1fbn6LQ4jSU4vXjlwyZhF5HsGuMAa7gqBP4Rw4yxxltyDUuF5MBclFzDTXO+ACchGQoeela4DSfzdQ==", + "dev": true + }, + "node_modules/get-stream": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", + "integrity": "sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==", + "dev": true, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/h3": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/h3/-/h3-1.13.0.tgz", + "integrity": "sha512-vFEAu/yf8UMUcB4s43OaDaigcqpQd14yanmOsn+NcRX3/guSKncyE2rOYhq8RIchgJrPSs/QiIddnTTR1ddiAg==", + "dev": true, + "dependencies": { + "cookie-es": "^1.2.2", + "crossws": ">=0.2.0 <0.4.0", + "defu": "^6.1.4", + "destr": "^2.0.3", + "iron-webcrypto": "^1.2.1", + "ohash": "^1.1.4", + "radix3": "^1.1.2", + "ufo": "^1.5.4", + "uncrypto": "^0.1.3", + "unenv": "^1.10.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "dev": true, + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/http-shutdown": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/http-shutdown/-/http-shutdown-1.2.2.tgz", + "integrity": "sha512-S9wWkJ/VSY9/k4qcjG318bqJNruzE4HySUhFYknwmu6LBP97KLLfwNf+n4V1BHurvFNkSKLFnK/RsuUnRTf9Vw==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/human-signals": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", + "integrity": "sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==", + "dev": true, + "engines": { + "node": ">=16.17.0" + } + }, + "node_modules/idb-keyval": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/idb-keyval/-/idb-keyval-6.2.1.tgz", + "integrity": "sha512-8Sb3veuYCyrZL+VBt9LJfZjLUPWVvqn8tG28VqYNFCo43KHcKuq+b4EiXGeuaLAQWL2YmyDgMp2aSpH9JHsEQg==", + "dev": true + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/iron-webcrypto": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/iron-webcrypto/-/iron-webcrypto-1.2.1.tgz", + "integrity": "sha512-feOM6FaSr6rEABp/eDfVseKyTMDt+KGpeB35SkVn9Tyn0CqvVsY3EwI0v5i8nMHyJnzCIQf7nsy3p41TPkJZhg==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/brc-dd" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dev": true, + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-wsl": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", + "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", + "dev": true, + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is64bit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is64bit/-/is64bit-2.0.0.tgz", + "integrity": "sha512-jv+8jaWCl0g2lSBkNSVXdzfBA0npK1HGC2KtWM9FumFRoGS94g3NbCCLVnCYHLjp4GrW2KZeeSTMo5ddtznmGw==", + "dev": true, + "dependencies": { + "system-architecture": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/jackspeak": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/jiti": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.4.0.tgz", + "integrity": "sha512-H5UpaUI+aHOqZXlYOaFP/8AzKsg+guWu+Pr3Y8i7+Y3zr1aXAvCvTAQ1RxSc6oVD8R8c7brgNtTVP91E7upH/g==", + "dev": true, + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/keyvaluestorage-interface": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/keyvaluestorage-interface/-/keyvaluestorage-interface-1.0.0.tgz", + "integrity": "sha512-8t6Q3TclQ4uZynJY9IGr2+SsIGwK9JHcO6ootkHCGA0CrQCRy+VkouYNO2xicET6b9al7QKzpebNow+gkpCL8g==", + "dev": true + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/listhen": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/listhen/-/listhen-1.9.0.tgz", + "integrity": "sha512-I8oW2+QL5KJo8zXNWX046M134WchxsXC7SawLPvRQpogCbkyQIaFxPE89A2HiwR7vAK2Dm2ERBAmyjTYGYEpBg==", + "dev": true, + "dependencies": { + "@parcel/watcher": "^2.4.1", + "@parcel/watcher-wasm": "^2.4.1", + "citty": "^0.1.6", + "clipboardy": "^4.0.0", + "consola": "^3.2.3", + "crossws": ">=0.2.0 <0.4.0", + "defu": "^6.1.4", + "get-port-please": "^3.1.2", + "h3": "^1.12.0", + "http-shutdown": "^1.2.2", + "jiti": "^2.1.2", + "mlly": "^1.7.1", + "node-forge": "^1.3.1", + "pathe": "^1.1.2", + "std-env": "^3.7.0", + "ufo": "^1.5.4", + "untun": "^0.1.3", + "uqr": "^0.1.2" + }, + "bin": { + "listen": "bin/listhen.mjs", + "listhen": "bin/listhen.mjs" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", + "dev": true + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "node_modules/lru-cache": { + "version": "11.0.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.2.tgz", + "integrity": "sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==", + "dev": true, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "dev": true, + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mime": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-3.0.0.tgz", + "integrity": "sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==", + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/mlly": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.2.tgz", + "integrity": "sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==", + "dev": true, + "dependencies": { + "acorn": "^8.12.1", + "pathe": "^1.1.2", + "pkg-types": "^1.2.0", + "ufo": "^1.5.4" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/multiformats": { + "version": "9.9.0", + "resolved": "https://registry.npmjs.org/multiformats/-/multiformats-9.9.0.tgz", + "integrity": "sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "dev": true + }, + "node_modules/node-fetch-native": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.4.tgz", + "integrity": "sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==", + "dev": true + }, + "node_modules/node-forge": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", + "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", + "dev": true, + "engines": { + "node": ">= 6.13.0" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.3.0.tgz", + "integrity": "sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/npm-run-path/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ofetch": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.4.1.tgz", + "integrity": "sha512-QZj2DfGplQAr2oj9KzceK9Hwz6Whxazmn85yYeVuS3u9XTMOGMRx0kO95MQ+vLsj/S/NwBDMMLU5hpxvI6Tklw==", + "dev": true, + "dependencies": { + "destr": "^2.0.3", + "node-fetch-native": "^1.6.4", + "ufo": "^1.5.4" + } + }, + "node_modules/ohash": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-1.1.4.tgz", + "integrity": "sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==", + "dev": true + }, + "node_modules/on-exit-leak-free": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", + "integrity": "sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg==", + "dev": true + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dev": true, + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/pathe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", + "integrity": "sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pino": { + "version": "7.11.0", + "resolved": "https://registry.npmjs.org/pino/-/pino-7.11.0.tgz", + "integrity": "sha512-dMACeu63HtRLmCG8VKdy4cShCPKaYDR4youZqoSWLxl5Gu99HUw8bw75thbPv9Nip+H+QYX8o3ZJbTdVZZ2TVg==", + "dev": true, + "dependencies": { + "atomic-sleep": "^1.0.0", + "fast-redact": "^3.0.0", + "on-exit-leak-free": "^0.2.0", + "pino-abstract-transport": "v0.5.0", + "pino-std-serializers": "^4.0.0", + "process-warning": "^1.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.1.0", + "safe-stable-stringify": "^2.1.0", + "sonic-boom": "^2.2.1", + "thread-stream": "^0.15.1" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz", + "integrity": "sha512-+KAgmVeqXYbTtU2FScx1XS3kNyfZ5TrXY07V96QnUSFqo2gAqlvmaxH67Lj7SWazqsMabf+58ctdTcBgnOLUOQ==", + "dev": true, + "dependencies": { + "duplexify": "^4.1.2", + "split2": "^4.0.0" + } + }, + "node_modules/pino-std-serializers": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-4.0.0.tgz", + "integrity": "sha512-cK0pekc1Kjy5w9V2/n+8MkZwusa6EyyxfeQCB799CQRhRt/CqYKiWs5adeu8Shve2ZNffvfC/7J64A2PJo1W/Q==", + "dev": true + }, + "node_modules/pkg-types": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.2.1.tgz", + "integrity": "sha512-sQoqa8alT3nHjGuTjuKgOnvjo4cljkufdtLMnO2LBP/wRwuDlo1tkaEdMxCRhyGRPacv/ztlZgDPm2b7FAmEvw==", + "dev": true, + "dependencies": { + "confbox": "^0.1.8", + "mlly": "^1.7.2", + "pathe": "^1.1.2" + } + }, + "node_modules/pngjs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", + "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", + "dev": true, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/process-warning": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", + "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==", + "dev": true + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/qrcode": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", + "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==", + "dev": true, + "dependencies": { + "dijkstrajs": "^1.0.1", + "pngjs": "^5.0.0", + "yargs": "^15.3.1" + }, + "bin": { + "qrcode": "bin/qrcode" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/query-string": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.3.tgz", + "integrity": "sha512-hh2WYhq4fi8+b+/2Kg9CEge4fDPvHS534aOOvOZeQ3+Vf2mCFsaFBYj0i+iXcAq6I9Vzp5fjMFBlONvayDC1qg==", + "dev": true, + "dependencies": { + "decode-uri-component": "^0.2.2", + "filter-obj": "^1.1.0", + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", + "dev": true + }, + "node_modules/radix3": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/radix3/-/radix3-1.1.2.tgz", + "integrity": "sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==", + "dev": true + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/real-require": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.1.0.tgz", + "integrity": "sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg==", + "dev": true, + "engines": { + "node": ">= 12.13.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", + "dev": true + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/rimraf": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", + "integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==", + "dev": true, + "dependencies": { + "glob": "^11.0.0", + "package-json-from-dist": "^1.0.0" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", + "dev": true + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/sonic-boom": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-2.8.0.tgz", + "integrity": "sha512-kuonw1YOYYNOve5iHdSahXPOK49GqwA+LZhI6Wz/l0rP57iKyXXIHaRagOBHAPmGwJC6od2Z9zgvZ5loSgMlVg==", + "dev": true, + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, + "node_modules/split-on-first": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", + "integrity": "sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "dev": true, + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/std-env": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", + "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", + "dev": true + }, + "node_modules/stream-shift": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", + "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==", + "dev": true + }, + "node_modules/strict-uri-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/system-architecture": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz", + "integrity": "sha512-ulAk51I9UVUyJgxlv9M6lFot2WP3e7t8Kz9+IS6D4rVba1tR9kON+Ey69f+1R4Q8cd45Lod6a4IcJIxnzGc/zA==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true + }, + "node_modules/thread-stream": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", + "integrity": "sha512-UkEhKIg2pD+fjkHQKyJO3yoIvAP3N6RlNFt2dUhcS1FGvCD1cQa1M/PGknCLFIyZdtJOWQjejp7bdNqmN7zwdA==", + "dev": true, + "dependencies": { + "real-require": "^0.1.0" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "node_modules/turbo": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/turbo/-/turbo-2.2.3.tgz", + "integrity": "sha512-5lDvSqIxCYJ/BAd6rQGK/AzFRhBkbu4JHVMLmGh/hCb7U3CqSnr5Tjwfy9vc+/5wG2DJ6wttgAaA7MoCgvBKZQ==", + "dev": true, + "bin": { + "turbo": "bin/turbo" + }, + "optionalDependencies": { + "turbo-darwin-64": "2.2.3", + "turbo-darwin-arm64": "2.2.3", + "turbo-linux-64": "2.2.3", + "turbo-linux-arm64": "2.2.3", + "turbo-windows-64": "2.2.3", + "turbo-windows-arm64": "2.2.3" + } + }, + "node_modules/turbo-darwin-64": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-2.2.3.tgz", + "integrity": "sha512-Rcm10CuMKQGcdIBS3R/9PMeuYnv6beYIHqfZFeKWVYEWH69sauj4INs83zKMTUiZJ3/hWGZ4jet9AOwhsssLyg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/turbo-darwin-arm64": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-2.2.3.tgz", + "integrity": "sha512-+EIMHkuLFqUdJYsA3roj66t9+9IciCajgj+DVek+QezEdOJKcRxlvDOS2BUaeN8kEzVSsNiAGnoysFWYw4K0HA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/turbo-linux-64": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-2.2.3.tgz", + "integrity": "sha512-UBhJCYnqtaeOBQLmLo8BAisWbc9v9daL9G8upLR+XGj6vuN/Nz6qUAhverN4Pyej1g4Nt1BhROnj6GLOPYyqxQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/turbo-linux-arm64": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-2.2.3.tgz", + "integrity": "sha512-hJYT9dN06XCQ3jBka/EWvvAETnHRs3xuO/rb5bESmDfG+d9yQjeTMlhRXKrr4eyIMt6cLDt1LBfyi+6CQ+VAwQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/turbo-windows-64": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-2.2.3.tgz", + "integrity": "sha512-NPrjacrZypMBF31b4HE4ROg4P3nhMBPHKS5WTpMwf7wydZ8uvdEHpESVNMOtqhlp857zbnKYgP+yJF30H3N2dQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/turbo-windows-arm64": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-2.2.3.tgz", + "integrity": "sha512-fnNrYBCqn6zgKPKLHu4sOkihBI/+0oYFr075duRxqUZ+1aLWTAGfHZLgjVeLh3zR37CVzuerGIPWAEkNhkWEIw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/ufo": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.5.4.tgz", + "integrity": "sha512-UsUk3byDzKd04EyoZ7U4DOlxQaD14JUKQl6/P7wiX4FNvUfm3XL246n9W5AmqwW5RSFJ27NAuM0iLscAOYUiGQ==", + "dev": true + }, + "node_modules/uint8arrays": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uint8arrays/-/uint8arrays-3.1.0.tgz", + "integrity": "sha512-ei5rfKtoRO8OyOIor2Rz5fhzjThwIHJZ3uyDPnDHTXbP0aMQ1RN/6AI5B5d9dBxJOU+BvOAk7ZQ1xphsX8Lrog==", + "dev": true, + "dependencies": { + "multiformats": "^9.4.2" + } + }, + "node_modules/uncrypto": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/uncrypto/-/uncrypto-0.1.3.tgz", + "integrity": "sha512-Ql87qFHB3s/De2ClA9e0gsnS6zXG27SkTiSJwjCc9MebbfapQfuPzumMIUMi38ezPZVNFcHI9sUIepeQfw8J8Q==", + "dev": true + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true + }, + "node_modules/unenv": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/unenv/-/unenv-1.10.0.tgz", + "integrity": "sha512-wY5bskBQFL9n3Eca5XnhH6KbUo/tfvkwm9OpcdCvLaeA7piBNbavbOKJySEwQ1V0RH6HvNlSAFRTpvTqgKRQXQ==", + "dev": true, + "dependencies": { + "consola": "^3.2.3", + "defu": "^6.1.4", + "mime": "^3.0.0", + "node-fetch-native": "^1.6.4", + "pathe": "^1.1.2" + } + }, + "node_modules/unstorage": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/unstorage/-/unstorage-1.13.1.tgz", + "integrity": "sha512-ELexQHUrG05QVIM/iUeQNdl9FXDZhqLJ4yP59fnmn2jGUh0TEulwOgov1ubOb3Gt2ZGK/VMchJwPDNVEGWQpRg==", + "dev": true, + "dependencies": { + "anymatch": "^3.1.3", + "chokidar": "^3.6.0", + "citty": "^0.1.6", + "destr": "^2.0.3", + "h3": "^1.13.0", + "listhen": "^1.9.0", + "lru-cache": "^10.4.3", + "node-fetch-native": "^1.6.4", + "ofetch": "^1.4.1", + "ufo": "^1.5.4" + }, + "peerDependencies": { + "@azure/app-configuration": "^1.7.0", + "@azure/cosmos": "^4.1.1", + "@azure/data-tables": "^13.2.2", + "@azure/identity": "^4.5.0", + "@azure/keyvault-secrets": "^4.9.0", + "@azure/storage-blob": "^12.25.0", + "@capacitor/preferences": "^6.0.2", + "@netlify/blobs": "^6.5.0 || ^7.0.0 || ^8.1.0", + "@planetscale/database": "^1.19.0", + "@upstash/redis": "^1.34.3", + "@vercel/kv": "^1.0.1", + "idb-keyval": "^6.2.1", + "ioredis": "^5.4.1" + }, + "peerDependenciesMeta": { + "@azure/app-configuration": { + "optional": true + }, + "@azure/cosmos": { + "optional": true + }, + "@azure/data-tables": { + "optional": true + }, + "@azure/identity": { + "optional": true + }, + "@azure/keyvault-secrets": { + "optional": true + }, + "@azure/storage-blob": { + "optional": true + }, + "@capacitor/preferences": { + "optional": true + }, + "@netlify/blobs": { + "optional": true + }, + "@planetscale/database": { + "optional": true + }, + "@upstash/redis": { + "optional": true + }, + "@vercel/kv": { + "optional": true + }, + "idb-keyval": { + "optional": true + }, + "ioredis": { + "optional": true + } + } + }, + "node_modules/unstorage/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true + }, + "node_modules/untun": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/untun/-/untun-0.1.3.tgz", + "integrity": "sha512-4luGP9LMYszMRZwsvyUd9MrxgEGZdZuZgpVQHEEX0lCYFESasVRvZd0EYpCkOIbJKHMuv0LskpXc/8Un+MJzEQ==", + "dev": true, + "dependencies": { + "citty": "^0.1.5", + "consola": "^3.2.3", + "pathe": "^1.1.1" + }, + "bin": { + "untun": "bin/untun.mjs" + } + }, + "node_modules/uqr": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/uqr/-/uqr-0.1.2.tgz", + "integrity": "sha512-MJu7ypHq6QasgF5YRTjqscSzQp/W11zoUk6kvmlH+fmWEs63Y0Eib13hYFwAzagRJcVY8WVnlV+eBDUGMJ5IbA==", + "dev": true + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", + "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", + "dev": true + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/ws": { + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "dev": true, + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/y18n": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", + "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", + "dev": true + }, + "node_modules/yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "dependencies": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/yargs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/yargs/node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/yargs/node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yargs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "packages/elven.js": { + "version": "1.0.0", + "devDependencies": { + "@types/qrcode": "1.5.5", + "@walletconnect/sign-client": "2.17.1", + "@walletconnect/types": "2.17.1", + "@walletconnect/utils": "2.17.1", + "qrcode": "1.5.4" + } + }, + "packages/mobile-signing-provider": { + "name": "@elven.js/mobile-signing-provider", + "version": "1.0.0" + } + } +} diff --git a/package.json b/package.json index 4c5358a..e35ed93 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,8 @@ { + "name": "elven.js-monorepo", "private": true, + "type": "module", + "packageManager": "npm@10.2.4", "workspaces": [ "packages/*", "configs/*" @@ -13,9 +16,14 @@ "clean": "turbo run clean && rm -rf node_modules" }, "devDependencies": { - "turbo": "2.2.3", + "@configs/esbuild": "workspace:*", "@configs/eslint-config": "workspace:*", "@configs/tsconfig": "workspace:*", - "@configs/esbuild": "workspace:*" + "@types/node": "22.8.7", + "eslint": "9.14.0", + "prettier": "3.3.3", + "rimraf": "6.0.1", + "turbo": "2.2.3", + "typescript": "5.6.3" } -} \ No newline at end of file +} diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json index b2203b1..494188f 100644 --- a/packages/elven.js/package.json +++ b/packages/elven.js/package.json @@ -15,10 +15,17 @@ "./package.json": "./package.json" }, "scripts": { - "build": "rimraf build && node ./esbuild.config.cjs && tsc", - "lint": "eslint src/** --fix", + "build": "rimraf build && node ./esbuild.config.js && tsc", + "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", "prettier": "prettier --write 'src/**/*.{js,ts,json}'", "check-types": "tsc --noEmit", "clean": "rimraf build node_modules" + }, + "devDependencies": { + "@types/qrcode": "1.5.5", + "@walletconnect/sign-client": "2.17.1", + "@walletconnect/types": "2.17.1", + "@walletconnect/utils": "2.17.1", + "qrcode": "1.5.4" } -} \ No newline at end of file +} diff --git a/packages/elven.js/tsconfig.json b/packages/elven.js/tsconfig.json new file mode 100644 index 0000000..6633db5 --- /dev/null +++ b/packages/elven.js/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"], + "exclude": ["node_modules", "build"] +} diff --git a/packages/@elven.js/mobile-signing-provider/esbuild.config.js b/packages/mobile-signing-provider/esbuild.config.js similarity index 100% rename from packages/@elven.js/mobile-signing-provider/esbuild.config.js rename to packages/mobile-signing-provider/esbuild.config.js diff --git a/packages/@elven.js/mobile-signing-provider/package.json b/packages/mobile-signing-provider/package.json similarity index 85% rename from packages/@elven.js/mobile-signing-provider/package.json rename to packages/mobile-signing-provider/package.json index d88c9d3..756c542 100644 --- a/packages/@elven.js/mobile-signing-provider/package.json +++ b/packages/mobile-signing-provider/package.json @@ -15,8 +15,8 @@ "./package.json": "./package.json" }, "scripts": { - "build": "rimraf build && node ./esbuild.config.cjs && tsc", - "lint": "eslint src/** --fix", + "build": "rimraf build && node ./esbuild.config.js && tsc", + "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", "prettier": "prettier --write 'src/**/*.{js,ts,json}'", "check-types": "tsc --noEmit", "clean": "rimraf build node_modules" diff --git a/packages/@elven.js/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/mobile-signing-provider/src/mobile-signing-provider.ts similarity index 100% rename from packages/@elven.js/mobile-signing-provider/src/mobile-signing-provider.ts rename to packages/mobile-signing-provider/src/mobile-signing-provider.ts diff --git a/packages/mobile-signing-provider/tsconfig.json b/packages/mobile-signing-provider/tsconfig.json new file mode 100644 index 0000000..6633db5 --- /dev/null +++ b/packages/mobile-signing-provider/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src/**/*"], + "exclude": ["node_modules", "build"] +} diff --git a/tsconfig.json b/tsconfig.json index 1d1630f..f3c8410 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,8 +5,10 @@ "baseUrl": ".", "paths": { "elven.js(/*)": ["packages/elven.js/src$1"], - "@elven.js/mobile-signing-provider(/*)": ["packages/@elven.js/mobile-signing-provider/src$1"] - } + "mobile-signing-provider(/*)": ["packages/mobile-signing-provider/src$1"] + }, + "types": ["node"] }, + "include": ["packages/*/src/**/*"], "exclude": ["node_modules"] } From 0b0632138e0b52d5c466b4698de52a8e7b278005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 12:21:01 +0100 Subject: [PATCH 03/13] with working build --- configs/esbuild/index.js | 9 +- package-lock.json | 482 ++++++++++++++++-- packages/elven.js/esbuild.config.js | 3 +- packages/elven.js/package.json | 3 +- .../mobile-signing-provider/esbuild.config.js | 3 +- packages/mobile-signing-provider/package.json | 3 + .../src/mobile-signing-provider.ts | 1 + turbo.json | 1 + 8 files changed, 444 insertions(+), 61 deletions(-) diff --git a/configs/esbuild/index.js b/configs/esbuild/index.js index a998f18..d50b3b5 100644 --- a/configs/esbuild/index.js +++ b/configs/esbuild/index.js @@ -7,14 +7,19 @@ const banner = `/*! */ `; -export default { +export const baseConfig = { format: 'esm', bundle: true, metafile: true, minify: true, outdir: 'build', platform: 'browser', + target: ['es2020'], banner: { js: banner }, treeShaking: true, - // drop: ['console', 'debugger'], + pure: ['console.log', 'console.info', 'console.debug', 'console.warn'], + sourcemap: false, + define: { + 'process.env.NODE_ENV': '"production"', + }, }; diff --git a/package-lock.json b/package-lock.json index dde9b77..c353a96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,59 +27,6 @@ "esbuild": "0.24.0" } }, - "configs/esbuild/node_modules/@esbuild/linux-x64": { - "version": "0.24.0", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "configs/esbuild/node_modules/esbuild": { - "version": "0.24.0", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.24.0", - "@esbuild/android-arm": "0.24.0", - "@esbuild/android-arm64": "0.24.0", - "@esbuild/android-x64": "0.24.0", - "@esbuild/darwin-arm64": "0.24.0", - "@esbuild/darwin-x64": "0.24.0", - "@esbuild/freebsd-arm64": "0.24.0", - "@esbuild/freebsd-x64": "0.24.0", - "@esbuild/linux-arm": "0.24.0", - "@esbuild/linux-arm64": "0.24.0", - "@esbuild/linux-ia32": "0.24.0", - "@esbuild/linux-loong64": "0.24.0", - "@esbuild/linux-mips64el": "0.24.0", - "@esbuild/linux-ppc64": "0.24.0", - "@esbuild/linux-riscv64": "0.24.0", - "@esbuild/linux-s390x": "0.24.0", - "@esbuild/linux-x64": "0.24.0", - "@esbuild/netbsd-x64": "0.24.0", - "@esbuild/openbsd-arm64": "0.24.0", - "@esbuild/openbsd-x64": "0.24.0", - "@esbuild/sunos-x64": "0.24.0", - "@esbuild/win32-arm64": "0.24.0", - "@esbuild/win32-ia32": "0.24.0", - "@esbuild/win32-x64": "0.24.0" - } - }, "configs/eslint-config": { "name": "@configs/eslint-config", "version": "0.0.0", @@ -557,6 +504,390 @@ "resolved": "packages/mobile-signing-provider", "link": true }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz", + "integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.0.tgz", + "integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz", + "integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.0.tgz", + "integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz", + "integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz", + "integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz", + "integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz", + "integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz", + "integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz", + "integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz", + "integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz", + "integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz", + "integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz", + "integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz", + "integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz", + "integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz", + "integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz", + "integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz", + "integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz", + "integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz", + "integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz", + "integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz", + "integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz", + "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", @@ -2389,6 +2720,45 @@ "once": "^1.4.0" } }, + "node_modules/esbuild": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz", + "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.24.0", + "@esbuild/android-arm": "0.24.0", + "@esbuild/android-arm64": "0.24.0", + "@esbuild/android-x64": "0.24.0", + "@esbuild/darwin-arm64": "0.24.0", + "@esbuild/darwin-x64": "0.24.0", + "@esbuild/freebsd-arm64": "0.24.0", + "@esbuild/freebsd-x64": "0.24.0", + "@esbuild/linux-arm": "0.24.0", + "@esbuild/linux-arm64": "0.24.0", + "@esbuild/linux-ia32": "0.24.0", + "@esbuild/linux-loong64": "0.24.0", + "@esbuild/linux-mips64el": "0.24.0", + "@esbuild/linux-ppc64": "0.24.0", + "@esbuild/linux-riscv64": "0.24.0", + "@esbuild/linux-s390x": "0.24.0", + "@esbuild/linux-x64": "0.24.0", + "@esbuild/netbsd-x64": "0.24.0", + "@esbuild/openbsd-arm64": "0.24.0", + "@esbuild/openbsd-x64": "0.24.0", + "@esbuild/sunos-x64": "0.24.0", + "@esbuild/win32-arm64": "0.24.0", + "@esbuild/win32-ia32": "0.24.0", + "@esbuild/win32-x64": "0.24.0" + } + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -4644,12 +5014,16 @@ "@walletconnect/sign-client": "2.17.1", "@walletconnect/types": "2.17.1", "@walletconnect/utils": "2.17.1", + "esbuild": "0.24.0", "qrcode": "1.5.4" } }, "packages/mobile-signing-provider": { "name": "@elven.js/mobile-signing-provider", - "version": "1.0.0" + "version": "1.0.0", + "devDependencies": { + "esbuild": "0.24.0" + } } } } diff --git a/packages/elven.js/esbuild.config.js b/packages/elven.js/esbuild.config.js index ab8c928..87cf477 100644 --- a/packages/elven.js/esbuild.config.js +++ b/packages/elven.js/esbuild.config.js @@ -1,12 +1,11 @@ import { baseConfig } from '@configs/esbuild'; -import esbuild from 'esbuild'; +import * as esbuild from 'esbuild'; import fs from 'fs'; esbuild .build({ ...baseConfig, entryPoints: ['./src/elven.ts'], - outfile: './build/elven.js', }) .then((result) => { fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json index 494188f..8f3db20 100644 --- a/packages/elven.js/package.json +++ b/packages/elven.js/package.json @@ -26,6 +26,7 @@ "@walletconnect/sign-client": "2.17.1", "@walletconnect/types": "2.17.1", "@walletconnect/utils": "2.17.1", + "esbuild": "0.24.0", "qrcode": "1.5.4" } -} +} \ No newline at end of file diff --git a/packages/mobile-signing-provider/esbuild.config.js b/packages/mobile-signing-provider/esbuild.config.js index 7893a57..3eaa9c8 100644 --- a/packages/mobile-signing-provider/esbuild.config.js +++ b/packages/mobile-signing-provider/esbuild.config.js @@ -1,12 +1,11 @@ import { baseConfig } from '@configs/esbuild'; -import esbuild from 'esbuild'; +import * as esbuild from 'esbuild'; import fs from 'fs'; esbuild .build({ ...baseConfig, entryPoints: ['./src/mobile-signing-provider.ts'], - outfile: './build/mobile-signing-provider.js', }) .then((result) => { fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); diff --git a/packages/mobile-signing-provider/package.json b/packages/mobile-signing-provider/package.json index 756c542..1a547fd 100644 --- a/packages/mobile-signing-provider/package.json +++ b/packages/mobile-signing-provider/package.json @@ -20,5 +20,8 @@ "prettier": "prettier --write 'src/**/*.{js,ts,json}'", "check-types": "tsc --noEmit", "clean": "rimraf build node_modules" + }, + "devDependencies": { + "esbuild": "0.24.0" } } \ No newline at end of file diff --git a/packages/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/mobile-signing-provider/src/mobile-signing-provider.ts index 68eebf6..e71da89 100644 --- a/packages/mobile-signing-provider/src/mobile-signing-provider.ts +++ b/packages/mobile-signing-provider/src/mobile-signing-provider.ts @@ -2,4 +2,5 @@ const nothingHereForNow = () => { console.log('nothing here for now'); }; +// SOME comment here lorem ipsum dolor sit amet export default nothingHereForNow; diff --git a/turbo.json b/turbo.json index 2e3e89f..af987d6 100644 --- a/turbo.json +++ b/turbo.json @@ -5,6 +5,7 @@ ], "tasks": { "build": { + "cache": false, "dependsOn": [ "^build" ], From 0265777fe0f5718a4612c2b55ecc66dadf0cae8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 12:35:46 +0100 Subject: [PATCH 04/13] with working dev server --- LICENSE | 2 +- demo-app/elven.js | 28 +++---- demo-app/mobile-signing-provider.js | 9 +++ dev-server.mjs => dev-server.js | 2 +- package-lock.json | 76 +++++++++++++++++++ package.json | 3 +- packages/elven.js/package.json | 2 +- packages/mobile-signing-provider/package.json | 2 +- .../src/mobile-signing-provider.ts | 4 +- turbo.json | 4 - 10 files changed, 109 insertions(+), 23 deletions(-) create mode 100644 demo-app/mobile-signing-provider.js rename dev-server.mjs => dev-server.js (94%) diff --git a/LICENSE b/LICENSE index 873032b..ceeffa1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Julian Ćwirko +Copyright (c) 2024 Julian Ćwirko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/demo-app/elven.js b/demo-app/elven.js index 2f58e4c..02e0045 100644 --- a/demo-app/elven.js +++ b/demo-app/elven.js @@ -6,14 +6,14 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var K3=Object.create;var Ya=Object.defineProperty;var V3=Object.getOwnPropertyDescriptor;var $3=Object.getOwnPropertyNames;var H3=Object.getPrototypeOf,G3=Object.prototype.hasOwnProperty;var fp=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var W3=(r,e)=>()=>(r&&(e=r(r=0)),e);var J=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),qt=(r,e)=>{for(var t in e)Ya(r,t,{get:e[t],enumerable:!0})},Ja=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $3(e))!G3.call(r,n)&&n!==t&&Ya(r,n,{get:()=>e[n],enumerable:!(i=V3(e,n))||i.enumerable});return r},Ht=(r,e,t)=>(Ja(r,e,"default"),t&&Ja(t,e,"default")),Be=(r,e,t)=>(t=r!=null?K3(H3(r)):{},Ja(e||!r||!r.__esModule?Ya(t,"default",{value:r,enumerable:!0}):t,r)),Ao=r=>Ja(Ya({},"__esModule",{value:!0}),r);var Fn=J((vP,Hu)=>{"use strict";var ms=typeof Reflect=="object"?Reflect:null,Pp=ms&&typeof ms.apply=="function"?ms.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},fc;ms&&typeof ms.ownKeys=="function"?fc=ms.ownKeys:Object.getOwnPropertySymbols?fc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:fc=function(e){return Object.getOwnPropertyNames(e)};function t6(r){console&&console.warn&&console.warn(r)}var Np=Number.isNaN||function(e){return e!==e};function $e(){$e.init.call(this)}Hu.exports=$e;Hu.exports.once=s6;$e.EventEmitter=$e;$e.prototype._events=void 0;$e.prototype._eventsCount=0;$e.prototype._maxListeners=void 0;var Rp=10;function uc(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty($e,"defaultMaxListeners",{enumerable:!0,get:function(){return Rp},set:function(r){if(typeof r!="number"||r<0||Np(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Rp=r}});$e.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};$e.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Np(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Dp(r){return r._maxListeners===void 0?$e.defaultMaxListeners:r._maxListeners}$e.prototype.getMaxListeners=function(){return Dp(this)};$e.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")Pp(f,this,t);else for(var u=f.length,g=Up(f,u),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=o.length,t6(a)}return r}$e.prototype.addListener=function(e,t){return Cp(this,e,t,!1)};$e.prototype.on=$e.prototype.addListener;$e.prototype.prependListener=function(e,t){return Cp(this,e,t,!0)};function r6(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Op(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=r6.bind(i);return n.listener=t,i.wrapFn=n,n}$e.prototype.once=function(e,t){return uc(t),this.on(e,Op(this,e,t)),this};$e.prototype.prependOnceListener=function(e,t){return uc(t),this.prependListener(e,Op(this,e,t)),this};$e.prototype.removeListener=function(e,t){var i,n,s,o,a;if(uc(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():i6(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};$e.prototype.off=$e.prototype.removeListener;$e.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function Lp(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?n6(n):Up(n,n.length)}$e.prototype.listeners=function(e){return Lp(this,e,!0)};$e.prototype.rawListeners=function(e){return Lp(this,e,!1)};$e.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Fp.call(r,e)};$e.prototype.listenerCount=Fp;function Fp(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}$e.prototype.eventNames=function(){return this._eventsCount>0?fc(this._events):[]};function Up(r,e){for(var t=new Array(e),i=0;iWu,__asyncDelegator:()=>y6,__asyncGenerator:()=>v6,__asyncValues:()=>w6,__await:()=>Oo,__awaiter:()=>d6,__classPrivateFieldGet:()=>S6,__classPrivateFieldSet:()=>I6,__createBinding:()=>p6,__decorate:()=>f6,__exportStar:()=>g6,__extends:()=>a6,__generator:()=>l6,__importDefault:()=>E6,__importStar:()=>_6,__makeTemplateObject:()=>x6,__metadata:()=>h6,__param:()=>u6,__read:()=>Bp,__rest:()=>c6,__spread:()=>m6,__spreadArrays:()=>b6,__values:()=>Ju});function a6(r,e){Gu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function c6(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;a--)(o=r[a])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function u6(r,e){return function(t,i){e(t,i,r)}}function h6(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function d6(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(g){try{u(i.next(g))}catch(y){o(y)}}function f(g){try{u(i.throw(g))}catch(y){o(y)}}function u(g){g.done?s(g.value):n(g.value).then(a,f)}u((i=i.apply(r,e||[])).next())})}function l6(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(g){return f([u,g])}}function f(u){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Bp(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function m6(){for(var r=[],e=0;e1||a(S,I)})})}function a(S,I){try{f(i[S](I))}catch(A){y(s[0][3],A)}}function f(S){S.value instanceof Oo?Promise.resolve(S.value.v).then(u,g):y(s[0][2],S)}function u(S){a("next",S)}function g(S){a("throw",S)}function y(S,I){S(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function y6(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Oo(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function w6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Ju=="function"?Ju(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(a,f){o=r[s](o),n(a,f,o.done,o.value)})}}function n(s,o,a,f){Promise.resolve(f).then(function(u){s({value:u,done:a})},o)}}function x6(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function _6(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function E6(r){return r&&r.__esModule?r:{default:r}}function S6(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function I6(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var Gu,Wu,vs=W3(()=>{Gu=function(r,e){return Gu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},Gu(r,e)};Wu=function(){return Wu=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.delay=void 0;function A6(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}hc.delay=A6});var zp=J(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.ONE_THOUSAND=ys.ONE_HUNDRED=void 0;ys.ONE_HUNDRED=100;ys.ONE_THOUSAND=1e3});var jp=J(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.ONE_YEAR=Z.FOUR_WEEKS=Z.THREE_WEEKS=Z.TWO_WEEKS=Z.ONE_WEEK=Z.THIRTY_DAYS=Z.SEVEN_DAYS=Z.FIVE_DAYS=Z.THREE_DAYS=Z.ONE_DAY=Z.TWENTY_FOUR_HOURS=Z.TWELVE_HOURS=Z.SIX_HOURS=Z.THREE_HOURS=Z.ONE_HOUR=Z.SIXTY_MINUTES=Z.THIRTY_MINUTES=Z.TEN_MINUTES=Z.FIVE_MINUTES=Z.ONE_MINUTE=Z.SIXTY_SECONDS=Z.THIRTY_SECONDS=Z.TEN_SECONDS=Z.FIVE_SECONDS=Z.ONE_SECOND=void 0;Z.ONE_SECOND=1;Z.FIVE_SECONDS=5;Z.TEN_SECONDS=10;Z.THIRTY_SECONDS=30;Z.SIXTY_SECONDS=60;Z.ONE_MINUTE=Z.SIXTY_SECONDS;Z.FIVE_MINUTES=Z.ONE_MINUTE*5;Z.TEN_MINUTES=Z.ONE_MINUTE*10;Z.THIRTY_MINUTES=Z.ONE_MINUTE*30;Z.SIXTY_MINUTES=Z.ONE_MINUTE*60;Z.ONE_HOUR=Z.SIXTY_MINUTES;Z.THREE_HOURS=Z.ONE_HOUR*3;Z.SIX_HOURS=Z.ONE_HOUR*6;Z.TWELVE_HOURS=Z.ONE_HOUR*12;Z.TWENTY_FOUR_HOURS=Z.ONE_HOUR*24;Z.ONE_DAY=Z.TWENTY_FOUR_HOURS;Z.THREE_DAYS=Z.ONE_DAY*3;Z.FIVE_DAYS=Z.ONE_DAY*5;Z.SEVEN_DAYS=Z.ONE_DAY*7;Z.THIRTY_DAYS=Z.ONE_DAY*30;Z.ONE_WEEK=Z.SEVEN_DAYS;Z.TWO_WEEKS=Z.ONE_WEEK*2;Z.THREE_WEEKS=Z.ONE_WEEK*3;Z.FOUR_WEEKS=Z.ONE_WEEK*4;Z.ONE_YEAR=Z.ONE_DAY*365});var Yu=J(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var Kp=(vs(),Ao(bs));Kp.__exportStar(zp(),dc);Kp.__exportStar(jp(),dc)});var $p=J(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.fromMiliseconds=ws.toMiliseconds=void 0;var Vp=Yu();function M6(r){return r*Vp.ONE_THOUSAND}ws.toMiliseconds=M6;function T6(r){return Math.floor(r/Vp.ONE_THOUSAND)}ws.fromMiliseconds=T6});var Gp=J(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var Hp=(vs(),Ao(bs));Hp.__exportStar(kp(),lc);Hp.__exportStar($p(),lc)});var Wp=J(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.Watch=void 0;var pc=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};Lo.Watch=pc;Lo.default=pc});var Jp=J(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.IWatch=void 0;var Xu=class{};gc.IWatch=Xu});var Yp=J(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var P6=(vs(),Ao(bs));P6.__exportStar(Jp(),Qu)});var _s=J(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});var mc=(vs(),Ao(bs));mc.__exportStar(Gp(),xs);mc.__exportStar(Wp(),xs);mc.__exportStar(Yp(),xs);mc.__exportStar(Yu(),xs)});var dg=J(($P,hg)=>{"use strict";function X6(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}hg.exports=Q6;function Q6(r,e,t){var i=t&&t.stringify||X6,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var a=1;a-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(g>=f||e[g]==null)break;y=f||e[g]==null)break;y=f||e[g]===void 0)break;y",y=I+2,I++;break}u+=i(e[g]),y=I+2,I++;break;case 115:if(g>=f)break;y{"use strict";var lg=dg();mg.exports=Zr;var ko=c5().console||{},Z6={mapHttpRequest:xc,mapHttpResponse:xc,wrapRequestSerializer:ah,wrapResponseSerializer:ah,wrapErrorSerializer:ah,req:xc,res:xc,err:n5};function e5(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Zr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||ko;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=e5(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let a=r.level||"info",f=Object.create(t);f.log||(f.log=zo),Object.defineProperty(f,"levelVal",{get:g}),Object.defineProperty(f,"level",{get:y,set:S});let u={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:s5(r)};f.levels=Zr.levels,f.level=a,f.setMaxListeners=f.getMaxListeners=f.emit=f.addListener=f.on=f.prependListener=f.once=f.prependOnceListener=f.removeListener=f.removeAllListeners=f.listeners=f.listenerCount=f.eventNames=f.write=f.flush=zo,f.serializers=i,f._serialize=n,f._stdErrSerialize=s,f.child=I,e&&(f._logEvent=ch());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(A){if(A!=="silent"&&!this.levels.values[A])throw Error("unknown level "+A);this._level=A,Es(u,f,"error","log"),Es(u,f,"fatal","error"),Es(u,f,"warn","error"),Es(u,f,"info","log"),Es(u,f,"debug","log"),Es(u,f,"trace","log")}function I(A,P){if(!A)throw new Error("missing bindings for child Pino");P=P||{},n&&A.serializers&&(P.serializers=A.serializers);let O=P.serializers;if(n&&O){var N=Object.assign({},i,O),U=r.browser.serialize===!0?Object.keys(N):n;delete A.serializers,_c([A],U,N,this._stdErrSerialize)}function k(B){this._childLevel=(B._childLevel|0)+1,this.error=Ss(B,A,"error"),this.fatal=Ss(B,A,"fatal"),this.warn=Ss(B,A,"warn"),this.info=Ss(B,A,"info"),this.debug=Ss(B,A,"debug"),this.trace=Ss(B,A,"trace"),N&&(this.serializers=N,this._serialize=U),e&&(this._logEvent=ch([].concat(B._logEvent.bindings,A)))}return k.prototype=this,new k(this)}return f}Zr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Zr.stdSerializers=Z6;Zr.stdTimeFunctions=Object.assign({},{nullTime:pg,epochTime:gg,unixTime:o5,isoTime:a5});function Es(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?zo:n[t]?n[t]:ko[t]||ko[i]||zo,t5(r,e,t)}function t5(r,e,t){!r.transmit&&e[t]===zo||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===ko?ko:this;for(var f=0;f-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function Ss(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.BrowserRandomSource=void 0;var xg=65536,ph=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(gh,"__esModule",{value:!0});function w5(r){for(var e=0;e{});var Eg=J(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.NodeRandomSource=void 0;var x5=cr(),bh=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof fp<"u"){let e=mh();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.SystemRandomSource=void 0;var _5=_g(),E5=Eg(),vh=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new _5.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new E5.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};jc.SystemRandomSource=vh});var Ig=J(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});function S5(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Wt.mul=Math.imul||S5;function I5(r,e){return r+e|0}Wt.add=I5;function A5(r,e){return r-e|0}Wt.sub=A5;function M5(r,e){return r<>>32-e}Wt.rotl=M5;function T5(r,e){return r<<32-e|r>>>e}Wt.rotr=T5;function P5(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Wt.isInteger=Number.isInteger||P5;Wt.MAX_SAFE_INTEGER=9007199254740991;Wt.isSafeInteger=function(r){return Wt.isInteger(r)&&r>=-Wt.MAX_SAFE_INTEGER&&r<=Wt.MAX_SAFE_INTEGER}});var Is=J(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});var Ag=Ig();function R5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Ue.readInt16BE=R5;function N5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Ue.readUint16BE=N5;function D5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Ue.readInt16LE=D5;function C5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Ue.readUint16LE=C5;function Mg(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Ue.writeUint16BE=Mg;Ue.writeInt16BE=Mg;function Tg(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Ue.writeUint16LE=Tg;Ue.writeInt16LE=Tg;function yh(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Ue.readInt32BE=yh;function wh(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Ue.readUint32BE=wh;function xh(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Ue.readInt32LE=xh;function _h(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Ue.readUint32LE=_h;function Kc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Ue.writeUint32BE=Kc;Ue.writeInt32BE=Kc;function Vc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Ue.writeUint32LE=Vc;Ue.writeInt32LE=Vc;function O5(r,e){e===void 0&&(e=0);var t=yh(r,e),i=yh(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Ue.readInt64BE=O5;function L5(r,e){e===void 0&&(e=0);var t=wh(r,e),i=wh(r,e+4);return t*4294967296+i}Ue.readUint64BE=L5;function F5(r,e){e===void 0&&(e=0);var t=xh(r,e),i=xh(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Ue.readInt64LE=F5;function U5(r,e){e===void 0&&(e=0);var t=_h(r,e),i=_h(r,e+4);return i*4294967296+t}Ue.readUint64LE=U5;function Pg(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Kc(r/4294967296>>>0,e,t),Kc(r>>>0,e,t+4),e}Ue.writeUint64BE=Pg;Ue.writeInt64BE=Pg;function Rg(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Vc(r>>>0,e,t),Vc(r/4294967296>>>0,e,t+4),e}Ue.writeUint64LE=Rg;Ue.writeInt64LE=Rg;function q5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Ue.readUintBE=q5;function B5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Ue.writeUintBE=k5;function z5(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Ag.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.randomStringForEntropy=Tt.randomString=Tt.randomUint32=Tt.randomBytes=Tt.defaultRandomSource=void 0;var Y5=Sg(),X5=Is(),Ng=cr();Tt.defaultRandomSource=new Y5.SystemRandomSource;function Eh(r,e=Tt.defaultRandomSource){return e.randomBytes(r)}Tt.randomBytes=Eh;function Q5(r=Tt.defaultRandomSource){let e=Eh(4,r),t=(0,X5.readUint32LE)(e);return(0,Ng.wipe)(e),t}Tt.randomUint32=Q5;var Dg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Cg(r,e=Dg,t=Tt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Eh(Math.ceil(r*256/s),t);for(let a=0;a0;a++){let f=o[a];f{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});var Ms=Is(),As=cr();Si.DIGEST_LENGTH=64;Si.BLOCK_SIZE=128;var Lg=function(){function r(){this.digestLength=Si.DIGEST_LENGTH,this.blockSize=Si.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){As.wipe(this._buffer),As.wipe(this._tempHi),As.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(Sh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=Sh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){As.wipe(e.stateHi),As.wipe(e.stateLo),e.buffer&&As.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Si.SHA512=Lg;var Og=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Sh(r,e,t,i,n,s,o){for(var a=t[0],f=t[1],u=t[2],g=t[3],y=t[4],S=t[5],I=t[6],A=t[7],P=i[0],O=i[1],N=i[2],U=i[3],k=i[4],B=i[5],j=i[6],V=i[7],L,C,W,R,l,w,p,c;o>=128;){for(var d=0;d<16;d++){var b=8*d+s;r[d]=Ms.readUint32BE(n,b),e[d]=Ms.readUint32BE(n,b+4)}for(var d=0;d<80;d++){var x=a,v=f,h=u,_=g,M=y,m=S,T=I,z=A,E=P,D=O,F=N,q=U,K=k,Y=B,H=j,$=V;if(L=A,C=V,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=(y>>>14|k<<18)^(y>>>18|k<<14)^(k>>>9|y<<23),C=(k>>>14|y<<18)^(k>>>18|y<<14)^(y>>>9|k<<23),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=y&S^~y&I,C=k&B^~k&j,l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=Og[d*2],C=Og[d*2+1],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=r[d%16],C=e[d%16],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,W=p&65535|c<<16,R=l&65535|w<<16,L=W,C=R,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=(a>>>28|P<<4)^(P>>>2|a<<30)^(P>>>7|a<<25),C=(P>>>28|a<<4)^(a>>>2|P<<30)^(a>>>7|P<<25),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=a&f^a&u^f&u,C=P&O^P&N^O&N,l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,z=p&65535|c<<16,$=l&65535|w<<16,L=_,C=q,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=W,C=R,l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,_=p&65535|c<<16,q=l&65535|w<<16,f=x,u=v,g=h,y=_,S=M,I=m,A=T,a=z,O=E,N=D,U=F,k=q,B=K,j=Y,V=H,P=$,d%16===15)for(var b=0;b<16;b++)L=r[b],C=e[b],l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=r[(b+9)%16],C=e[(b+9)%16],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,W=r[(b+1)%16],R=e[(b+1)%16],L=(W>>>1|R<<31)^(W>>>8|R<<24)^W>>>7,C=(R>>>1|W<<31)^(R>>>8|W<<24)^(R>>>7|W<<25),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,W=r[(b+14)%16],R=e[(b+14)%16],L=(W>>>19|R<<13)^(R>>>29|W<<3)^W>>>6,C=(R>>>19|W<<13)^(W>>>29|R<<3)^(R>>>6|W<<26),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,r[b]=p&65535|c<<16,e[b]=l&65535|w<<16}L=a,C=P,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[0],C=i[0],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[0]=a=p&65535|c<<16,i[0]=P=l&65535|w<<16,L=f,C=O,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[1],C=i[1],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[1]=f=p&65535|c<<16,i[1]=O=l&65535|w<<16,L=u,C=N,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[2],C=i[2],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[2]=u=p&65535|c<<16,i[2]=N=l&65535|w<<16,L=g,C=U,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[3],C=i[3],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[3]=g=p&65535|c<<16,i[3]=U=l&65535|w<<16,L=y,C=k,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[4],C=i[4],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[4]=y=p&65535|c<<16,i[4]=k=l&65535|w<<16,L=S,C=B,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[5],C=i[5],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[5]=S=p&65535|c<<16,i[5]=B=l&65535|w<<16,L=I,C=j,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[6],C=i[6],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[6]=I=p&65535|c<<16,i[6]=j=l&65535|w<<16,L=A,C=V,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[7],C=i[7],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[7]=A=p&65535|c<<16,i[7]=V=l&65535|w<<16,s+=128,o-=128}return s}function ex(r){var e=new Lg;e.update(r);var t=e.digest();return e.clean(),t}Si.hash=ex});var Yg=J(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var tx=$o(),Ho=Fg(),zg=cr();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function ie(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,jg(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function Kg(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function Bg(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Go(t,r),Go(i,e),Kg(t,i)}function Vg(r){let e=new Uint8Array(32);return Go(e,r),e[0]&1}function ox(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Bn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function zn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function He(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,P=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,C=0,W=0,R=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],M=t[1],m=t[2],T=t[3],z=t[4],E=t[5],D=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*M,a+=i*m,f+=i*T,u+=i*z,g+=i*E,y+=i*D,S+=i*F,I+=i*q,A+=i*K,P+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*M,f+=i*m,u+=i*T,g+=i*z,y+=i*E,S+=i*D,I+=i*F,A+=i*q,P+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*M,u+=i*m,g+=i*T,y+=i*z,S+=i*E,I+=i*D,A+=i*F,P+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*M,g+=i*m,y+=i*T,S+=i*z,I+=i*E,A+=i*D,P+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*M,y+=i*m,S+=i*T,I+=i*z,A+=i*E,P+=i*D,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,C+=i*X,i=e[5],g+=i*_,y+=i*M,S+=i*m,I+=i*T,A+=i*z,P+=i*E,O+=i*D,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,C+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*M,I+=i*m,A+=i*T,P+=i*z,O+=i*E,N+=i*D,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,C+=i*ee,W+=i*G,R+=i*X,i=e[7],S+=i*_,I+=i*M,A+=i*m,P+=i*T,O+=i*z,N+=i*E,U+=i*D,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,C+=i*$,W+=i*ee,R+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*M,P+=i*m,O+=i*T,N+=i*z,U+=i*E,k+=i*D,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,C+=i*H,W+=i*$,R+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,P+=i*M,O+=i*m,N+=i*T,U+=i*z,k+=i*E,B+=i*D,j+=i*F,V+=i*q,L+=i*K,C+=i*Y,W+=i*H,R+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],P+=i*_,O+=i*M,N+=i*m,U+=i*T,k+=i*z,B+=i*E,j+=i*D,V+=i*F,L+=i*q,C+=i*K,W+=i*Y,R+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*M,U+=i*m,k+=i*T,B+=i*z,j+=i*E,V+=i*D,L+=i*F,C+=i*q,W+=i*K,R+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*M,k+=i*m,B+=i*T,j+=i*z,V+=i*E,L+=i*D,C+=i*F,W+=i*q,R+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*M,B+=i*m,j+=i*T,V+=i*z,L+=i*E,C+=i*D,W+=i*F,R+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*M,j+=i*m,V+=i*T,L+=i*z,C+=i*E,W+=i*D,R+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*M,V+=i*m,L+=i*T,C+=i*z,W+=i*E,R+=i*D,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*C,u+=38*W,g+=38*R,y+=38*l,S+=38*w,I+=38*p,A+=38*c,P+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=P,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function kn(r,e){He(r,e,e)}function $g(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)kn(t,t),i!==2&&i!==4&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function ax(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)kn(t,t),i!==1&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Th(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie(),u=ie(),g=ie();zn(t,r[1],r[0]),zn(g,e[1],e[0]),He(t,t,g),Bn(i,r[0],r[1]),Bn(g,e[0],e[1]),He(i,i,g),He(n,r[3],e[3]),He(n,n,nx),He(s,r[2],e[2]),Bn(s,s,s),zn(o,i,t),zn(a,s,n),Bn(f,s,n),Bn(u,i,t),He(r[0],o,a),He(r[1],u,f),He(r[2],f,a),He(r[3],o,u)}function kg(r,e,t){for(let i=0;i<4;i++)jg(r[i],e[i],t)}function Rh(r,e){let t=ie(),i=ie(),n=ie();$g(n,e[2]),He(t,e[0],n),He(i,e[1],n),Go(r,i),r[31]^=Vg(t)<<7}function Hg(r,e,t){$i(r[0],Mh),$i(r[1],Ts),$i(r[2],Ts),$i(r[3],Mh);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;kg(r,e,n),Th(e,r),Th(r,r),kg(r,e,n)}}function Nh(r,e){let t=[ie(),ie(),ie(),ie()];$i(t[0],Ug),$i(t[1],qg),$i(t[2],Ts),He(t[3],Ug,qg),Hg(r,t,e)}function Gg(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ho.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[ie(),ie(),ie(),ie()];Nh(i,e),Rh(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=Gg;function cx(r){let e=(0,tx.randomBytes)(32,r),t=Gg(e);return(0,zg.wipe)(e),t}ze.generateKeyPair=cx;function fx(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=fx;var Ah=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Wg(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*Ah[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*Ah[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Ph(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;Wg(r,e)}function ux(r,e){let t=new Float64Array(64),i=[ie(),ie(),ie(),ie()],n=(0,Ho.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ho.SHA512;o.update(s.subarray(32)),o.update(e);let a=o.digest();o.clean(),Ph(a),Nh(i,a),Rh(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let f=o.digest();Ph(f);for(let u=0;u<32;u++)t[u]=a[u];for(let u=0;u<32;u++)for(let g=0;g<32;g++)t[u+g]+=f[u]*n[g];return Wg(s.subarray(32),t),s}ze.sign=ux;function Jg(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie();return $i(r[2],Ts),ox(r[1],e),kn(n,r[1]),He(s,n,ix),zn(n,n,r[2]),Bn(s,r[2],s),kn(o,s),kn(a,o),He(f,a,o),He(t,f,n),He(t,t,s),ax(t,t),He(t,t,n),He(t,t,s),He(t,t,s),He(r[0],t,s),kn(i,r[0]),He(i,i,s),Bg(i,n)&&He(r[0],r[0],sx),kn(i,r[0]),He(i,i,s),Bg(i,n)?-1:(Vg(r[0])===e[31]>>7&&zn(r[0],Mh,r[0]),He(r[3],r[0],r[1]),0)}function hx(r,e,t){let i=new Uint8Array(32),n=[ie(),ie(),ie(),ie()],s=[ie(),ie(),ie(),ie()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(Jg(s,r))return!1;let o=new Ho.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let a=o.digest();return Ph(a),Hg(n,s,a),Nh(s,t.subarray(32)),Th(n,s),Rh(i,n),!Kg(t,i)}ze.verify=hx;function dx(r){let e=[ie(),ie(),ie(),ie()];if(Jg(e,r))throw new Error("Ed25519: invalid public key");let t=ie(),i=ie(),n=e[1];Bn(t,Ts,n),zn(i,Ts,n),$g(i,i),He(t,t,i);let s=new Uint8Array(32);return Go(s,t),s}ze.convertPublicKeyToX25519=dx;function lx(r){let e=(0,Ho.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,zg.wipe)(e),t}ze.convertSecretKeyToX25519=lx});var Qc=J(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.getLocalStorage=Je.getLocalStorageOrThrow=Je.getCrypto=Je.getCryptoOrThrow=Je.getLocation=Je.getLocationOrThrow=Je.getNavigator=Je.getNavigatorOrThrow=Je.getDocument=Je.getDocumentOrThrow=Je.getFromWindowOrThrow=Je.getFromWindow=void 0;function Vn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Je.getFromWindow=Vn;function Ls(r){let e=Vn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Je.getFromWindowOrThrow=Ls;function k4(){return Ls("document")}Je.getDocumentOrThrow=k4;function z4(){return Vn("document")}Je.getDocument=z4;function j4(){return Ls("navigator")}Je.getNavigatorOrThrow=j4;function K4(){return Vn("navigator")}Je.getNavigator=K4;function V4(){return Ls("location")}Je.getLocationOrThrow=V4;function $4(){return Vn("location")}Je.getLocation=$4;function H4(){return Ls("crypto")}Je.getCryptoOrThrow=H4;function G4(){return Vn("crypto")}Je.getCrypto=G4;function W4(){return Ls("localStorage")}Je.getLocalStorageOrThrow=W4;function J4(){return Vn("localStorage")}Je.getLocalStorage=J4});var F1=J(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.getWindowMetadata=void 0;var L1=Qc();function Y4(){let r,e;try{r=L1.getDocumentOrThrow(),e=L1.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=A.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let N=e.protocol+"//"+e.host;if(O.indexOf("/")===0)N+=O;else{let U=e.pathname.split("/");U.pop();let k=U.join("/");N+=k+"/"+O}S.push(N)}else if(O.indexOf("//")===0){let N=e.protocol+O;S.push(N)}else S.push(O)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IA.getAttribute(O)).filter(O=>O?y.includes(O):!1);if(P.length&&P){let O=A.getAttribute("content");if(O)return O}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),a=s(),f=e.origin,u=t();return{description:a,url:f,icons:u,name:o}}Zc.getWindowMetadata=Y4});var q1=J((bN,U1)=>{"use strict";U1.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var K1=J((vN,j1)=>{"use strict";var z1="%[a-f0-9]{2}",B1=new RegExp("("+z1+")|([^%]+?)","gi"),k1=new RegExp("("+z1+")+","gi");function id(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],id(t),id(i))}function X4(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(B1)||[],t=1;t{"use strict";V1.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var G1=J((wN,H1)=>{"use strict";H1.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Z4=q1(),e8=K1(),J1=$1(),t8=G1(),r8=r=>r==null,nd=Symbol("encodeFragmentIdentifier");function i8(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[",n,"]"].join("")]:[...t,[ct(e,r),"[",ct(n,r),"]=",ct(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[]"].join("")]:[...t,[ct(e,r),"[]=",ct(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),":list="].join("")]:[...t,[ct(e,r),":list=",ct(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[ct(t,r),e,ct(n,r)].join("")]:[[i,ct(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,ct(e,r)]:[...t,[ct(e,r),"=",ct(i,r)].join("")]}}function n8(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&Ai(i,r).includes(r.arrayFormatSeparator);i=o?Ai(i,r):i;let a=s||o?i.split(r.arrayFormatSeparator).map(f=>Ai(f,r)):i===null?i:Ai(i,r);n[t]=a};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&Ai(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(a=>Ai(a,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Y1(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function ct(r,e){return e.encode?e.strict?Z4(r):encodeURIComponent(r):r}function Ai(r,e){return e.decode?e8(r):r}function X1(r){return Array.isArray(r)?r.sort():typeof r=="object"?X1(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Q1(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function s8(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Z1(r){r=Q1(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function W1(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function em(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Y1(e.arrayFormatSeparator);let t=n8(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=J1(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:Ai(o,e),t(Ai(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=W1(s[o],e);else i[n]=W1(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=X1(o):n[s]=o,n},Object.create(null))}zt.extract=Z1;zt.parse=em;zt.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Y1(e.arrayFormatSeparator);let t=o=>e.skipNull&&r8(r[o])||e.skipEmptyString&&r[o]==="",i=i8(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let a=r[o];return a===void 0?"":a===null?ct(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?ct(o,e)+"[]":a.reduce(i(o),[]).join("&"):ct(o,e)+"="+ct(a,e)}).filter(o=>o.length>0).join("&")};zt.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=J1(r,"#");return Object.assign({url:t.split("?")[0]||"",query:em(Z1(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:Ai(i,e)}:{})};zt.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[nd]:!0},e);let t=Q1(r.url).split("?")[0]||"",i=zt.extract(r.url),n=zt.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=zt.stringify(s,e);o&&(o=`?${o}`);let a=s8(r.url);return r.fragmentIdentifier&&(a=`#${e[nd]?ct(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${a}`};zt.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[nd]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=zt.parseUrl(r,t);return zt.stringifyUrl({url:i,query:t8(n,e),fragmentIdentifier:s},t)};zt.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return zt.pick(r,i,t)}});var rm=J((_N,ef)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=global:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ef=="object"&&ef.exports,a=typeof define=="function"&&define.amd,f=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],A=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],N=[128,256],U=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),f&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var B=function(E,D,F){return function(q){return new m(E,D,E).update(q)[F]()}},j=function(E,D,F){return function(q,K){return new m(E,D,K).update(q)[F]()}},V=function(E,D,F){return function(q,K,Y,H){return c["cshake"+E].update(q,K,Y,H)[F]()}},L=function(E,D,F){return function(q,K,Y,H){return c["kmac"+E].update(q,K,Y,H)[F]()}},C=function(E,D,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}m.prototype.update=function(E){if(this.finalized)throw new Error(e);var D,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);D=!0}for(var q=this.blocks,K=this.byteCount,Y=E.length,H=this.blockCount,$=0,ee=this.s,G,X;$>2]|=E[$]<>2]|=X<>2]|=(192|X>>6)<>2]|=(128|X&63)<=57344?(q[G>>2]|=(224|X>>12)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<>2]|=(240|X>>18)<>2]|=(128|X>>12&63)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<=K){for(this.start=G-K,this.block=q[H],G=0;G>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return D?K.push(q):K.unshift(q),this.update(K),K.length},m.prototype.encodeString=function(E){var D,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);D=!0}var q=0,K=E.length;if(D)q=K;else for(var Y=0;Y=57344?q+=3:(H=65536+((H&1023)<<10|E.charCodeAt(++Y)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},m.prototype.bytepad=function(E,D){for(var F=this.encode(D),q=0;q>2]|=this.padding[D&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],D=1;D>4&15]+u[$&15]+u[$>>12&15]+u[$>>8&15]+u[$>>20&15]+u[$>>16&15]+u[$>>28&15]+u[$>>24&15];Y%E===0&&(z(D),K=0)}return q&&($=D[K],H+=u[$>>4&15]+u[$&15],q>1&&(H+=u[$>>12&15]+u[$>>8&15]),q>2&&(H+=u[$>>20&15]+u[$>>16&15])),H},m.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,D=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,Y=0,H=this.outputBits>>3,$;q?$=new ArrayBuffer(F+1<<2):$=new ArrayBuffer(H);for(var ee=new Uint32Array($);Y>8&255,H[$+2]=ee>>16&255,H[$+3]=ee>>24&255;Y%E===0&&z(D)}return q&&($=Y<<2,ee=D[K],H[$]=ee&255,q>1&&(H[$+1]=ee>>8&255),q>2&&(H[$+2]=ee>>16&255)),H};function T(E,D,F){m.call(this,E,D,F)}T.prototype=new m,T.prototype.finalize=function(){return this.encode(this.outputBits,!0),m.prototype.finalize.call(this)};var z=function(E){var D,F,q,K,Y,H,$,ee,G,X,Ur,se,oe,qr,ae,ce,Br,fe,ue,kr,he,de,zr,le,pe,jr,ge,me,Kr,be,ve,Vr,ye,we,$r,xe,_e,Hr,Ee,Se,Gr,Ie,Ae,Wr,Me,Te,Jr,Pe,Re,Yr,Ne,De,Xr,Ce,Oe,vr,Ke,Ve,tr,rr,ir,nr,sr;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],Y=E[1]^E[11]^E[21]^E[31]^E[41],H=E[2]^E[12]^E[22]^E[32]^E[42],$=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],X=E[6]^E[16]^E[26]^E[36]^E[46],Ur=E[7]^E[17]^E[27]^E[37]^E[47],se=E[8]^E[18]^E[28]^E[38]^E[48],oe=E[9]^E[19]^E[29]^E[39]^E[49],D=se^(H<<1|$>>>31),F=oe^($<<1|H>>>31),E[0]^=D,E[1]^=F,E[10]^=D,E[11]^=F,E[20]^=D,E[21]^=F,E[30]^=D,E[31]^=F,E[40]^=D,E[41]^=F,D=K^(ee<<1|G>>>31),F=Y^(G<<1|ee>>>31),E[2]^=D,E[3]^=F,E[12]^=D,E[13]^=F,E[22]^=D,E[23]^=F,E[32]^=D,E[33]^=F,E[42]^=D,E[43]^=F,D=H^(X<<1|Ur>>>31),F=$^(Ur<<1|X>>>31),E[4]^=D,E[5]^=F,E[14]^=D,E[15]^=F,E[24]^=D,E[25]^=F,E[34]^=D,E[35]^=F,E[44]^=D,E[45]^=F,D=ee^(se<<1|oe>>>31),F=G^(oe<<1|se>>>31),E[6]^=D,E[7]^=F,E[16]^=D,E[17]^=F,E[26]^=D,E[27]^=F,E[36]^=D,E[37]^=F,E[46]^=D,E[47]^=F,D=X^(K<<1|Y>>>31),F=Ur^(Y<<1|K>>>31),E[8]^=D,E[9]^=F,E[18]^=D,E[19]^=F,E[28]^=D,E[29]^=F,E[38]^=D,E[39]^=F,E[48]^=D,E[49]^=F,qr=E[0],ae=E[1],Te=E[11]<<4|E[10]>>>28,Jr=E[10]<<4|E[11]>>>28,me=E[20]<<3|E[21]>>>29,Kr=E[21]<<3|E[20]>>>29,rr=E[31]<<9|E[30]>>>23,ir=E[30]<<9|E[31]>>>23,Ie=E[40]<<18|E[41]>>>14,Ae=E[41]<<18|E[40]>>>14,we=E[2]<<1|E[3]>>>31,$r=E[3]<<1|E[2]>>>31,ce=E[13]<<12|E[12]>>>20,Br=E[12]<<12|E[13]>>>20,Pe=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,be=E[33]<<13|E[32]>>>19,ve=E[32]<<13|E[33]>>>19,nr=E[42]<<2|E[43]>>>30,sr=E[43]<<2|E[42]>>>30,Ce=E[5]<<30|E[4]>>>2,Oe=E[4]<<30|E[5]>>>2,xe=E[14]<<6|E[15]>>>26,_e=E[15]<<6|E[14]>>>26,fe=E[25]<<11|E[24]>>>21,ue=E[24]<<11|E[25]>>>21,Yr=E[34]<<15|E[35]>>>17,Ne=E[35]<<15|E[34]>>>17,Vr=E[45]<<29|E[44]>>>3,ye=E[44]<<29|E[45]>>>3,le=E[6]<<28|E[7]>>>4,pe=E[7]<<28|E[6]>>>4,vr=E[17]<<23|E[16]>>>9,Ke=E[16]<<23|E[17]>>>9,Hr=E[26]<<25|E[27]>>>7,Ee=E[27]<<25|E[26]>>>7,kr=E[36]<<21|E[37]>>>11,he=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Xr=E[46]<<24|E[47]>>>8,Wr=E[8]<<27|E[9]>>>5,Me=E[9]<<27|E[8]>>>5,jr=E[18]<<20|E[19]>>>12,ge=E[19]<<20|E[18]>>>12,Ve=E[29]<<7|E[28]>>>25,tr=E[28]<<7|E[29]>>>25,Se=E[38]<<8|E[39]>>>24,Gr=E[39]<<8|E[38]>>>24,de=E[48]<<14|E[49]>>>18,zr=E[49]<<14|E[48]>>>18,E[0]=qr^~ce&fe,E[1]=ae^~Br&ue,E[10]=le^~jr&me,E[11]=pe^~ge&Kr,E[20]=we^~xe&Hr,E[21]=$r^~_e&Ee,E[30]=Wr^~Te&Pe,E[31]=Me^~Jr&Re,E[40]=Ce^~vr&Ve,E[41]=Oe^~Ke&tr,E[2]=ce^~fe&kr,E[3]=Br^~ue&he,E[12]=jr^~me&be,E[13]=ge^~Kr&ve,E[22]=xe^~Hr&Se,E[23]=_e^~Ee&Gr,E[32]=Te^~Pe&Yr,E[33]=Jr^~Re&Ne,E[42]=vr^~Ve&rr,E[43]=Ke^~tr&ir,E[4]=fe^~kr&de,E[5]=ue^~he&zr,E[14]=me^~be&Vr,E[15]=Kr^~ve&ye,E[24]=Hr^~Se&Ie,E[25]=Ee^~Gr&Ae,E[34]=Pe^~Yr&De,E[35]=Re^~Ne&Xr,E[44]=Ve^~rr&nr,E[45]=tr^~ir&sr,E[6]=kr^~de&qr,E[7]=he^~zr&ae,E[16]=be^~Vr&le,E[17]=ve^~ye&pe,E[26]=Se^~Ie&we,E[27]=Gr^~Ae&$r,E[36]=Yr^~De&Wr,E[37]=Ne^~Xr&Me,E[46]=rr^~nr&Ce,E[47]=ir^~sr&Oe,E[8]=de^~qr&ce,E[9]=zr^~ae&Br,E[18]=Vr^~le&jr,E[19]=ye^~pe&ge,E[28]=Ie^~we&xe,E[29]=Ae^~$r&_e,E[38]=De^~Wr&Te,E[39]=Xr^~Me&Jr,E[48]=nr^~Ce&vr,E[49]=sr^~Oe&Ke,E[0]^=P[q],E[1]^=P[q+1]};if(o)ef.exports=c;else{for(b=0;b{});var dd=J((pm,hd)=>{(function(r,e){"use strict";function t(p,c){if(!p)throw new Error(c||"Assertion failed")}function i(p,c){p.super_=c;var d=function(){};d.prototype=c.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,c,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((c==="le"||c==="be")&&(d=c,c=10),this._init(p||0,c||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=ud().Buffer}catch{}n.isBN=function(c){return c instanceof n?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===n.wordSize&&Array.isArray(c.words)},n.max=function(c,d){return c.cmp(d)>0?c:d},n.min=function(c,d){return c.cmp(d)<0?c:d},n.prototype._init=function(c,d,b){if(typeof c=="number")return this._initNumber(c,d,b);if(typeof c=="object")return this._initArray(c,d,b);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),c=c.toString().replace(/\s+/g,"");var x=0;c[0]==="-"&&(x++,this.negative=1),x=0;x-=3)h=c[x]|c[x-1]<<8|c[x-2]<<16,this.words[v]|=h<<_&67108863,this.words[v+1]=h>>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);else if(b==="le")for(x=0,v=0;x>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);return this._strip()};function o(p,c){var d=p.charCodeAt(c);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function a(p,c,d){var b=o(p,d);return d-1>=c&&(b|=o(p,d-1)<<4),b}n.prototype._parseHex=function(c,d,b){this.length=Math.ceil((c.length-d)/6),this.words=new Array(this.length);for(var x=0;x=d;x-=2)_=a(c,d,x)<=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8;else{var M=c.length-d;for(x=M%2===0?d+1:d;x=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8}this._strip()};function f(p,c,d,b){for(var x=0,v=0,h=Math.min(p.length,d),_=c;_=49?v=M-49+10:M>=17?v=M-17+10:v=M,t(M>=0&&v1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{n.prototype.inspect=g}else n.prototype.inspect=g;function g(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(c,d){c=c||10,d=d|0||1;var b;if(c===16||c==="hex"){b="";for(var x=0,v=0,h=0;h>>24-x&16777215,x+=2,x>=26&&(x-=26,h--),v!==0||h!==this.length-1?b=y[6-M.length]+M+b:b=M+b}for(v!==0&&(b=v.toString(16)+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(c===(c|0)&&c>=2&&c<=36){var m=S[c],T=I[c];b="";var z=this.clone();for(z.negative=0;!z.isZero();){var E=z.modrn(T).toString(c);z=z.idivn(T),z.isZero()?b=E+b:b=y[m-E.length]+E+b}for(this.isZero()&&(b="0"+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(c,d){return this.toArrayLike(s,c,d)}),n.prototype.toArray=function(c,d){return this.toArrayLike(Array,c,d)};var A=function(c,d){return c.allocUnsafe?c.allocUnsafe(d):new c(d)};n.prototype.toArrayLike=function(c,d,b){this._strip();var x=this.byteLength(),v=b||Math.max(1,x);t(x<=v,"byte array longer than desired length"),t(v>0,"Requested array length <= 0");var h=A(c,v),_=d==="le"?"LE":"BE";return this["_toArrayLike"+_](h,x),h},n.prototype._toArrayLikeLE=function(c,d){for(var b=0,x=0,v=0,h=0;v>8&255),b>16&255),h===6?(b>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b=0&&(c[b--]=_>>8&255),b>=0&&(c[b--]=_>>16&255),h===6?(b>=0&&(c[b--]=_>>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b>=0)for(c[b--]=x;b>=0;)c[b--]=0},Math.clz32?n.prototype._countBits=function(c){return 32-Math.clz32(c)}:n.prototype._countBits=function(c){var d=c,b=0;return d>=4096&&(b+=13,d>>>=13),d>=64&&(b+=7,d>>>=7),d>=8&&(b+=4,d>>>=4),d>=2&&(b+=2,d>>>=2),b+d},n.prototype._zeroBits=function(c){if(c===0)return 26;var d=c,b=0;return d&8191||(b+=13,d>>>=13),d&127||(b+=7,d>>>=7),d&15||(b+=4,d>>>=4),d&3||(b+=2,d>>>=2),d&1||b++,b},n.prototype.bitLength=function(){var c=this.words[this.length-1],d=this._countBits(c);return(this.length-1)*26+d};function P(p){for(var c=new Array(p.bitLength()),d=0;d>>x&1}return c}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,d=0;dc.length?this.clone().ior(c):c.clone().ior(this)},n.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},n.prototype.iuand=function(c){var d;this.length>c.length?d=c:d=this;for(var b=0;bc.length?this.clone().iand(c):c.clone().iand(this)},n.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},n.prototype.iuxor=function(c){var d,b;this.length>c.length?(d=this,b=c):(d=c,b=this);for(var x=0;xc.length?this.clone().ixor(c):c.clone().ixor(this)},n.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},n.prototype.inotn=function(c){t(typeof c=="number"&&c>=0);var d=Math.ceil(c/26)|0,b=c%26;this._expand(d),b>0&&d--;for(var x=0;x0&&(this.words[x]=~this.words[x]&67108863>>26-b),this._strip()},n.prototype.notn=function(c){return this.clone().inotn(c)},n.prototype.setn=function(c,d){t(typeof c=="number"&&c>=0);var b=c/26|0,x=c%26;return this._expand(b+1),d?this.words[b]=this.words[b]|1<c.length?(b=this,x=c):(b=c,x=this);for(var v=0,h=0;h>>26;for(;v!==0&&h>>26;if(this.length=b.length,v!==0)this.words[this.length]=v,this.length++;else if(b!==this)for(;hc.length?this.clone().iadd(c):c.clone().iadd(this)},n.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var d=this.iadd(c);return c.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var b=this.cmp(c);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,v;b>0?(x=this,v=c):(x=c,v=this);for(var h=0,_=0;_>26,this.words[_]=d&67108863;for(;h!==0&&_>26,this.words[_]=d&67108863;if(h===0&&_>>26,z=M&67108863,E=Math.min(m,c.length-1),D=Math.max(0,m-p.length+1);D<=E;D++){var F=m-D|0;x=p.words[F]|0,v=c.words[D]|0,h=x*v+z,T+=h/67108864|0,z=h&67108863}d.words[m]=z|0,M=T|0}return M!==0?d.words[m]=M|0:d.length--,d._strip()}var N=function(c,d,b){var x=c.words,v=d.words,h=b.words,_=0,M,m,T,z=x[0]|0,E=z&8191,D=z>>>13,F=x[1]|0,q=F&8191,K=F>>>13,Y=x[2]|0,H=Y&8191,$=Y>>>13,ee=x[3]|0,G=ee&8191,X=ee>>>13,Ur=x[4]|0,se=Ur&8191,oe=Ur>>>13,qr=x[5]|0,ae=qr&8191,ce=qr>>>13,Br=x[6]|0,fe=Br&8191,ue=Br>>>13,kr=x[7]|0,he=kr&8191,de=kr>>>13,zr=x[8]|0,le=zr&8191,pe=zr>>>13,jr=x[9]|0,ge=jr&8191,me=jr>>>13,Kr=v[0]|0,be=Kr&8191,ve=Kr>>>13,Vr=v[1]|0,ye=Vr&8191,we=Vr>>>13,$r=v[2]|0,xe=$r&8191,_e=$r>>>13,Hr=v[3]|0,Ee=Hr&8191,Se=Hr>>>13,Gr=v[4]|0,Ie=Gr&8191,Ae=Gr>>>13,Wr=v[5]|0,Me=Wr&8191,Te=Wr>>>13,Jr=v[6]|0,Pe=Jr&8191,Re=Jr>>>13,Yr=v[7]|0,Ne=Yr&8191,De=Yr>>>13,Xr=v[8]|0,Ce=Xr&8191,Oe=Xr>>>13,vr=v[9]|0,Ke=vr&8191,Ve=vr>>>13;b.negative=c.negative^d.negative,b.length=19,M=Math.imul(E,be),m=Math.imul(E,ve),m=m+Math.imul(D,be)|0,T=Math.imul(D,ve);var tr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(tr>>>26)|0,tr&=67108863,M=Math.imul(q,be),m=Math.imul(q,ve),m=m+Math.imul(K,be)|0,T=Math.imul(K,ve),M=M+Math.imul(E,ye)|0,m=m+Math.imul(E,we)|0,m=m+Math.imul(D,ye)|0,T=T+Math.imul(D,we)|0;var rr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(rr>>>26)|0,rr&=67108863,M=Math.imul(H,be),m=Math.imul(H,ve),m=m+Math.imul($,be)|0,T=Math.imul($,ve),M=M+Math.imul(q,ye)|0,m=m+Math.imul(q,we)|0,m=m+Math.imul(K,ye)|0,T=T+Math.imul(K,we)|0,M=M+Math.imul(E,xe)|0,m=m+Math.imul(E,_e)|0,m=m+Math.imul(D,xe)|0,T=T+Math.imul(D,_e)|0;var ir=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(ir>>>26)|0,ir&=67108863,M=Math.imul(G,be),m=Math.imul(G,ve),m=m+Math.imul(X,be)|0,T=Math.imul(X,ve),M=M+Math.imul(H,ye)|0,m=m+Math.imul(H,we)|0,m=m+Math.imul($,ye)|0,T=T+Math.imul($,we)|0,M=M+Math.imul(q,xe)|0,m=m+Math.imul(q,_e)|0,m=m+Math.imul(K,xe)|0,T=T+Math.imul(K,_e)|0,M=M+Math.imul(E,Ee)|0,m=m+Math.imul(E,Se)|0,m=m+Math.imul(D,Ee)|0,T=T+Math.imul(D,Se)|0;var nr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(nr>>>26)|0,nr&=67108863,M=Math.imul(se,be),m=Math.imul(se,ve),m=m+Math.imul(oe,be)|0,T=Math.imul(oe,ve),M=M+Math.imul(G,ye)|0,m=m+Math.imul(G,we)|0,m=m+Math.imul(X,ye)|0,T=T+Math.imul(X,we)|0,M=M+Math.imul(H,xe)|0,m=m+Math.imul(H,_e)|0,m=m+Math.imul($,xe)|0,T=T+Math.imul($,_e)|0,M=M+Math.imul(q,Ee)|0,m=m+Math.imul(q,Se)|0,m=m+Math.imul(K,Ee)|0,T=T+Math.imul(K,Se)|0,M=M+Math.imul(E,Ie)|0,m=m+Math.imul(E,Ae)|0,m=m+Math.imul(D,Ie)|0,T=T+Math.imul(D,Ae)|0;var sr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(sr>>>26)|0,sr&=67108863,M=Math.imul(ae,be),m=Math.imul(ae,ve),m=m+Math.imul(ce,be)|0,T=Math.imul(ce,ve),M=M+Math.imul(se,ye)|0,m=m+Math.imul(se,we)|0,m=m+Math.imul(oe,ye)|0,T=T+Math.imul(oe,we)|0,M=M+Math.imul(G,xe)|0,m=m+Math.imul(G,_e)|0,m=m+Math.imul(X,xe)|0,T=T+Math.imul(X,_e)|0,M=M+Math.imul(H,Ee)|0,m=m+Math.imul(H,Se)|0,m=m+Math.imul($,Ee)|0,T=T+Math.imul($,Se)|0,M=M+Math.imul(q,Ie)|0,m=m+Math.imul(q,Ae)|0,m=m+Math.imul(K,Ie)|0,T=T+Math.imul(K,Ae)|0,M=M+Math.imul(E,Me)|0,m=m+Math.imul(E,Te)|0,m=m+Math.imul(D,Me)|0,T=T+Math.imul(D,Te)|0;var _n=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(_n>>>26)|0,_n&=67108863,M=Math.imul(fe,be),m=Math.imul(fe,ve),m=m+Math.imul(ue,be)|0,T=Math.imul(ue,ve),M=M+Math.imul(ae,ye)|0,m=m+Math.imul(ae,we)|0,m=m+Math.imul(ce,ye)|0,T=T+Math.imul(ce,we)|0,M=M+Math.imul(se,xe)|0,m=m+Math.imul(se,_e)|0,m=m+Math.imul(oe,xe)|0,T=T+Math.imul(oe,_e)|0,M=M+Math.imul(G,Ee)|0,m=m+Math.imul(G,Se)|0,m=m+Math.imul(X,Ee)|0,T=T+Math.imul(X,Se)|0,M=M+Math.imul(H,Ie)|0,m=m+Math.imul(H,Ae)|0,m=m+Math.imul($,Ie)|0,T=T+Math.imul($,Ae)|0,M=M+Math.imul(q,Me)|0,m=m+Math.imul(q,Te)|0,m=m+Math.imul(K,Me)|0,T=T+Math.imul(K,Te)|0,M=M+Math.imul(E,Pe)|0,m=m+Math.imul(E,Re)|0,m=m+Math.imul(D,Pe)|0,T=T+Math.imul(D,Re)|0;var En=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(En>>>26)|0,En&=67108863,M=Math.imul(he,be),m=Math.imul(he,ve),m=m+Math.imul(de,be)|0,T=Math.imul(de,ve),M=M+Math.imul(fe,ye)|0,m=m+Math.imul(fe,we)|0,m=m+Math.imul(ue,ye)|0,T=T+Math.imul(ue,we)|0,M=M+Math.imul(ae,xe)|0,m=m+Math.imul(ae,_e)|0,m=m+Math.imul(ce,xe)|0,T=T+Math.imul(ce,_e)|0,M=M+Math.imul(se,Ee)|0,m=m+Math.imul(se,Se)|0,m=m+Math.imul(oe,Ee)|0,T=T+Math.imul(oe,Se)|0,M=M+Math.imul(G,Ie)|0,m=m+Math.imul(G,Ae)|0,m=m+Math.imul(X,Ie)|0,T=T+Math.imul(X,Ae)|0,M=M+Math.imul(H,Me)|0,m=m+Math.imul(H,Te)|0,m=m+Math.imul($,Me)|0,T=T+Math.imul($,Te)|0,M=M+Math.imul(q,Pe)|0,m=m+Math.imul(q,Re)|0,m=m+Math.imul(K,Pe)|0,T=T+Math.imul(K,Re)|0,M=M+Math.imul(E,Ne)|0,m=m+Math.imul(E,De)|0,m=m+Math.imul(D,Ne)|0,T=T+Math.imul(D,De)|0;var Sn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Sn>>>26)|0,Sn&=67108863,M=Math.imul(le,be),m=Math.imul(le,ve),m=m+Math.imul(pe,be)|0,T=Math.imul(pe,ve),M=M+Math.imul(he,ye)|0,m=m+Math.imul(he,we)|0,m=m+Math.imul(de,ye)|0,T=T+Math.imul(de,we)|0,M=M+Math.imul(fe,xe)|0,m=m+Math.imul(fe,_e)|0,m=m+Math.imul(ue,xe)|0,T=T+Math.imul(ue,_e)|0,M=M+Math.imul(ae,Ee)|0,m=m+Math.imul(ae,Se)|0,m=m+Math.imul(ce,Ee)|0,T=T+Math.imul(ce,Se)|0,M=M+Math.imul(se,Ie)|0,m=m+Math.imul(se,Ae)|0,m=m+Math.imul(oe,Ie)|0,T=T+Math.imul(oe,Ae)|0,M=M+Math.imul(G,Me)|0,m=m+Math.imul(G,Te)|0,m=m+Math.imul(X,Me)|0,T=T+Math.imul(X,Te)|0,M=M+Math.imul(H,Pe)|0,m=m+Math.imul(H,Re)|0,m=m+Math.imul($,Pe)|0,T=T+Math.imul($,Re)|0,M=M+Math.imul(q,Ne)|0,m=m+Math.imul(q,De)|0,m=m+Math.imul(K,Ne)|0,T=T+Math.imul(K,De)|0,M=M+Math.imul(E,Ce)|0,m=m+Math.imul(E,Oe)|0,m=m+Math.imul(D,Ce)|0,T=T+Math.imul(D,Oe)|0;var In=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(In>>>26)|0,In&=67108863,M=Math.imul(ge,be),m=Math.imul(ge,ve),m=m+Math.imul(me,be)|0,T=Math.imul(me,ve),M=M+Math.imul(le,ye)|0,m=m+Math.imul(le,we)|0,m=m+Math.imul(pe,ye)|0,T=T+Math.imul(pe,we)|0,M=M+Math.imul(he,xe)|0,m=m+Math.imul(he,_e)|0,m=m+Math.imul(de,xe)|0,T=T+Math.imul(de,_e)|0,M=M+Math.imul(fe,Ee)|0,m=m+Math.imul(fe,Se)|0,m=m+Math.imul(ue,Ee)|0,T=T+Math.imul(ue,Se)|0,M=M+Math.imul(ae,Ie)|0,m=m+Math.imul(ae,Ae)|0,m=m+Math.imul(ce,Ie)|0,T=T+Math.imul(ce,Ae)|0,M=M+Math.imul(se,Me)|0,m=m+Math.imul(se,Te)|0,m=m+Math.imul(oe,Me)|0,T=T+Math.imul(oe,Te)|0,M=M+Math.imul(G,Pe)|0,m=m+Math.imul(G,Re)|0,m=m+Math.imul(X,Pe)|0,T=T+Math.imul(X,Re)|0,M=M+Math.imul(H,Ne)|0,m=m+Math.imul(H,De)|0,m=m+Math.imul($,Ne)|0,T=T+Math.imul($,De)|0,M=M+Math.imul(q,Ce)|0,m=m+Math.imul(q,Oe)|0,m=m+Math.imul(K,Ce)|0,T=T+Math.imul(K,Oe)|0,M=M+Math.imul(E,Ke)|0,m=m+Math.imul(E,Ve)|0,m=m+Math.imul(D,Ke)|0,T=T+Math.imul(D,Ve)|0;var An=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(An>>>26)|0,An&=67108863,M=Math.imul(ge,ye),m=Math.imul(ge,we),m=m+Math.imul(me,ye)|0,T=Math.imul(me,we),M=M+Math.imul(le,xe)|0,m=m+Math.imul(le,_e)|0,m=m+Math.imul(pe,xe)|0,T=T+Math.imul(pe,_e)|0,M=M+Math.imul(he,Ee)|0,m=m+Math.imul(he,Se)|0,m=m+Math.imul(de,Ee)|0,T=T+Math.imul(de,Se)|0,M=M+Math.imul(fe,Ie)|0,m=m+Math.imul(fe,Ae)|0,m=m+Math.imul(ue,Ie)|0,T=T+Math.imul(ue,Ae)|0,M=M+Math.imul(ae,Me)|0,m=m+Math.imul(ae,Te)|0,m=m+Math.imul(ce,Me)|0,T=T+Math.imul(ce,Te)|0,M=M+Math.imul(se,Pe)|0,m=m+Math.imul(se,Re)|0,m=m+Math.imul(oe,Pe)|0,T=T+Math.imul(oe,Re)|0,M=M+Math.imul(G,Ne)|0,m=m+Math.imul(G,De)|0,m=m+Math.imul(X,Ne)|0,T=T+Math.imul(X,De)|0,M=M+Math.imul(H,Ce)|0,m=m+Math.imul(H,Oe)|0,m=m+Math.imul($,Ce)|0,T=T+Math.imul($,Oe)|0,M=M+Math.imul(q,Ke)|0,m=m+Math.imul(q,Ve)|0,m=m+Math.imul(K,Ke)|0,T=T+Math.imul(K,Ve)|0;var Mn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,M=Math.imul(ge,xe),m=Math.imul(ge,_e),m=m+Math.imul(me,xe)|0,T=Math.imul(me,_e),M=M+Math.imul(le,Ee)|0,m=m+Math.imul(le,Se)|0,m=m+Math.imul(pe,Ee)|0,T=T+Math.imul(pe,Se)|0,M=M+Math.imul(he,Ie)|0,m=m+Math.imul(he,Ae)|0,m=m+Math.imul(de,Ie)|0,T=T+Math.imul(de,Ae)|0,M=M+Math.imul(fe,Me)|0,m=m+Math.imul(fe,Te)|0,m=m+Math.imul(ue,Me)|0,T=T+Math.imul(ue,Te)|0,M=M+Math.imul(ae,Pe)|0,m=m+Math.imul(ae,Re)|0,m=m+Math.imul(ce,Pe)|0,T=T+Math.imul(ce,Re)|0,M=M+Math.imul(se,Ne)|0,m=m+Math.imul(se,De)|0,m=m+Math.imul(oe,Ne)|0,T=T+Math.imul(oe,De)|0,M=M+Math.imul(G,Ce)|0,m=m+Math.imul(G,Oe)|0,m=m+Math.imul(X,Ce)|0,T=T+Math.imul(X,Oe)|0,M=M+Math.imul(H,Ke)|0,m=m+Math.imul(H,Ve)|0,m=m+Math.imul($,Ke)|0,T=T+Math.imul($,Ve)|0;var Tn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,M=Math.imul(ge,Ee),m=Math.imul(ge,Se),m=m+Math.imul(me,Ee)|0,T=Math.imul(me,Se),M=M+Math.imul(le,Ie)|0,m=m+Math.imul(le,Ae)|0,m=m+Math.imul(pe,Ie)|0,T=T+Math.imul(pe,Ae)|0,M=M+Math.imul(he,Me)|0,m=m+Math.imul(he,Te)|0,m=m+Math.imul(de,Me)|0,T=T+Math.imul(de,Te)|0,M=M+Math.imul(fe,Pe)|0,m=m+Math.imul(fe,Re)|0,m=m+Math.imul(ue,Pe)|0,T=T+Math.imul(ue,Re)|0,M=M+Math.imul(ae,Ne)|0,m=m+Math.imul(ae,De)|0,m=m+Math.imul(ce,Ne)|0,T=T+Math.imul(ce,De)|0,M=M+Math.imul(se,Ce)|0,m=m+Math.imul(se,Oe)|0,m=m+Math.imul(oe,Ce)|0,T=T+Math.imul(oe,Oe)|0,M=M+Math.imul(G,Ke)|0,m=m+Math.imul(G,Ve)|0,m=m+Math.imul(X,Ke)|0,T=T+Math.imul(X,Ve)|0;var Pn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,M=Math.imul(ge,Ie),m=Math.imul(ge,Ae),m=m+Math.imul(me,Ie)|0,T=Math.imul(me,Ae),M=M+Math.imul(le,Me)|0,m=m+Math.imul(le,Te)|0,m=m+Math.imul(pe,Me)|0,T=T+Math.imul(pe,Te)|0,M=M+Math.imul(he,Pe)|0,m=m+Math.imul(he,Re)|0,m=m+Math.imul(de,Pe)|0,T=T+Math.imul(de,Re)|0,M=M+Math.imul(fe,Ne)|0,m=m+Math.imul(fe,De)|0,m=m+Math.imul(ue,Ne)|0,T=T+Math.imul(ue,De)|0,M=M+Math.imul(ae,Ce)|0,m=m+Math.imul(ae,Oe)|0,m=m+Math.imul(ce,Ce)|0,T=T+Math.imul(ce,Oe)|0,M=M+Math.imul(se,Ke)|0,m=m+Math.imul(se,Ve)|0,m=m+Math.imul(oe,Ke)|0,T=T+Math.imul(oe,Ve)|0;var Rn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,M=Math.imul(ge,Me),m=Math.imul(ge,Te),m=m+Math.imul(me,Me)|0,T=Math.imul(me,Te),M=M+Math.imul(le,Pe)|0,m=m+Math.imul(le,Re)|0,m=m+Math.imul(pe,Pe)|0,T=T+Math.imul(pe,Re)|0,M=M+Math.imul(he,Ne)|0,m=m+Math.imul(he,De)|0,m=m+Math.imul(de,Ne)|0,T=T+Math.imul(de,De)|0,M=M+Math.imul(fe,Ce)|0,m=m+Math.imul(fe,Oe)|0,m=m+Math.imul(ue,Ce)|0,T=T+Math.imul(ue,Oe)|0,M=M+Math.imul(ae,Ke)|0,m=m+Math.imul(ae,Ve)|0,m=m+Math.imul(ce,Ke)|0,T=T+Math.imul(ce,Ve)|0;var Nn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,M=Math.imul(ge,Pe),m=Math.imul(ge,Re),m=m+Math.imul(me,Pe)|0,T=Math.imul(me,Re),M=M+Math.imul(le,Ne)|0,m=m+Math.imul(le,De)|0,m=m+Math.imul(pe,Ne)|0,T=T+Math.imul(pe,De)|0,M=M+Math.imul(he,Ce)|0,m=m+Math.imul(he,Oe)|0,m=m+Math.imul(de,Ce)|0,T=T+Math.imul(de,Oe)|0,M=M+Math.imul(fe,Ke)|0,m=m+Math.imul(fe,Ve)|0,m=m+Math.imul(ue,Ke)|0,T=T+Math.imul(ue,Ve)|0;var Dn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,M=Math.imul(ge,Ne),m=Math.imul(ge,De),m=m+Math.imul(me,Ne)|0,T=Math.imul(me,De),M=M+Math.imul(le,Ce)|0,m=m+Math.imul(le,Oe)|0,m=m+Math.imul(pe,Ce)|0,T=T+Math.imul(pe,Oe)|0,M=M+Math.imul(he,Ke)|0,m=m+Math.imul(he,Ve)|0,m=m+Math.imul(de,Ke)|0,T=T+Math.imul(de,Ve)|0;var qu=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(qu>>>26)|0,qu&=67108863,M=Math.imul(ge,Ce),m=Math.imul(ge,Oe),m=m+Math.imul(me,Ce)|0,T=Math.imul(me,Oe),M=M+Math.imul(le,Ke)|0,m=m+Math.imul(le,Ve)|0,m=m+Math.imul(pe,Ke)|0,T=T+Math.imul(pe,Ve)|0;var Bu=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Bu>>>26)|0,Bu&=67108863,M=Math.imul(ge,Ke),m=Math.imul(ge,Ve),m=m+Math.imul(me,Ke)|0,T=Math.imul(me,Ve);var ku=(_+M|0)+((m&8191)<<13)|0;return _=(T+(m>>>13)|0)+(ku>>>26)|0,ku&=67108863,h[0]=tr,h[1]=rr,h[2]=ir,h[3]=nr,h[4]=sr,h[5]=_n,h[6]=En,h[7]=Sn,h[8]=In,h[9]=An,h[10]=Mn,h[11]=Tn,h[12]=Pn,h[13]=Rn,h[14]=Nn,h[15]=Dn,h[16]=qu,h[17]=Bu,h[18]=ku,_!==0&&(h[19]=_,b.length++),b};Math.imul||(N=O);function U(p,c,d){d.negative=c.negative^p.negative,d.length=p.length+c.length;for(var b=0,x=0,v=0;v>>26)|0,x+=h>>>26,h&=67108863}d.words[v]=_,b=h,h=x}return b!==0?d.words[v]=b:d.length--,d._strip()}function k(p,c,d){return U(p,c,d)}n.prototype.mulTo=function(c,d){var b,x=this.length+c.length;return this.length===10&&c.length===10?b=N(this,c,d):x<63?b=O(this,c,d):x<1024?b=U(this,c,d):b=k(this,c,d),b};function B(p,c){this.x=p,this.y=c}B.prototype.makeRBT=function(c){for(var d=new Array(c),b=n.prototype._countBits(c)-1,x=0;x>=1;return x},B.prototype.permute=function(c,d,b,x,v,h){for(var _=0;_>>1)v++;return 1<>>13,b[2*h+1]=v&8191,v=v>>>13;for(h=2*d;h>=26,b+=v/67108864|0,b+=h>>>26,this.words[x]=h&67108863}return b!==0&&(this.words[x]=b,this.length++),d?this.ineg():this},n.prototype.muln=function(c){return this.clone().imuln(c)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(c){var d=P(c);if(d.length===0)return new n(1);for(var b=this,x=0;x=0);var d=c%26,b=(c-d)/26,x=67108863>>>26-d<<26-d,v;if(d!==0){var h=0;for(v=0;v>>26-d}h&&(this.words[v]=h,this.length++)}if(b!==0){for(v=this.length-1;v>=0;v--)this.words[v+b]=this.words[v];for(v=0;v=0);var x;d?x=(d-d%26)/26:x=0;var v=c%26,h=Math.min((c-v)/26,this.length),_=67108863^67108863>>>v<h)for(this.length-=h,m=0;m=0&&(T!==0||m>=x);m--){var z=this.words[m]|0;this.words[m]=T<<26-v|z>>>v,T=z&_}return M&&T!==0&&(M.words[M.length++]=T),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(c,d,b){return t(this.negative===0),this.iushrn(c,d,b)},n.prototype.shln=function(c){return this.clone().ishln(c)},n.prototype.ushln=function(c){return this.clone().iushln(c)},n.prototype.shrn=function(c){return this.clone().ishrn(c)},n.prototype.ushrn=function(c){return this.clone().iushrn(c)},n.prototype.testn=function(c){t(typeof c=="number"&&c>=0);var d=c%26,b=(c-d)/26,x=1<=0);var d=c%26,b=(c-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(d!==0&&b++,this.length=Math.min(b,this.length),d!==0){var x=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(c){if(t(typeof c=="number"),t(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(M/67108864|0),this.words[v+b]=h&67108863}for(;v>26,this.words[v+b]=h&67108863;if(_===0)return this._strip();for(t(_===-1),_=0,v=0;v>26,this.words[v]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(c,d){var b=this.length-c.length,x=this.clone(),v=c,h=v.words[v.length-1]|0,_=this._countBits(h);b=26-_,b!==0&&(v=v.ushln(b),x.iushln(b),h=v.words[v.length-1]|0);var M=x.length-v.length,m;if(d!=="mod"){m=new n(null),m.length=M+1,m.words=new Array(m.length);for(var T=0;T=0;E--){var D=(x.words[v.length+E]|0)*67108864+(x.words[v.length+E-1]|0);for(D=Math.min(D/h|0,67108863),x._ishlnsubmul(v,D,E);x.negative!==0;)D--,x.negative=0,x._ishlnsubmul(v,1,E),x.isZero()||(x.negative^=1);m&&(m.words[E]=D)}return m&&m._strip(),x._strip(),d!=="div"&&b!==0&&x.iushrn(b),{div:m||null,mod:x}},n.prototype.divmod=function(c,d,b){if(t(!c.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var x,v,h;return this.negative!==0&&c.negative===0?(h=this.neg().divmod(c,d),d!=="mod"&&(x=h.div.neg()),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.iadd(c)),{div:x,mod:v}):this.negative===0&&c.negative!==0?(h=this.divmod(c.neg(),d),d!=="mod"&&(x=h.div.neg()),{div:x,mod:h.mod}):this.negative&c.negative?(h=this.neg().divmod(c.neg(),d),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.isub(c)),{div:h.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new n(0),mod:this}:c.length===1?d==="div"?{div:this.divn(c.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new n(this.modrn(c.words[0]))}:this._wordDiv(c,d)},n.prototype.div=function(c){return this.divmod(c,"div",!1).div},n.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},n.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},n.prototype.divRound=function(c){var d=this.divmod(c);if(d.mod.isZero())return d.div;var b=d.div.negative!==0?d.mod.isub(c):d.mod,x=c.ushrn(1),v=c.andln(1),h=b.cmp(x);return h<0||v===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=(1<<26)%c,x=0,v=this.length-1;v>=0;v--)x=(b*x+(this.words[v]|0))%c;return d?-x:x},n.prototype.modn=function(c){return this.modrn(c)},n.prototype.idivn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=0,x=this.length-1;x>=0;x--){var v=(this.words[x]|0)+b*67108864;this.words[x]=v/c|0,b=v%c}return this._strip(),d?this.ineg():this},n.prototype.divn=function(c){return this.clone().idivn(c)},n.prototype.egcd=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=new n(0),_=new n(1),M=0;d.isEven()&&b.isEven();)d.iushrn(1),b.iushrn(1),++M;for(var m=b.clone(),T=d.clone();!d.isZero();){for(var z=0,E=1;!(d.words[0]&E)&&z<26;++z,E<<=1);if(z>0)for(d.iushrn(z);z-- >0;)(x.isOdd()||v.isOdd())&&(x.iadd(m),v.isub(T)),x.iushrn(1),v.iushrn(1);for(var D=0,F=1;!(b.words[0]&F)&&D<26;++D,F<<=1);if(D>0)for(b.iushrn(D);D-- >0;)(h.isOdd()||_.isOdd())&&(h.iadd(m),_.isub(T)),h.iushrn(1),_.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(h),v.isub(_)):(b.isub(d),h.isub(x),_.isub(v))}return{a:h,b:_,gcd:b.iushln(M)}},n.prototype._invmp=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=b.clone();d.cmpn(1)>0&&b.cmpn(1)>0;){for(var _=0,M=1;!(d.words[0]&M)&&_<26;++_,M<<=1);if(_>0)for(d.iushrn(_);_-- >0;)x.isOdd()&&x.iadd(h),x.iushrn(1);for(var m=0,T=1;!(b.words[0]&T)&&m<26;++m,T<<=1);if(m>0)for(b.iushrn(m);m-- >0;)v.isOdd()&&v.iadd(h),v.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(v)):(b.isub(d),v.isub(x))}var z;return d.cmpn(1)===0?z=x:z=v,z.cmpn(0)<0&&z.iadd(c),z},n.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var d=this.clone(),b=c.clone();d.negative=0,b.negative=0;for(var x=0;d.isEven()&&b.isEven();x++)d.iushrn(1),b.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;b.isEven();)b.iushrn(1);var v=d.cmp(b);if(v<0){var h=d;d=b,b=h}else if(v===0||b.cmpn(1)===0)break;d.isub(b)}while(!0);return b.iushln(x)},n.prototype.invm=function(c){return this.egcd(c).a.umod(c)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(c){return this.words[0]&c},n.prototype.bincn=function(c){t(typeof c=="number");var d=c%26,b=(c-d)/26,x=1<>>26,_&=67108863,this.words[h]=_}return v!==0&&(this.words[h]=v,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(c){var d=c<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var b;if(this.length>1)b=1;else{d&&(c=-c),t(c<=67108863,"Number is too big");var x=this.words[0]|0;b=x===c?0:xc.length)return 1;if(this.length=0;b--){var x=this.words[b]|0,v=c.words[b]|0;if(x!==v){xv&&(d=1);break}}return d},n.prototype.gtn=function(c){return this.cmpn(c)===1},n.prototype.gt=function(c){return this.cmp(c)===1},n.prototype.gten=function(c){return this.cmpn(c)>=0},n.prototype.gte=function(c){return this.cmp(c)>=0},n.prototype.ltn=function(c){return this.cmpn(c)===-1},n.prototype.lt=function(c){return this.cmp(c)===-1},n.prototype.lten=function(c){return this.cmpn(c)<=0},n.prototype.lte=function(c){return this.cmp(c)<=0},n.prototype.eqn=function(c){return this.cmpn(c)===0},n.prototype.eq=function(c){return this.cmp(c)===0},n.red=function(c){return new l(c)},n.prototype.toRed=function(c){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(c){return this.red=c,this},n.prototype.forceRed=function(c){return t(!this.red,"Already a number in reduction context"),this._forceRed(c)},n.prototype.redAdd=function(c){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},n.prototype.redIAdd=function(c){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},n.prototype.redSub=function(c){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},n.prototype.redISub=function(c){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},n.prototype.redShl=function(c){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},n.prototype.redMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},n.prototype.redIMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(c){return t(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var j={k256:null,p224:null,p192:null,p25519:null};function V(p,c){this.name=p,this.p=new n(c,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var c=new n(null);return c.words=new Array(Math.ceil(this.n/13)),c},V.prototype.ireduce=function(c){var d=c,b;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),b=d.bitLength();while(b>this.n);var x=b0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},V.prototype.split=function(c,d){c.iushrn(this.n,0,d)},V.prototype.imulK=function(c){return c.imul(this.k)};function L(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,V),L.prototype.split=function(c,d){for(var b=4194303,x=Math.min(c.length,9),v=0;v>>22,h=_}h>>>=22,c.words[v-10]=h,h===0&&c.length>10?c.length-=10:c.length-=9},L.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var d=0,b=0;b>>=26,c.words[b]=v,d=x}return d!==0&&(c.words[c.length++]=d),c},n._prime=function(c){if(j[c])return j[c];var d;if(c==="k256")d=new L;else if(c==="p224")d=new C;else if(c==="p192")d=new W;else if(c==="p25519")d=new R;else throw new Error("Unknown prime "+c);return j[c]=d,d};function l(p){if(typeof p=="string"){var c=n._prime(p);this.m=c.p,this.prime=c}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(c){t(c.negative===0,"red works only with positives"),t(c.red,"red works only with red numbers")},l.prototype._verify2=function(c,d){t((c.negative|d.negative)===0,"red works only with positives"),t(c.red&&c.red===d.red,"red works only with red numbers")},l.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(u(c,c.umod(this.m)._forceRed(this)),c)},l.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},l.prototype.add=function(c,d){this._verify2(c,d);var b=c.add(d);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},l.prototype.iadd=function(c,d){this._verify2(c,d);var b=c.iadd(d);return b.cmp(this.m)>=0&&b.isub(this.m),b},l.prototype.sub=function(c,d){this._verify2(c,d);var b=c.sub(d);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},l.prototype.isub=function(c,d){this._verify2(c,d);var b=c.isub(d);return b.cmpn(0)<0&&b.iadd(this.m),b},l.prototype.shl=function(c,d){return this._verify1(c),this.imod(c.ushln(d))},l.prototype.imul=function(c,d){return this._verify2(c,d),this.imod(c.imul(d))},l.prototype.mul=function(c,d){return this._verify2(c,d),this.imod(c.mul(d))},l.prototype.isqr=function(c){return this.imul(c,c.clone())},l.prototype.sqr=function(c){return this.mul(c,c)},l.prototype.sqrt=function(c){if(c.isZero())return c.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var b=this.m.add(new n(1)).iushrn(2);return this.pow(c,b)}for(var x=this.m.subn(1),v=0;!x.isZero()&&x.andln(1)===0;)v++,x.iushrn(1);t(!x.isZero());var h=new n(1).toRed(this),_=h.redNeg(),M=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new n(2*m*m).toRed(this);this.pow(m,M).cmp(_)!==0;)m.redIAdd(_);for(var T=this.pow(m,x),z=this.pow(c,x.addn(1).iushrn(1)),E=this.pow(c,x),D=v;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;v--){for(var T=d.words[v],z=m-1;z>=0;z--){var E=T>>z&1;if(h!==x[0]&&(h=this.sqr(h)),E===0&&_===0){M=0;continue}_<<=1,_|=E,M++,!(M!==b&&(v!==0||z!==0))&&(h=this.mul(h,x[_]),M=0,_=0)}m=26}return h},l.prototype.convertTo=function(c){var d=c.umod(this.m);return d===c?d.clone():d},l.prototype.convertFrom=function(c){var d=c.clone();return d.red=null,d},n.mont=function(c){return new w(c)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},w.prototype.convertFrom=function(c){var d=this.imod(c.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(c,d){if(c.isZero()||d.isZero())return c.words[0]=0,c.length=1,c;var b=c.imul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(c,d){if(c.isZero()||d.isZero())return new n(0)._forceRed(this);var b=c.mul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(c){var d=this.imod(c._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof hd>"u"||hd,pm)});var Wi=J((mD,Mm)=>{Mm.exports=Am;function Am(r,e){if(!r)throw new Error(e||"Assertion failed")}Am.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var sa=J((bD,gd)=>{typeof Object.create=="function"?gd.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:gd.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var Ir=J(Ge=>{"use strict";var b8=Wi(),v8=sa();Ge.inherits=v8;function y8(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function w8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):y8(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ge.htonl=Tm;function _8(r,e){for(var t="",i=0;i>>0}return s}Ge.join32=E8;function S8(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ge.split32=S8;function I8(r,e){return r>>>e|r<<32-e}Ge.rotr32=I8;function A8(r,e){return r<>>32-e}Ge.rotl32=A8;function M8(r,e){return r+e>>>0}Ge.sum32=M8;function T8(r,e,t){return r+e+t>>>0}Ge.sum32_3=T8;function P8(r,e,t,i){return r+e+t+i>>>0}Ge.sum32_4=P8;function R8(r,e,t,i,n){return r+e+t+i+n>>>0}Ge.sum32_5=R8;function N8(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,a=(o>>0,r[e+1]=o}Ge.sum64=N8;function D8(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ge.sum64_hi=D8;function C8(r,e,t,i){var n=e+i;return n>>>0}Ge.sum64_lo=C8;function O8(r,e,t,i,n,s,o,a){var f=0,u=e;u=u+i>>>0,f+=u>>0,f+=u>>0,f+=u>>0}Ge.sum64_4_hi=O8;function L8(r,e,t,i,n,s,o,a){var f=e+i+s+a;return f>>>0}Ge.sum64_4_lo=L8;function F8(r,e,t,i,n,s,o,a,f,u){var g=0,y=e;y=y+i>>>0,g+=y>>0,g+=y>>0,g+=y>>0,g+=y>>0}Ge.sum64_5_hi=F8;function U8(r,e,t,i,n,s,o,a,f,u){var g=e+i+s+a+u;return g>>>0}Ge.sum64_5_lo=U8;function q8(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ge.rotr64_hi=q8;function B8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.rotr64_lo=B8;function k8(r,e,t){return r>>>t}Ge.shr64_hi=k8;function z8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.shr64_lo=z8});var Bs=J(Dm=>{"use strict";var Nm=Ir(),j8=Wi();function af(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Dm.BlockHash=af;af.prototype.update=function(e,t){if(e=Nm.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=Nm.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var K8=Ir(),ti=K8.rotr32;function V8(r,e,t,i){if(r===0)return Cm(e,t,i);if(r===1||r===3)return Lm(e,t,i);if(r===2)return Om(e,t,i)}Mi.ft_1=V8;function Cm(r,e,t){return r&e^~r&t}Mi.ch32=Cm;function Om(r,e,t){return r&e^r&t^e&t}Mi.maj32=Om;function Lm(r,e,t){return r^e^t}Mi.p32=Lm;function $8(r){return ti(r,2)^ti(r,13)^ti(r,22)}Mi.s0_256=$8;function H8(r){return ti(r,6)^ti(r,11)^ti(r,25)}Mi.s1_256=H8;function G8(r){return ti(r,7)^ti(r,18)^r>>>3}Mi.g0_256=G8;function W8(r){return ti(r,17)^ti(r,19)^r>>>10}Mi.g1_256=W8});var qm=J((xD,Um)=>{"use strict";var ks=Ir(),J8=Bs(),Y8=md(),bd=ks.rotl32,oa=ks.sum32,X8=ks.sum32_5,Q8=Y8.ft_1,Fm=J8.BlockHash,Z8=[1518500249,1859775393,2400959708,3395469782];function ri(){if(!(this instanceof ri))return new ri;Fm.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ks.inherits(ri,Fm);Um.exports=ri;ri.blockSize=512;ri.outSize=160;ri.hmacStrength=80;ri.padLength=64;ri.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var zs=Ir(),e_=Bs(),js=md(),t_=Wi(),Ar=zs.sum32,r_=zs.sum32_4,i_=zs.sum32_5,n_=js.ch32,s_=js.maj32,o_=js.s0_256,a_=js.s1_256,c_=js.g0_256,f_=js.g1_256,Bm=e_.BlockHash,u_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function ii(){if(!(this instanceof ii))return new ii;Bm.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=u_,this.W=new Array(64)}zs.inherits(ii,Bm);km.exports=ii;ii.blockSize=512;ii.outSize=256;ii.hmacStrength=192;ii.padLength=64;ii.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var yd=Ir(),zm=vd();function Ti(){if(!(this instanceof Ti))return new Ti;zm.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}yd.inherits(Ti,zm);jm.exports=Ti;Ti.blockSize=512;Ti.outSize=224;Ti.hmacStrength=192;Ti.padLength=64;Ti.prototype._digest=function(e){return e==="hex"?yd.toHex32(this.h.slice(0,7),"big"):yd.split32(this.h.slice(0,7),"big")}});var _d=J((SD,Gm)=>{"use strict";var jt=Ir(),h_=Bs(),d_=Wi(),ni=jt.rotr64_hi,si=jt.rotr64_lo,Vm=jt.shr64_hi,$m=jt.shr64_lo,Ji=jt.sum64,wd=jt.sum64_hi,xd=jt.sum64_lo,l_=jt.sum64_4_hi,p_=jt.sum64_4_lo,g_=jt.sum64_5_hi,m_=jt.sum64_5_lo,Hm=h_.BlockHash,b_=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Mr(){if(!(this instanceof Mr))return new Mr;Hm.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b_,this.W=new Array(160)}jt.inherits(Mr,Hm);Gm.exports=Mr;Mr.blockSize=1024;Mr.outSize=512;Mr.hmacStrength=192;Mr.padLength=128;Mr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Ed=Ir(),Wm=_d();function Pi(){if(!(this instanceof Pi))return new Pi;Wm.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Ed.inherits(Pi,Wm);Jm.exports=Pi;Pi.blockSize=1024;Pi.outSize=384;Pi.hmacStrength=192;Pi.padLength=128;Pi.prototype._digest=function(e){return e==="hex"?Ed.toHex32(this.h.slice(0,12),"big"):Ed.split32(this.h.slice(0,12),"big")}});var Xm=J(Ks=>{"use strict";Ks.sha1=qm();Ks.sha224=Km();Ks.sha256=vd();Ks.sha384=Ym();Ks.sha512=_d()});var ib=J(rb=>{"use strict";var Hn=Ir(),R_=Bs(),cf=Hn.rotl32,Qm=Hn.sum32,aa=Hn.sum32_3,Zm=Hn.sum32_4,tb=R_.BlockHash;function oi(){if(!(this instanceof oi))return new oi;tb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Hn.inherits(oi,tb);rb.ripemd160=oi;oi.blockSize=512;oi.outSize=160;oi.hmacStrength=192;oi.padLength=64;oi.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],f=i,u=n,g=s,y=o,S=a,I=0;I<80;I++){var A=Qm(cf(Zm(i,eb(I,n,s,o),e[C_[I]+t],N_(I)),L_[I]),a);i=a,a=o,o=cf(s,10),s=n,n=A,A=Qm(cf(Zm(f,eb(79-I,u,g,y),e[O_[I]+t],D_(I)),F_[I]),S),f=S,S=y,y=cf(g,10),g=u,u=A}A=aa(this.h[1],s,y),this.h[1]=aa(this.h[2],o,S),this.h[2]=aa(this.h[3],a,f),this.h[3]=aa(this.h[4],i,u),this.h[4]=aa(this.h[0],n,g),this.h[0]=A};oi.prototype._digest=function(e){return e==="hex"?Hn.toHex32(this.h,"little"):Hn.split32(this.h,"little")};function eb(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function N_(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function D_(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var C_=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],O_=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],L_=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],F_=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var sb=J((TD,nb)=>{"use strict";var U_=Ir(),q_=Wi();function Vs(r,e,t){if(!(this instanceof Vs))return new Vs(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(U_.toArray(e,t))}nb.exports=Vs;Vs.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),q_(e.length<=this.blockSize);for(var t=e.length;t{var xt=ob;xt.utils=Ir();xt.common=Bs();xt.sha=Xm();xt.ripemd=ib();xt.hmac=sb();xt.sha1=xt.sha.sha1;xt.sha256=xt.sha.sha256;xt.sha224=xt.sha.sha224;xt.sha384=xt.sha.sha384;xt.sha512=xt.sha.sha512;xt.ripemd160=xt.ripemd.ripemd160});var vb=J(gf=>{"use strict";Object.defineProperty(gf,"__esModule",{value:!0});var Nt=Is(),Od=cr(),J_=20;function Y_(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,a=t[3]<<24|t[2]<<16|t[1]<<8|t[0],f=t[7]<<24|t[6]<<16|t[5]<<8|t[4],u=t[11]<<24|t[10]<<16|t[9]<<8|t[8],g=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],A=t[31]<<24|t[30]<<16|t[29]<<8|t[28],P=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],N=e[11]<<24|e[10]<<16|e[9]<<8|e[8],U=e[15]<<24|e[14]<<16|e[13]<<8|e[12],k=i,B=n,j=s,V=o,L=a,C=f,W=u,R=g,l=y,w=S,p=I,c=A,d=P,b=O,x=N,v=U,h=0;h>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,B=B+C|0,b^=B,b=b>>>16|b<<16,w=w+b|0,C^=w,C=C>>>20|C<<12,j=j+W|0,x^=j,x=x>>>16|x<<16,p=p+x|0,W^=p,W=W>>>20|W<<12,V=V+R|0,v^=V,v=v>>>16|v<<16,c=c+v|0,R^=c,R=R>>>20|R<<12,j=j+W|0,x^=j,x=x>>>24|x<<8,p=p+x|0,W^=p,W=W>>>25|W<<7,V=V+R|0,v^=V,v=v>>>24|v<<8,c=c+v|0,R^=c,R=R>>>25|R<<7,B=B+C|0,b^=B,b=b>>>24|b<<8,w=w+b|0,C^=w,C=C>>>25|C<<7,k=k+L|0,d^=k,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,k=k+C|0,v^=k,v=v>>>16|v<<16,p=p+v|0,C^=p,C=C>>>20|C<<12,B=B+W|0,d^=B,d=d>>>16|d<<16,c=c+d|0,W^=c,W=W>>>20|W<<12,j=j+R|0,b^=j,b=b>>>16|b<<16,l=l+b|0,R^=l,R=R>>>20|R<<12,V=V+L|0,x^=V,x=x>>>16|x<<16,w=w+x|0,L^=w,L=L>>>20|L<<12,j=j+R|0,b^=j,b=b>>>24|b<<8,l=l+b|0,R^=l,R=R>>>25|R<<7,V=V+L|0,x^=V,x=x>>>24|x<<8,w=w+x|0,L^=w,L=L>>>25|L<<7,B=B+W|0,d^=B,d=d>>>24|d<<8,c=c+d|0,W^=c,W=W>>>25|W<<7,k=k+C|0,v^=k,v=v>>>24|v<<8,p=p+v|0,C^=p,C=C>>>25|C<<7;Nt.writeUint32LE(k+i|0,r,0),Nt.writeUint32LE(B+n|0,r,4),Nt.writeUint32LE(j+s|0,r,8),Nt.writeUint32LE(V+o|0,r,12),Nt.writeUint32LE(L+a|0,r,16),Nt.writeUint32LE(C+f|0,r,20),Nt.writeUint32LE(W+u|0,r,24),Nt.writeUint32LE(R+g|0,r,28),Nt.writeUint32LE(l+y|0,r,32),Nt.writeUint32LE(w+S|0,r,36),Nt.writeUint32LE(p+I|0,r,40),Nt.writeUint32LE(c+A|0,r,44),Nt.writeUint32LE(d+P|0,r,48),Nt.writeUint32LE(b+O|0,r,52),Nt.writeUint32LE(x+N|0,r,56),Nt.writeUint32LE(v+U|0,r,60)}function bb(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var mf=J(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});function Z_(r,e,t){return~(r-1)&e|r-1&t}Hs.select=Z_;function eE(r,e){return(r|0)-(e|0)-1>>>31&1}Hs.lessOrEqual=eE;function yb(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Hs.compare=yb;function tE(r,e){return r.length===0||e.length===0?!1:yb(r,e)!==0}Hs.equal=tE});var xb=J(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});var rE=mf(),bf=cr();Ri.DIGEST_LENGTH=16;var wb=function(){function r(e){this.digestLength=Ri.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=(o>>>14|a<<2)&8191;var f=e[12]|e[13]<<8;this._r[7]=(a>>>11|f<<5)&8065;var u=e[14]|e[15]<<8;this._r[8]=(f>>>8|u<<8)&8191,this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],a=this._h[2],f=this._h[3],u=this._h[4],g=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],A=this._h[9],P=this._r[0],O=this._r[1],N=this._r[2],U=this._r[3],k=this._r[4],B=this._r[5],j=this._r[6],V=this._r[7],L=this._r[8],C=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var R=e[t+2]|e[t+3]<<8;o+=(W>>>13|R<<3)&8191;var l=e[t+4]|e[t+5]<<8;a+=(R>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;f+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;u+=(w>>>4|p<<12)&8191,g+=p>>>1&8191;var c=e[t+10]|e[t+11]<<8;y+=(p>>>14|c<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(c>>>11|d<<5)&8191;var b=e[t+14]|e[t+15]<<8;I+=(d>>>8|b<<8)&8191,A+=b>>>5|n;var x=0,v=x;v+=s*P,v+=o*(5*C),v+=a*(5*L),v+=f*(5*V),v+=u*(5*j),x=v>>>13,v&=8191,v+=g*(5*B),v+=y*(5*k),v+=S*(5*U),v+=I*(5*N),v+=A*(5*O),x+=v>>>13,v&=8191;var h=x;h+=s*O,h+=o*P,h+=a*(5*C),h+=f*(5*L),h+=u*(5*V),x=h>>>13,h&=8191,h+=g*(5*j),h+=y*(5*B),h+=S*(5*k),h+=I*(5*U),h+=A*(5*N),x+=h>>>13,h&=8191;var _=x;_+=s*N,_+=o*O,_+=a*P,_+=f*(5*C),_+=u*(5*L),x=_>>>13,_&=8191,_+=g*(5*V),_+=y*(5*j),_+=S*(5*B),_+=I*(5*k),_+=A*(5*U),x+=_>>>13,_&=8191;var M=x;M+=s*U,M+=o*N,M+=a*O,M+=f*P,M+=u*(5*C),x=M>>>13,M&=8191,M+=g*(5*L),M+=y*(5*V),M+=S*(5*j),M+=I*(5*B),M+=A*(5*k),x+=M>>>13,M&=8191;var m=x;m+=s*k,m+=o*U,m+=a*N,m+=f*O,m+=u*P,x=m>>>13,m&=8191,m+=g*(5*C),m+=y*(5*L),m+=S*(5*V),m+=I*(5*j),m+=A*(5*B),x+=m>>>13,m&=8191;var T=x;T+=s*B,T+=o*k,T+=a*U,T+=f*N,T+=u*O,x=T>>>13,T&=8191,T+=g*P,T+=y*(5*C),T+=S*(5*L),T+=I*(5*V),T+=A*(5*j),x+=T>>>13,T&=8191;var z=x;z+=s*j,z+=o*B,z+=a*k,z+=f*U,z+=u*N,x=z>>>13,z&=8191,z+=g*O,z+=y*P,z+=S*(5*C),z+=I*(5*L),z+=A*(5*V),x+=z>>>13,z&=8191;var E=x;E+=s*V,E+=o*j,E+=a*B,E+=f*k,E+=u*U,x=E>>>13,E&=8191,E+=g*N,E+=y*O,E+=S*P,E+=I*(5*C),E+=A*(5*L),x+=E>>>13,E&=8191;var D=x;D+=s*L,D+=o*V,D+=a*j,D+=f*B,D+=u*k,x=D>>>13,D&=8191,D+=g*U,D+=y*N,D+=S*O,D+=I*P,D+=A*(5*C),x+=D>>>13,D&=8191;var F=x;F+=s*C,F+=o*L,F+=a*V,F+=f*j,F+=u*B,x=F>>>13,F&=8191,F+=g*k,F+=y*U,F+=S*N,F+=I*O,F+=A*P,x+=F>>>13,F&=8191,x=(x<<2)+x|0,x=x+v|0,v=x&8191,x=x>>>13,h+=x,s=v,o=h,a=_,f=M,u=m,g=T,y=z,S=E,I=D,A=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=a,this._h[3]=f,this._h[4]=u,this._h[5]=g,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=A},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,a;if(this._leftover){for(a=this._leftover,this._buffer[a++]=1;a<16;a++)this._buffer[a]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,a=2;a<10;a++)this._h[a]+=n,n=this._h[a]>>>13,this._h[a]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,a=1;a<10;a++)i[a]=this._h[a]+n,n=i[a]>>>13,i[a]&=8191;for(i[9]-=8192,s=(n^1)-1,a=0;a<10;a++)i[a]&=s;for(s=~s,a=0;a<10;a++)this._h[a]=this._h[a]&s|i[a];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,a=1;a<8;a++)o=(this._h[a]+this._pad[a]|0)+(o>>>16)|0,this._h[a]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});var vf=vb(),sE=xb(),fa=cr(),_b=Is(),oE=mf();Ni.KEY_LENGTH=32;Ni.NONCE_LENGTH=12;Ni.TAG_LENGTH=16;var Eb=new Uint8Array(16),aE=function(){function r(e){if(this.nonceLength=Ni.NONCE_LENGTH,this.tagLength=Ni.TAG_LENGTH,e.length!==Ni.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);vf.stream(this._key,s,o,4);var a=t.length+this.tagLength,f;if(n){if(n.length!==a)throw new Error("ChaCha20Poly1305: incorrect destination length");f=n}else f=new Uint8Array(a);return vf.streamXOR(this._key,s,t,f,4),this._authenticate(f.subarray(f.length-this.tagLength,f.length),o,f.subarray(0,f.length-this.tagLength),i),fa.wipe(s),f},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(Eb.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(Eb.subarray(i.length%16));var o=new Uint8Array(8);n&&_b.writeUint64LE(n.length,o),s.update(o),_b.writeUint64LE(i.length,o),s.update(o);for(var a=s.digest(),f=0;f{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});function cE(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}Ld.isSerializableHash=cE});var Mb=J(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});var fi=Ib(),fE=mf(),uE=cr(),Ab=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});var Tb=Mb(),Pb=cr(),dE=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Tb.hmac(this._hash,i,t);this._hmac=new Tb.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});var wf=Is(),yf=cr();Qi.DIGEST_LENGTH=32;Qi.BLOCK_SIZE=64;var Nb=function(){function r(){this.digestLength=Qi.DIGEST_LENGTH,this.blockSize=Qi.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){yf.wipe(this._buffer),yf.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(Ud(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=Ud(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){yf.wipe(e.state),e.buffer&&yf.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Qi.SHA256=Nb;var lE=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Ud(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],a=e[2],f=e[3],u=e[4],g=e[5],y=e[6],S=e[7],I=0;I<16;I++){var A=i+I*4;r[I]=wf.readUint32BE(t,A)}for(var I=16;I<64;I++){var P=r[I-2],O=(P>>>17|P<<15)^(P>>>19|P<<13)^P>>>10;P=r[I-15];var N=(P>>>7|P<<25)^(P>>>18|P<<14)^P>>>3;r[I]=(O+r[I-7]|0)+(N+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&g^~u&y)|0)+(S+(lE[I]+r[I]|0)|0)|0,N=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&a^o&a)|0;S=y,y=g,g=u,u=f+O|0,f=a,a=o,o=s,s=O+N|0}e[0]+=s,e[1]+=o,e[2]+=a,e[3]+=f,e[4]+=u,e[5]+=g,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function pE(r){var e=new Nb;e.update(r);var t=e.digest();return e.clean(),t}Qi.hash=pE});var Fb=J(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.sharedKey=it.generateKeyPair=it.generateKeyPairFromSeed=it.scalarMultBase=it.scalarMult=it.SHARED_KEY_LENGTH=it.SECRET_KEY_LENGTH=it.PUBLIC_KEY_LENGTH=void 0;var gE=$o(),mE=cr();it.PUBLIC_KEY_LENGTH=32;it.SECRET_KEY_LENGTH=32;it.SHARED_KEY_LENGTH=32;function ui(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,ha(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function yE(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function xf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function _f(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function Di(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,P=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,C=0,W=0,R=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],M=t[1],m=t[2],T=t[3],z=t[4],E=t[5],D=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*M,a+=i*m,f+=i*T,u+=i*z,g+=i*E,y+=i*D,S+=i*F,I+=i*q,A+=i*K,P+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*M,f+=i*m,u+=i*T,g+=i*z,y+=i*E,S+=i*D,I+=i*F,A+=i*q,P+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*M,u+=i*m,g+=i*T,y+=i*z,S+=i*E,I+=i*D,A+=i*F,P+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*M,g+=i*m,y+=i*T,S+=i*z,I+=i*E,A+=i*D,P+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*M,y+=i*m,S+=i*T,I+=i*z,A+=i*E,P+=i*D,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,C+=i*X,i=e[5],g+=i*_,y+=i*M,S+=i*m,I+=i*T,A+=i*z,P+=i*E,O+=i*D,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,C+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*M,I+=i*m,A+=i*T,P+=i*z,O+=i*E,N+=i*D,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,C+=i*ee,W+=i*G,R+=i*X,i=e[7],S+=i*_,I+=i*M,A+=i*m,P+=i*T,O+=i*z,N+=i*E,U+=i*D,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,C+=i*$,W+=i*ee,R+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*M,P+=i*m,O+=i*T,N+=i*z,U+=i*E,k+=i*D,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,C+=i*H,W+=i*$,R+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,P+=i*M,O+=i*m,N+=i*T,U+=i*z,k+=i*E,B+=i*D,j+=i*F,V+=i*q,L+=i*K,C+=i*Y,W+=i*H,R+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],P+=i*_,O+=i*M,N+=i*m,U+=i*T,k+=i*z,B+=i*E,j+=i*D,V+=i*F,L+=i*q,C+=i*K,W+=i*Y,R+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*M,U+=i*m,k+=i*T,B+=i*z,j+=i*E,V+=i*D,L+=i*F,C+=i*q,W+=i*K,R+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*M,k+=i*m,B+=i*T,j+=i*z,V+=i*E,L+=i*D,C+=i*F,W+=i*q,R+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*M,B+=i*m,j+=i*T,V+=i*z,L+=i*E,C+=i*D,W+=i*F,R+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*M,j+=i*m,V+=i*T,L+=i*z,C+=i*E,W+=i*D,R+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*M,V+=i*m,L+=i*T,C+=i*z,W+=i*E,R+=i*D,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*C,u+=38*W,g+=38*R,y+=38*l,S+=38*w,I+=38*p,A+=38*c,P+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=P,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function da(r,e){Di(r,e,e)}function wE(r,e){let t=ui();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)da(t,t),i!==2&&i!==4&&Di(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function Bd(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=ui(),s=ui(),o=ui(),a=ui(),f=ui(),u=ui();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,yE(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=a[0]=1;for(let I=254;I>=0;--I){let A=t[I>>>3]>>>(I&7)&1;ha(n,s,A),ha(o,a,A),xf(f,n,o),_f(n,n,o),xf(o,s,a),_f(s,s,a),da(a,f),da(u,n),Di(n,o,n),Di(o,s,f),xf(f,n,o),_f(n,n,o),da(s,n),_f(o,a,u),Di(n,o,bE),xf(n,n,a),Di(o,o,n),Di(n,a,u),Di(a,s,i),da(s,f),ha(n,s,A),ha(o,a,A)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=a[I];let g=i.subarray(32),y=i.subarray(16);wE(g,g),Di(y,y,g);let S=new Uint8Array(32);return vE(S,y),S}it.scalarMult=Bd;function Ob(r){return Bd(r,Cb)}it.scalarMultBase=Ob;function Lb(r){if(r.length!==it.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${it.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:Ob(e),secretKey:e}}it.generateKeyPairFromSeed=Lb;function xE(r){let e=(0,gE.randomBytes)(32,r),t=Lb(e);return(0,mE.wipe)(e),t}it.generateKeyPair=xE;function _E(r,e,t=!1){if(r.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=Bd(r,e);if(t){let n=0;for(let s=0;s{EE.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var hi=J((qb,kd)=>{(function(r,e){"use strict";function t(R,l){if(!R)throw new Error(l||"Assertion failed")}function i(R,l){R.super_=l;var w=function(){};w.prototype=l.prototype,R.prototype=new w,R.prototype.constructor=R}function n(R,l,w){if(n.isBN(R))return R;this.negative=0,this.words=null,this.length=0,this.red=null,R!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(R||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=ud().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var c=0;l[0]==="-"&&(c++,this.negative=1),c=0;c-=3)b=l[c]|l[c-1]<<8|l[c-2]<<16,this.words[d]|=b<>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);else if(p==="le")for(c=0,d=0;c>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);return this.strip()};function o(R,l){var w=R.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function a(R,l,w){var p=o(R,w);return w-1>=l&&(p|=o(R,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var c=0;c=w;c-=2)x=a(l,w,c)<=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8;else{var v=l.length-w;for(c=v%2===0?w+1:w;c=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8}this.strip()};function f(R,l,w,p){for(var c=0,d=Math.min(R.length,w),b=l;b=49?c+=x-49+10:x>=17?c+=x-17+10:c+=x}return c}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var c=0,d=1;d<=67108863;d*=w)c++;c--,d=d/w|0;for(var b=l.length-p,x=b%c,v=Math.min(b,b-x)+p,h=0,_=p;_1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var c=0,d=0,b=0;b>>24-c&16777215,d!==0||b!==this.length-1?p=u[6-v.length]+v+p:p=v+p,c+=2,c>=26&&(c-=26,b--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=g[l],_=y[l];p="";var M=this.clone();for(M.negative=0;!M.isZero();){var m=M.modn(_).toString(l);M=M.idivn(_),M.isZero()?p=m+p:p=u[h-m.length]+m+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var c=this.byteLength(),d=p||Math.max(1,c);t(c<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var b=w==="le",x=new l(d),v,h,_=this.clone();if(b){for(h=0;!_.isZero();h++)v=_.andln(255),_.iushrn(8),x[h]=v;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(R){for(var l=new Array(R.bitLength()),w=0;w>>c}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var c=0;cl.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var c=0;c0&&(this.words[c]=~this.words[c]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,c=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,c=l):(p=l,c=this);for(var d=0,b=0;b>>26;for(;d!==0&&b>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;bl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var c,d;p>0?(c=this,d=l):(c=l,d=this);for(var b=0,x=0;x>26,this.words[x]=w&67108863;for(;b!==0&&x>26,this.words[x]=w&67108863;if(b===0&&x>>26,M=v&67108863,m=Math.min(h,l.length-1),T=Math.max(0,h-R.length+1);T<=m;T++){var z=h-T|0;c=R.words[z]|0,d=l.words[T]|0,b=c*d+M,_+=b/67108864|0,M=b&67108863}w.words[h]=M|0,v=_|0}return v!==0?w.words[h]=v|0:w.length--,w.strip()}var A=function(l,w,p){var c=l.words,d=w.words,b=p.words,x=0,v,h,_,M=c[0]|0,m=M&8191,T=M>>>13,z=c[1]|0,E=z&8191,D=z>>>13,F=c[2]|0,q=F&8191,K=F>>>13,Y=c[3]|0,H=Y&8191,$=Y>>>13,ee=c[4]|0,G=ee&8191,X=ee>>>13,Ur=c[5]|0,se=Ur&8191,oe=Ur>>>13,qr=c[6]|0,ae=qr&8191,ce=qr>>>13,Br=c[7]|0,fe=Br&8191,ue=Br>>>13,kr=c[8]|0,he=kr&8191,de=kr>>>13,zr=c[9]|0,le=zr&8191,pe=zr>>>13,jr=d[0]|0,ge=jr&8191,me=jr>>>13,Kr=d[1]|0,be=Kr&8191,ve=Kr>>>13,Vr=d[2]|0,ye=Vr&8191,we=Vr>>>13,$r=d[3]|0,xe=$r&8191,_e=$r>>>13,Hr=d[4]|0,Ee=Hr&8191,Se=Hr>>>13,Gr=d[5]|0,Ie=Gr&8191,Ae=Gr>>>13,Wr=d[6]|0,Me=Wr&8191,Te=Wr>>>13,Jr=d[7]|0,Pe=Jr&8191,Re=Jr>>>13,Yr=d[8]|0,Ne=Yr&8191,De=Yr>>>13,Xr=d[9]|0,Ce=Xr&8191,Oe=Xr>>>13;p.negative=l.negative^w.negative,p.length=19,v=Math.imul(m,ge),h=Math.imul(m,me),h=h+Math.imul(T,ge)|0,_=Math.imul(T,me);var vr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(vr>>>26)|0,vr&=67108863,v=Math.imul(E,ge),h=Math.imul(E,me),h=h+Math.imul(D,ge)|0,_=Math.imul(D,me),v=v+Math.imul(m,be)|0,h=h+Math.imul(m,ve)|0,h=h+Math.imul(T,be)|0,_=_+Math.imul(T,ve)|0;var Ke=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,v=Math.imul(q,ge),h=Math.imul(q,me),h=h+Math.imul(K,ge)|0,_=Math.imul(K,me),v=v+Math.imul(E,be)|0,h=h+Math.imul(E,ve)|0,h=h+Math.imul(D,be)|0,_=_+Math.imul(D,ve)|0,v=v+Math.imul(m,ye)|0,h=h+Math.imul(m,we)|0,h=h+Math.imul(T,ye)|0,_=_+Math.imul(T,we)|0;var Ve=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,v=Math.imul(H,ge),h=Math.imul(H,me),h=h+Math.imul($,ge)|0,_=Math.imul($,me),v=v+Math.imul(q,be)|0,h=h+Math.imul(q,ve)|0,h=h+Math.imul(K,be)|0,_=_+Math.imul(K,ve)|0,v=v+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(D,ye)|0,_=_+Math.imul(D,we)|0,v=v+Math.imul(m,xe)|0,h=h+Math.imul(m,_e)|0,h=h+Math.imul(T,xe)|0,_=_+Math.imul(T,_e)|0;var tr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(tr>>>26)|0,tr&=67108863,v=Math.imul(G,ge),h=Math.imul(G,me),h=h+Math.imul(X,ge)|0,_=Math.imul(X,me),v=v+Math.imul(H,be)|0,h=h+Math.imul(H,ve)|0,h=h+Math.imul($,be)|0,_=_+Math.imul($,ve)|0,v=v+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,_=_+Math.imul(K,we)|0,v=v+Math.imul(E,xe)|0,h=h+Math.imul(E,_e)|0,h=h+Math.imul(D,xe)|0,_=_+Math.imul(D,_e)|0,v=v+Math.imul(m,Ee)|0,h=h+Math.imul(m,Se)|0,h=h+Math.imul(T,Ee)|0,_=_+Math.imul(T,Se)|0;var rr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(rr>>>26)|0,rr&=67108863,v=Math.imul(se,ge),h=Math.imul(se,me),h=h+Math.imul(oe,ge)|0,_=Math.imul(oe,me),v=v+Math.imul(G,be)|0,h=h+Math.imul(G,ve)|0,h=h+Math.imul(X,be)|0,_=_+Math.imul(X,ve)|0,v=v+Math.imul(H,ye)|0,h=h+Math.imul(H,we)|0,h=h+Math.imul($,ye)|0,_=_+Math.imul($,we)|0,v=v+Math.imul(q,xe)|0,h=h+Math.imul(q,_e)|0,h=h+Math.imul(K,xe)|0,_=_+Math.imul(K,_e)|0,v=v+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(D,Ee)|0,_=_+Math.imul(D,Se)|0,v=v+Math.imul(m,Ie)|0,h=h+Math.imul(m,Ae)|0,h=h+Math.imul(T,Ie)|0,_=_+Math.imul(T,Ae)|0;var ir=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(ir>>>26)|0,ir&=67108863,v=Math.imul(ae,ge),h=Math.imul(ae,me),h=h+Math.imul(ce,ge)|0,_=Math.imul(ce,me),v=v+Math.imul(se,be)|0,h=h+Math.imul(se,ve)|0,h=h+Math.imul(oe,be)|0,_=_+Math.imul(oe,ve)|0,v=v+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(X,ye)|0,_=_+Math.imul(X,we)|0,v=v+Math.imul(H,xe)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul($,xe)|0,_=_+Math.imul($,_e)|0,v=v+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,_=_+Math.imul(K,Se)|0,v=v+Math.imul(E,Ie)|0,h=h+Math.imul(E,Ae)|0,h=h+Math.imul(D,Ie)|0,_=_+Math.imul(D,Ae)|0,v=v+Math.imul(m,Me)|0,h=h+Math.imul(m,Te)|0,h=h+Math.imul(T,Me)|0,_=_+Math.imul(T,Te)|0;var nr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,v=Math.imul(fe,ge),h=Math.imul(fe,me),h=h+Math.imul(ue,ge)|0,_=Math.imul(ue,me),v=v+Math.imul(ae,be)|0,h=h+Math.imul(ae,ve)|0,h=h+Math.imul(ce,be)|0,_=_+Math.imul(ce,ve)|0,v=v+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,_=_+Math.imul(oe,we)|0,v=v+Math.imul(G,xe)|0,h=h+Math.imul(G,_e)|0,h=h+Math.imul(X,xe)|0,_=_+Math.imul(X,_e)|0,v=v+Math.imul(H,Ee)|0,h=h+Math.imul(H,Se)|0,h=h+Math.imul($,Ee)|0,_=_+Math.imul($,Se)|0,v=v+Math.imul(q,Ie)|0,h=h+Math.imul(q,Ae)|0,h=h+Math.imul(K,Ie)|0,_=_+Math.imul(K,Ae)|0,v=v+Math.imul(E,Me)|0,h=h+Math.imul(E,Te)|0,h=h+Math.imul(D,Me)|0,_=_+Math.imul(D,Te)|0,v=v+Math.imul(m,Pe)|0,h=h+Math.imul(m,Re)|0,h=h+Math.imul(T,Pe)|0,_=_+Math.imul(T,Re)|0;var sr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(sr>>>26)|0,sr&=67108863,v=Math.imul(he,ge),h=Math.imul(he,me),h=h+Math.imul(de,ge)|0,_=Math.imul(de,me),v=v+Math.imul(fe,be)|0,h=h+Math.imul(fe,ve)|0,h=h+Math.imul(ue,be)|0,_=_+Math.imul(ue,ve)|0,v=v+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(ce,ye)|0,_=_+Math.imul(ce,we)|0,v=v+Math.imul(se,xe)|0,h=h+Math.imul(se,_e)|0,h=h+Math.imul(oe,xe)|0,_=_+Math.imul(oe,_e)|0,v=v+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(X,Ee)|0,_=_+Math.imul(X,Se)|0,v=v+Math.imul(H,Ie)|0,h=h+Math.imul(H,Ae)|0,h=h+Math.imul($,Ie)|0,_=_+Math.imul($,Ae)|0,v=v+Math.imul(q,Me)|0,h=h+Math.imul(q,Te)|0,h=h+Math.imul(K,Me)|0,_=_+Math.imul(K,Te)|0,v=v+Math.imul(E,Pe)|0,h=h+Math.imul(E,Re)|0,h=h+Math.imul(D,Pe)|0,_=_+Math.imul(D,Re)|0,v=v+Math.imul(m,Ne)|0,h=h+Math.imul(m,De)|0,h=h+Math.imul(T,Ne)|0,_=_+Math.imul(T,De)|0;var _n=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(_n>>>26)|0,_n&=67108863,v=Math.imul(le,ge),h=Math.imul(le,me),h=h+Math.imul(pe,ge)|0,_=Math.imul(pe,me),v=v+Math.imul(he,be)|0,h=h+Math.imul(he,ve)|0,h=h+Math.imul(de,be)|0,_=_+Math.imul(de,ve)|0,v=v+Math.imul(fe,ye)|0,h=h+Math.imul(fe,we)|0,h=h+Math.imul(ue,ye)|0,_=_+Math.imul(ue,we)|0,v=v+Math.imul(ae,xe)|0,h=h+Math.imul(ae,_e)|0,h=h+Math.imul(ce,xe)|0,_=_+Math.imul(ce,_e)|0,v=v+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,_=_+Math.imul(oe,Se)|0,v=v+Math.imul(G,Ie)|0,h=h+Math.imul(G,Ae)|0,h=h+Math.imul(X,Ie)|0,_=_+Math.imul(X,Ae)|0,v=v+Math.imul(H,Me)|0,h=h+Math.imul(H,Te)|0,h=h+Math.imul($,Me)|0,_=_+Math.imul($,Te)|0,v=v+Math.imul(q,Pe)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(K,Pe)|0,_=_+Math.imul(K,Re)|0,v=v+Math.imul(E,Ne)|0,h=h+Math.imul(E,De)|0,h=h+Math.imul(D,Ne)|0,_=_+Math.imul(D,De)|0,v=v+Math.imul(m,Ce)|0,h=h+Math.imul(m,Oe)|0,h=h+Math.imul(T,Ce)|0,_=_+Math.imul(T,Oe)|0;var En=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(En>>>26)|0,En&=67108863,v=Math.imul(le,be),h=Math.imul(le,ve),h=h+Math.imul(pe,be)|0,_=Math.imul(pe,ve),v=v+Math.imul(he,ye)|0,h=h+Math.imul(he,we)|0,h=h+Math.imul(de,ye)|0,_=_+Math.imul(de,we)|0,v=v+Math.imul(fe,xe)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(ue,xe)|0,_=_+Math.imul(ue,_e)|0,v=v+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(ce,Ee)|0,_=_+Math.imul(ce,Se)|0,v=v+Math.imul(se,Ie)|0,h=h+Math.imul(se,Ae)|0,h=h+Math.imul(oe,Ie)|0,_=_+Math.imul(oe,Ae)|0,v=v+Math.imul(G,Me)|0,h=h+Math.imul(G,Te)|0,h=h+Math.imul(X,Me)|0,_=_+Math.imul(X,Te)|0,v=v+Math.imul(H,Pe)|0,h=h+Math.imul(H,Re)|0,h=h+Math.imul($,Pe)|0,_=_+Math.imul($,Re)|0,v=v+Math.imul(q,Ne)|0,h=h+Math.imul(q,De)|0,h=h+Math.imul(K,Ne)|0,_=_+Math.imul(K,De)|0,v=v+Math.imul(E,Ce)|0,h=h+Math.imul(E,Oe)|0,h=h+Math.imul(D,Ce)|0,_=_+Math.imul(D,Oe)|0;var Sn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Sn>>>26)|0,Sn&=67108863,v=Math.imul(le,ye),h=Math.imul(le,we),h=h+Math.imul(pe,ye)|0,_=Math.imul(pe,we),v=v+Math.imul(he,xe)|0,h=h+Math.imul(he,_e)|0,h=h+Math.imul(de,xe)|0,_=_+Math.imul(de,_e)|0,v=v+Math.imul(fe,Ee)|0,h=h+Math.imul(fe,Se)|0,h=h+Math.imul(ue,Ee)|0,_=_+Math.imul(ue,Se)|0,v=v+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Ae)|0,h=h+Math.imul(ce,Ie)|0,_=_+Math.imul(ce,Ae)|0,v=v+Math.imul(se,Me)|0,h=h+Math.imul(se,Te)|0,h=h+Math.imul(oe,Me)|0,_=_+Math.imul(oe,Te)|0,v=v+Math.imul(G,Pe)|0,h=h+Math.imul(G,Re)|0,h=h+Math.imul(X,Pe)|0,_=_+Math.imul(X,Re)|0,v=v+Math.imul(H,Ne)|0,h=h+Math.imul(H,De)|0,h=h+Math.imul($,Ne)|0,_=_+Math.imul($,De)|0,v=v+Math.imul(q,Ce)|0,h=h+Math.imul(q,Oe)|0,h=h+Math.imul(K,Ce)|0,_=_+Math.imul(K,Oe)|0;var In=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(In>>>26)|0,In&=67108863,v=Math.imul(le,xe),h=Math.imul(le,_e),h=h+Math.imul(pe,xe)|0,_=Math.imul(pe,_e),v=v+Math.imul(he,Ee)|0,h=h+Math.imul(he,Se)|0,h=h+Math.imul(de,Ee)|0,_=_+Math.imul(de,Se)|0,v=v+Math.imul(fe,Ie)|0,h=h+Math.imul(fe,Ae)|0,h=h+Math.imul(ue,Ie)|0,_=_+Math.imul(ue,Ae)|0,v=v+Math.imul(ae,Me)|0,h=h+Math.imul(ae,Te)|0,h=h+Math.imul(ce,Me)|0,_=_+Math.imul(ce,Te)|0,v=v+Math.imul(se,Pe)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(oe,Pe)|0,_=_+Math.imul(oe,Re)|0,v=v+Math.imul(G,Ne)|0,h=h+Math.imul(G,De)|0,h=h+Math.imul(X,Ne)|0,_=_+Math.imul(X,De)|0,v=v+Math.imul(H,Ce)|0,h=h+Math.imul(H,Oe)|0,h=h+Math.imul($,Ce)|0,_=_+Math.imul($,Oe)|0;var An=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(An>>>26)|0,An&=67108863,v=Math.imul(le,Ee),h=Math.imul(le,Se),h=h+Math.imul(pe,Ee)|0,_=Math.imul(pe,Se),v=v+Math.imul(he,Ie)|0,h=h+Math.imul(he,Ae)|0,h=h+Math.imul(de,Ie)|0,_=_+Math.imul(de,Ae)|0,v=v+Math.imul(fe,Me)|0,h=h+Math.imul(fe,Te)|0,h=h+Math.imul(ue,Me)|0,_=_+Math.imul(ue,Te)|0,v=v+Math.imul(ae,Pe)|0,h=h+Math.imul(ae,Re)|0,h=h+Math.imul(ce,Pe)|0,_=_+Math.imul(ce,Re)|0,v=v+Math.imul(se,Ne)|0,h=h+Math.imul(se,De)|0,h=h+Math.imul(oe,Ne)|0,_=_+Math.imul(oe,De)|0,v=v+Math.imul(G,Ce)|0,h=h+Math.imul(G,Oe)|0,h=h+Math.imul(X,Ce)|0,_=_+Math.imul(X,Oe)|0;var Mn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,v=Math.imul(le,Ie),h=Math.imul(le,Ae),h=h+Math.imul(pe,Ie)|0,_=Math.imul(pe,Ae),v=v+Math.imul(he,Me)|0,h=h+Math.imul(he,Te)|0,h=h+Math.imul(de,Me)|0,_=_+Math.imul(de,Te)|0,v=v+Math.imul(fe,Pe)|0,h=h+Math.imul(fe,Re)|0,h=h+Math.imul(ue,Pe)|0,_=_+Math.imul(ue,Re)|0,v=v+Math.imul(ae,Ne)|0,h=h+Math.imul(ae,De)|0,h=h+Math.imul(ce,Ne)|0,_=_+Math.imul(ce,De)|0,v=v+Math.imul(se,Ce)|0,h=h+Math.imul(se,Oe)|0,h=h+Math.imul(oe,Ce)|0,_=_+Math.imul(oe,Oe)|0;var Tn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,v=Math.imul(le,Me),h=Math.imul(le,Te),h=h+Math.imul(pe,Me)|0,_=Math.imul(pe,Te),v=v+Math.imul(he,Pe)|0,h=h+Math.imul(he,Re)|0,h=h+Math.imul(de,Pe)|0,_=_+Math.imul(de,Re)|0,v=v+Math.imul(fe,Ne)|0,h=h+Math.imul(fe,De)|0,h=h+Math.imul(ue,Ne)|0,_=_+Math.imul(ue,De)|0,v=v+Math.imul(ae,Ce)|0,h=h+Math.imul(ae,Oe)|0,h=h+Math.imul(ce,Ce)|0,_=_+Math.imul(ce,Oe)|0;var Pn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,v=Math.imul(le,Pe),h=Math.imul(le,Re),h=h+Math.imul(pe,Pe)|0,_=Math.imul(pe,Re),v=v+Math.imul(he,Ne)|0,h=h+Math.imul(he,De)|0,h=h+Math.imul(de,Ne)|0,_=_+Math.imul(de,De)|0,v=v+Math.imul(fe,Ce)|0,h=h+Math.imul(fe,Oe)|0,h=h+Math.imul(ue,Ce)|0,_=_+Math.imul(ue,Oe)|0;var Rn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,v=Math.imul(le,Ne),h=Math.imul(le,De),h=h+Math.imul(pe,Ne)|0,_=Math.imul(pe,De),v=v+Math.imul(he,Ce)|0,h=h+Math.imul(he,Oe)|0,h=h+Math.imul(de,Ce)|0,_=_+Math.imul(de,Oe)|0;var Nn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,v=Math.imul(le,Ce),h=Math.imul(le,Oe),h=h+Math.imul(pe,Ce)|0,_=Math.imul(pe,Oe);var Dn=(x+v|0)+((h&8191)<<13)|0;return x=(_+(h>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,b[0]=vr,b[1]=Ke,b[2]=Ve,b[3]=tr,b[4]=rr,b[5]=ir,b[6]=nr,b[7]=sr,b[8]=_n,b[9]=En,b[10]=Sn,b[11]=In,b[12]=An,b[13]=Mn,b[14]=Tn,b[15]=Pn,b[16]=Rn,b[17]=Nn,b[18]=Dn,x!==0&&(b[19]=x,p.length++),p};Math.imul||(A=I);function P(R,l,w){w.negative=l.negative^R.negative,w.length=R.length+l.length;for(var p=0,c=0,d=0;d>>26)|0,c+=b>>>26,b&=67108863}w.words[d]=x,p=b,b=c}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(R,l,w){var p=new N;return p.mulp(R,l,w)}n.prototype.mulTo=function(l,w){var p,c=this.length+l.length;return this.length===10&&l.length===10?p=A(this,l,w):c<63?p=I(this,l,w):c<1024?p=P(this,l,w):p=O(this,l,w),p};function N(R,l){this.x=R,this.y=l}N.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,c=0;c>=1;return c},N.prototype.permute=function(l,w,p,c,d,b){for(var x=0;x>>1)d++;return 1<>>13,p[2*b+1]=d&8191,d=d>>>13;for(b=2*w;b>=26,w+=c/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,c=0;c=0);var w=l%26,p=(l-w)/26,c=67108863>>>26-w<<26-w,d;if(w!==0){var b=0;for(d=0;d>>26-w}b&&(this.words[d]=b,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var c;w?c=(w-w%26)/26:c=0;var d=l%26,b=Math.min((l-d)/26,this.length),x=67108863^67108863>>>d<b)for(this.length-=b,h=0;h=0&&(_!==0||h>=c);h--){var M=this.words[h]|0;this.words[h]=_<<26-d|M>>>d,_=M&x}return v&&_!==0&&(v.words[v.length++]=_),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,c=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var c=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(v/67108864|0),this.words[d+p]=b&67108863}for(;d>26,this.words[d+p]=b&67108863;if(x===0)return this.strip();for(t(x===-1),x=0,d=0;d>26,this.words[d]=b&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,c=this.clone(),d=l,b=d.words[d.length-1]|0,x=this._countBits(b);p=26-x,p!==0&&(d=d.ushln(p),c.iushln(p),b=d.words[d.length-1]|0);var v=c.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=v+1,h.words=new Array(h.length);for(var _=0;_=0;m--){var T=(c.words[d.length+m]|0)*67108864+(c.words[d.length+m-1]|0);for(T=Math.min(T/b|0,67108863),c._ishlnsubmul(d,T,m);c.negative!==0;)T--,c.negative=0,c._ishlnsubmul(d,1,m),c.isZero()||(c.negative^=1);h&&(h.words[m]=T)}return h&&h.strip(),c.strip(),w!=="div"&&p!==0&&c.iushrn(p),{div:h||null,mod:c}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var c,d,b;return this.negative!==0&&l.negative===0?(b=this.neg().divmod(l,w),w!=="mod"&&(c=b.div.neg()),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:c,mod:d}):this.negative===0&&l.negative!==0?(b=this.divmod(l.neg(),w),w!=="mod"&&(c=b.div.neg()),{div:c,mod:b.mod}):this.negative&l.negative?(b=this.neg().divmod(l.neg(),w),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:b.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,c=l.ushrn(1),d=l.andln(1),b=p.cmp(c);return b<0||d===1&&b===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,c=this.length-1;c>=0;c--)p=(w*p+(this.words[c]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var c=(this.words[p]|0)+w*67108864;this.words[p]=c/l|0,w=c%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=new n(0),x=new n(1),v=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++v;for(var h=p.clone(),_=w.clone();!w.isZero();){for(var M=0,m=1;!(w.words[0]&m)&&M<26;++M,m<<=1);if(M>0)for(w.iushrn(M);M-- >0;)(c.isOdd()||d.isOdd())&&(c.iadd(h),d.isub(_)),c.iushrn(1),d.iushrn(1);for(var T=0,z=1;!(p.words[0]&z)&&T<26;++T,z<<=1);if(T>0)for(p.iushrn(T);T-- >0;)(b.isOdd()||x.isOdd())&&(b.iadd(h),x.isub(_)),b.iushrn(1),x.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(b),d.isub(x)):(p.isub(w),b.isub(c),x.isub(d))}return{a:b,b:x,gcd:p.iushln(v)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var x=0,v=1;!(w.words[0]&v)&&x<26;++x,v<<=1);if(x>0)for(w.iushrn(x);x-- >0;)c.isOdd()&&c.iadd(b),c.iushrn(1);for(var h=0,_=1;!(p.words[0]&_)&&h<26;++h,_<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(b),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(d)):(p.isub(w),d.isub(c))}var M;return w.cmpn(1)===0?M=c:M=d,M.cmpn(0)<0&&M.iadd(l),M},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var c=0;w.isEven()&&p.isEven();c++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var b=w;w=p,p=b}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(c)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,c=1<>>26,x&=67108863,this.words[b]=x}return d!==0&&(this.words[b]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var c=this.words[0]|0;p=c===l?0:cl.length)return 1;if(this.length=0;p--){var c=this.words[p]|0,d=l.words[p]|0;if(c!==d){cd&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new C(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var U={k256:null,p224:null,p192:null,p25519:null};function k(R,l){this.name=R,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}k.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},k.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var c=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},k.prototype.split=function(l,w){l.iushrn(this.n,0,w)},k.prototype.imulK=function(l){return l.imul(this.k)};function B(){k.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(B,k),B.prototype.split=function(l,w){for(var p=4194303,c=Math.min(l.length,9),d=0;d>>22,b=x}b>>>=22,l.words[d-10]=b,b===0&&l.length>10?l.length-=10:l.length-=9},B.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=c}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(U[l])return U[l];var w;if(l==="k256")w=new B;else if(l==="p224")w=new j;else if(l==="p192")w=new V;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return U[l]=w,w};function C(R){if(typeof R=="string"){var l=n._prime(R);this.m=l.p,this.prime=l}else t(R.gtn(1),"modulus must be greater than 1"),this.m=R,this.prime=null}C.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},C.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},C.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},C.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},C.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},C.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},C.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},C.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},C.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},C.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},C.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},C.prototype.isqr=function(l){return this.imul(l,l.clone())},C.prototype.sqr=function(l){return this.mul(l,l)},C.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var c=this.m.subn(1),d=0;!c.isZero()&&c.andln(1)===0;)d++,c.iushrn(1);t(!c.isZero());var b=new n(1).toRed(this),x=b.redNeg(),v=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,v).cmp(x)!==0;)h.redIAdd(x);for(var _=this.pow(h,c),M=this.pow(l,c.addn(1).iushrn(1)),m=this.pow(l,c),T=d;m.cmp(b)!==0;){for(var z=m,E=0;z.cmp(b)!==0;E++)z=z.redSqr();t(E=0;d--){for(var _=w.words[d],M=h-1;M>=0;M--){var m=_>>M&1;if(b!==c[0]&&(b=this.sqr(b)),m===0&&x===0){v=0;continue}x<<=1,x|=m,v++,!(v!==p&&(d!==0||M!==0))&&(b=this.mul(b,c[x]),v=0,x=0)}h=26}return b},C.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},C.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(R){C.call(this,R),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,C),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof kd>"u"||kd,qb)});var zd=J(zb=>{"use strict";var Ef=zb;function SE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}Ef.toArray=SE;function Bb(r){return r.length===1?"0"+r:r}Ef.zero2=Bb;function kb(r){for(var e="",t=0;t{"use strict";var Pr=jb,IE=hi(),AE=Wi(),Sf=zd();Pr.assert=AE;Pr.toArray=Sf.toArray;Pr.zero2=Sf.zero2;Pr.toHex=Sf.toHex;Pr.encode=Sf.encode;function ME(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?a=(s>>1)-f:a=f,o.isubn(a)):a=0,i[n]=a,o.iushrn(1)}return i}Pr.getNAF=ME;function TE(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,a=e.andln(3)+n&3;o===3&&(o=-1),a===3&&(a=-1);var f;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&a===2?f=-o:f=o):f=0,t[0].push(f);var u;a&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?u=-a:u=a):u=0,t[1].push(u),2*i===f+1&&(i=1-i),2*n===u+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}Pr.getJSF=TE;function PE(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}Pr.cachedProperty=PE;function RE(r){return typeof r=="string"?Pr.toArray(r,"hex"):r}Pr.parseBytes=RE;function NE(r){return new IE(r,"hex","le")}Pr.intFromLE=NE});var $d=J((wC,Vd)=>{var jd;Vd.exports=function(e){return jd||(jd=new Zi(null)),jd.generate(e)};function Zi(r){this.rand=r}Vd.exports.Rand=Zi;Zi.prototype.generate=function(e){return this._rand(e)};Zi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var Wn=hi(),la=Yt(),If=la.getNAF,DE=la.getJSF,Af=la.assert;function en(r,e){this.type=r,this.p=new Wn(e.p,16),this.red=e.prime?Wn.red(e.prime):Wn.mont(this.p),this.zero=new Wn(0).toRed(this.red),this.one=new Wn(1).toRed(this.red),this.two=new Wn(2).toRed(this.red),this.n=e.n&&new Wn(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Kb.exports=en;en.prototype.point=function(){throw new Error("Not implemented")};en.prototype.validate=function(){throw new Error("Not implemented")};en.prototype._fixedNafMul=function(e,t){Af(e.precomputed);var i=e._getDoubles(),n=If(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];Af(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};en.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,P=g;if(o[A]!==1||o[P]!==1){f[A]=If(i[A],o[A],this._bitLength),f[P]=If(i[P],o[P],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[P].length,u);continue}var O=[t[A],null,null,t[P]];t[A].y.cmp(t[P].y)===0?(O[1]=t[A].add(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg())):t[A].y.cmp(t[P].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].add(t[P].neg())):(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=DE(i[A],i[P]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[P]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var C=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};dr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var CE=Yt(),nt=hi(),Hd=sa(),Gs=pa(),OE=CE.assert;function lr(r){Gs.call(this,"short",r),this.a=new nt(r.a,16).toRed(this.red),this.b=new nt(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Hd(lr,Gs);Vb.exports=lr;lr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new nt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new nt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],OE(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new nt(a.a,16),b:new nt(a.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};lr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:nt.mont(e),i=new nt(2).toRed(t).redInvm(),n=i.redNeg(),s=new nt(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]};lr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new nt(1),o=new nt(0),a=new nt(0),f=new nt(1),u,g,y,S,I,A,P,O=0,N,U;i.cmpn(0)!==0;){var k=n.div(i);N=n.sub(k.mul(i)),U=a.sub(k.mul(s));var B=f.sub(k.mul(o));if(!y&&N.cmp(t)<0)u=P.neg(),g=s,y=N.neg(),S=U;else if(y&&++O===2)break;P=N,n=i,i=N,a=s,s=U,f=o,o=B}I=N.neg(),A=U;var j=y.sqr().add(S.sqr()),V=I.sqr().add(A.sqr());return V.cmp(j)>=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};lr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};lr.prototype.pointFromX=function(e,t){e=new nt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};lr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};lr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};gt.prototype.isInfinity=function(){return this.inf};gt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};gt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};gt.prototype.getX=function(){return this.x.fromRed()};gt.prototype.getY=function(){return this.y.fromRed()};gt.prototype.mul=function(e){return e=new nt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};gt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};gt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};gt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};gt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};gt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Et(r,e,t,i){Gs.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nt(0)):(this.x=new nt(e,16),this.y=new nt(t,16),this.z=new nt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Hd(Et,Gs.BasePoint);lr.prototype.jpoint=function(e,t,i){return new Et(this,e,t,i)};Et.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};Et.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Et.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,P)};Et.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};Et.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};Et.prototype.inspect=function(){return this.isInfinity()?"":""};Et.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Wb=J((EC,Gb)=>{"use strict";var Ws=hi(),Hb=sa(),Mf=pa(),LE=Yt();function Js(r){Mf.call(this,"mont",r),this.a=new Ws(r.a,16).toRed(this.red),this.b=new Ws(r.b,16).toRed(this.red),this.i4=new Ws(4).toRed(this.red).redInvm(),this.two=new Ws(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Hb(Js,Mf);Gb.exports=Js;Js.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function mt(r,e,t){Mf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Ws(e,16),this.z=new Ws(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Hb(mt,Mf.BasePoint);Js.prototype.decodePoint=function(e,t){return this.point(LE.toArray(e,t),1)};Js.prototype.point=function(e,t){return new mt(this,e,t)};Js.prototype.pointFromJSON=function(e){return mt.fromJSON(this,e)};mt.prototype.precompute=function(){};mt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};mt.fromJSON=function(e,t){return new mt(e,t[0],t[1]||e.one)};mt.prototype.inspect=function(){return this.isInfinity()?"":""};mt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};mt.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)};mt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),f=s.redMul(n),u=t.z.redMul(a.redAdd(f).redSqr()),g=t.x.redMul(a.redISub(f).redSqr());return this.curve.point(u,g)};mt.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};mt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};mt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};mt.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Xb=J((SC,Yb)=>{"use strict";var FE=Yt(),Ci=hi(),Jb=sa(),Tf=pa(),UE=FE.assert;function di(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,Tf.call(this,"edwards",r),this.a=new Ci(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Ci(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Ci(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),UE(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Jb(di,Tf);Yb.exports=di;di.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};di.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};di.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};di.prototype.pointFromX=function(e,t){e=new Ci(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var f=a.fromRed().isOdd();return(t&&!f||!t&&f)&&(a=a.redNeg()),this.point(e,a)};di.prototype.pointFromY=function(e,t){e=new Ci(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)};di.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ye(r,e,t,i,n){Tf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Ci(e,16),this.y=new Ci(t,16),this.z=i?new Ci(i,16):this.curve.one,this.t=n&&new Ci(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Jb(Ye,Tf.BasePoint);di.prototype.pointFromJSON=function(e){return Ye.fromJSON(this,e)};di.prototype.point=function(e,t,i,n){return new Ye(this,e,t,i,n)};Ye.fromJSON=function(e,t){return new Ye(e,t[0],t[1],t[2])};Ye.prototype.inspect=function(){return this.isInfinity()?"":""};Ye.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ye.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(i),f=n.redSub(t),u=s.redMul(a),g=o.redMul(f),y=s.redMul(f),S=a.redMul(o);return this.curve.point(u,g,S,y)};Ye.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,f,u;if(this.curve.twisted){a=this.curve._mulA(t);var g=a.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(g.redSub(this.curve.two)),s=g.redMul(a.redSub(i)),o=g.redSqr().redSub(g).redSub(g)):(f=this.z.redSqr(),u=g.redSub(f).redISub(f),n=e.redSub(t).redISub(i).redMul(u),s=g.redMul(a.redSub(i)),o=g.redMul(u))}else a=t.redAdd(i),f=this.curve._mulC(this.z).redSqr(),u=a.redSub(f).redSub(f),n=this.curve._mulC(e.redISub(a)).redMul(u),s=this.curve._mulC(a).redMul(t.redISub(i)),o=a.redMul(u);return this.curve.point(n,s,o)};Ye.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ye.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),a=s.redSub(n),f=s.redAdd(n),u=i.redAdd(t),g=o.redMul(a),y=f.redMul(u),S=o.redMul(u),I=a.redMul(f);return this.curve.point(g,y,I,S)};Ye.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),f=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),g=t.redMul(a).redMul(u),y,S;return this.curve.twisted?(y=t.redMul(f).redMul(s.redSub(this.curve._mulA(n))),S=a.redMul(f)):(y=t.redMul(f).redMul(s.redSub(n)),S=this.curve._mulC(a).redMul(f)),this.curve.point(g,y,S)};Ye.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ye.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ye.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ye.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ye.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ye.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ye.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ye.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ye.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ye.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ye.prototype.toP=Ye.prototype.normalize;Ye.prototype.mixedAdd=Ye.prototype.add});var Gd=J(Qb=>{"use strict";var Pf=Qb;Pf.base=pa();Pf.short=$b();Pf.mont=Wb();Pf.edwards=Xb()});var ev=J((AC,Zb)=>{Zb.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var Rf=J(iv=>{"use strict";var Jd=iv,tn=ca(),Wd=Gd(),qE=Yt(),tv=qE.assert;function rv(r){r.type==="short"?this.curve=new Wd.short(r):r.type==="edwards"?this.curve=new Wd.edwards(r):this.curve=new Wd.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,tv(this.g.validate(),"Invalid curve"),tv(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}Jd.PresetCurve=rv;function rn(r,e){Object.defineProperty(Jd,r,{configurable:!0,enumerable:!0,get:function(){var t=new rv(e);return Object.defineProperty(Jd,r,{configurable:!0,enumerable:!0,value:t}),t}})}rn("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:tn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});rn("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:tn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});rn("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:tn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});rn("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:tn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});rn("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:tn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});rn("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:tn.sha256,gRed:!1,g:["9"]});rn("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:tn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var Yd;try{Yd=ev()}catch{Yd=void 0}rn("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:tn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",Yd]})});var ov=J((TC,sv)=>{"use strict";var BE=ca(),Jn=zd(),nv=Wi();function nn(r){if(!(this instanceof nn))return new nn(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Jn.toArray(r.entropy,r.entropyEnc||"hex"),t=Jn.toArray(r.nonce,r.nonceEnc||"hex"),i=Jn.toArray(r.pers,r.persEnc||"hex");nv(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}sv.exports=nn;nn.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};nn.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Jn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var kE=hi(),zE=Yt(),Xd=zE.assert;function Dt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}av.exports=Dt;Dt.fromPublic=function(e,t,i){return t instanceof Dt?t:new Dt(e,{pub:t,pubEnc:i})};Dt.fromPrivate=function(e,t,i){return t instanceof Dt?t:new Dt(e,{priv:t,privEnc:i})};Dt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Dt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};Dt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Dt.prototype._importPrivate=function(e,t){this.priv=new kE(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};Dt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Xd(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Xd(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};Dt.prototype.derive=function(e){return e.validate()||Xd(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Dt.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};Dt.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};Dt.prototype.inspect=function(){return""}});var hv=J((RC,uv)=>{"use strict";var Nf=hi(),el=Yt(),jE=el.assert;function Df(r,e){if(r instanceof Df)return r;this._importDER(r,e)||(jE(r.r&&r.s,"Signature without r or s"),this.r=new Nf(r.r,16),this.s=new Nf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}uv.exports=Df;function KE(){this.place=0}function Qd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function fv(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Df.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=fv(t),i=fv(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Zd(n,t.length),n=n.concat(t),n.push(2),Zd(n,i.length);var s=n.concat(i),o=[48];return Zd(o,s.length),o=o.concat(s),el.encode(o,e)}});var gv=J((NC,pv)=>{"use strict";var Yn=hi(),dv=ov(),VE=Yt(),tl=Rf(),$E=$d(),lv=VE.assert,rl=cv(),Cf=hv();function pr(r){if(!(this instanceof pr))return new pr(r);typeof r=="string"&&(lv(Object.prototype.hasOwnProperty.call(tl,r),"Unknown curve "+r),r=tl[r]),r instanceof tl.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}pv.exports=pr;pr.prototype.keyPair=function(e){return new rl(this,e)};pr.prototype.keyFromPrivate=function(e,t){return rl.fromPrivate(this,e,t)};pr.prototype.keyFromPublic=function(e,t){return rl.fromPublic(this,e,t)};pr.prototype.genKeyPair=function(e){e||(e={});for(var t=new dv({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||$E(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Yn(2));;){var s=new Yn(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};pr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};pr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Yn(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new dv({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Yn(1)),g=0;;g++){var y=n.k?n.k(g):new Yn(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var P=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(P=P.umod(this.n),P.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),O^=1),new Cf({r:A,s:P,recoveryParam:O})}}}}}};pr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Yn(e,16)),i=this.keyFromPublic(i,n),t=new Cf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};pr.prototype.recoverPubKey=function(r,e,t,i){lv((3&t)===t,"The recovery param is more than two bits"),e=new Cf(e,i);var n=this.n,s=new Yn(r),o=e.r,a=e.s,f=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};pr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Cf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var yv=J((DC,vv)=>{"use strict";var ga=Yt(),bv=ga.assert,mv=ga.parseBytes,Ys=ga.cachedProperty;function bt(r,e){this.eddsa=r,this._secret=mv(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=mv(e.pub)}bt.fromPublic=function(e,t){return t instanceof bt?t:new bt(e,{pub:t})};bt.fromSecret=function(e,t){return t instanceof bt?t:new bt(e,{secret:t})};bt.prototype.secret=function(){return this._secret};Ys(bt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});Ys(bt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});Ys(bt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});Ys(bt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});Ys(bt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});Ys(bt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});bt.prototype.sign=function(e){return bv(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};bt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};bt.prototype.getSecret=function(e){return bv(this._secret,"KeyPair is public only"),ga.encode(this.secret(),e)};bt.prototype.getPublic=function(e){return ga.encode(this.pubBytes(),e)};vv.exports=bt});var _v=J((CC,xv)=>{"use strict";var HE=hi(),Of=Yt(),wv=Of.assert,Lf=Of.cachedProperty,GE=Of.parseBytes;function Xn(r,e){this.eddsa=r,typeof e!="object"&&(e=GE(e)),Array.isArray(e)&&(wv(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),wv(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof HE&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}Lf(Xn,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});Lf(Xn,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});Lf(Xn,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});Lf(Xn,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Xn.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Xn.prototype.toHex=function(){return Of.encode(this.toBytes(),"hex").toUpperCase()};xv.exports=Xn});var Mv=J((OC,Av)=>{"use strict";var WE=ca(),JE=Rf(),Xs=Yt(),YE=Xs.assert,Sv=Xs.parseBytes,Iv=yv(),Ev=_v();function Kt(r){if(YE(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Kt))return new Kt(r);r=JE[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=WE.sha512}Av.exports=Kt;Kt.prototype.sign=function(e,t){e=Sv(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),f=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:f,Rencoded:o})};Kt.prototype.verify=function(e,t,i){if(e=Sv(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),a=t.R().add(n.pub().mul(s));return a.eq(o)};Kt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Qn=Tv;Qn.version=Ub().version;Qn.utils=Yt();Qn.rand=$d();Qn.curve=Gd();Qn.curves=Rf();Qn.ec=gv();Qn.eddsa=Mv()});var qy=J(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.isBrowserCryptoAvailable=fn.getSubtleCrypto=fn.getBrowerCrypto=void 0;function Pl(){return(global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}fn.getBrowerCrypto=Pl;function Uy(){let r=Pl();return r.subtle||r.webkitSubtle}fn.getSubtleCrypto=Uy;function d7(){return!!Pl()&&!!Uy()}fn.isBrowserCryptoAvailable=d7});var zy=J(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.isBrowser=un.isNode=un.isReactNative=void 0;function By(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}un.isReactNative=By;function ky(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}un.isNode=ky;function l7(){return!By()&&!ky()}un.isBrowser=l7});var Rl=J(Wf=>{"use strict";Object.defineProperty(Wf,"__esModule",{value:!0});var jy=(vs(),Ao(bs));jy.__exportStar(qy(),Wf);jy.__exportStar(zy(),Wf)});var Jy=J((mO,Wy)=>{"use strict";Wy.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var Cw=J((Da,ho)=>{var I7=200,Vl="__lodash_hash_undefined__",cu=1,uw=2,hw=9007199254740991,tu="[object Arguments]",Ul="[object Array]",A7="[object AsyncFunction]",dw="[object Boolean]",lw="[object Date]",pw="[object Error]",gw="[object Function]",M7="[object GeneratorFunction]",ru="[object Map]",mw="[object Number]",T7="[object Null]",uo="[object Object]",Zy="[object Promise]",P7="[object Proxy]",bw="[object RegExp]",iu="[object Set]",vw="[object String]",R7="[object Symbol]",N7="[object Undefined]",ql="[object WeakMap]",yw="[object ArrayBuffer]",nu="[object DataView]",D7="[object Float32Array]",C7="[object Float64Array]",O7="[object Int8Array]",L7="[object Int16Array]",F7="[object Int32Array]",U7="[object Uint8Array]",q7="[object Uint8ClampedArray]",B7="[object Uint16Array]",k7="[object Uint32Array]",z7=/[\\^$.*+?()[\]{}|]/g,j7=/^\[object .+?Constructor\]$/,K7=/^(?:0|[1-9]\d*)$/,Ze={};Ze[D7]=Ze[C7]=Ze[O7]=Ze[L7]=Ze[F7]=Ze[U7]=Ze[q7]=Ze[B7]=Ze[k7]=!0;Ze[tu]=Ze[Ul]=Ze[yw]=Ze[dw]=Ze[nu]=Ze[lw]=Ze[pw]=Ze[gw]=Ze[ru]=Ze[mw]=Ze[uo]=Ze[bw]=Ze[iu]=Ze[vw]=Ze[ql]=!1;var ww=typeof global=="object"&&global&&global.Object===Object&&global,V7=typeof self=="object"&&self&&self.Object===Object&&self,Ui=ww||V7||Function("return this")(),xw=typeof Da=="object"&&Da&&!Da.nodeType&&Da,ew=xw&&typeof ho=="object"&&ho&&!ho.nodeType&&ho,_w=ew&&ew.exports===xw,Ol=_w&&ww.process,tw=function(){try{return Ol&&Ol.binding&&Ol.binding("util")}catch{}}(),rw=tw&&tw.isTypedArray;function $7(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function xS(r,e){var t=this.__data__,i=uu(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}qi.prototype.clear=bS;qi.prototype.delete=vS;qi.prototype.get=yS;qi.prototype.has=wS;qi.prototype.set=xS;function os(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ea))return!1;var u=s.get(r);if(u&&s.get(e))return u==e;var g=-1,y=!0,S=t&uw?new ou:void 0;for(s.set(r,e),s.set(e,r);++g-1&&r%1==0&&r-1&&r%1==0&&r<=hw}function Nw(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function La(r){return r!=null&&typeof r=="object"}var Dw=rw?J7(rw):qS;function QS(r){return YS(r)?OS(r):BS(r)}function ZS(){return[]}function eI(){return!1}ho.exports=XS});var N2=J((QL,R2)=>{R2.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var vn=J(fs=>{var U0,LM=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];fs.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};fs.getSymbolTotalCodewords=function(e){return LM[e]};fs.getBCHDigit=function(r){let e=0;for(;r!==0;)e++,r>>>=1;return e};fs.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');U0=e};fs.isKanjiModeEnabled=function(){return typeof U0<"u"};fs.toSJIS=function(e){return U0(e)}});var _u=J(br=>{br.L={bit:1};br.M={bit:0};br.Q={bit:3};br.H={bit:2};function FM(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return br.L;case"m":case"medium":return br.M;case"q":case"quartile":return br.Q;case"h":case"high":return br.H;default:throw new Error("Unknown EC Level: "+r)}}br.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4};br.from=function(e,t){if(br.isValid(e))return e;try{return FM(e)}catch{return t}}});var O2=J((tF,C2)=>{function D2(){this.buffer=[],this.length=0}D2.prototype={get:function(r){let e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(let t=0;t>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};C2.exports=D2});var F2=J((rF,L2)=>{function za(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}za.prototype.set=function(r,e,t,i){let n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};za.prototype.get=function(r,e){return this.data[r*this.size+e]};za.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};za.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};L2.exports=za});var U2=J(Eu=>{var UM=vn().getSymbolSize;Eu.getRowColCoords=function(e){if(e===1)return[];let t=Math.floor(e/7)+2,i=UM(e),n=i===145?26:Math.ceil((i-13)/(2*t-2))*2,s=[i-7];for(let o=1;o{var qM=vn().getSymbolSize,q2=7;B2.getPositions=function(e){let t=qM(e);return[[0,0],[t-q2,0],[0,t-q2]]}});var z2=J(Xe=>{Xe.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var us={N1:3,N2:3,N3:40,N4:10};Xe.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7};Xe.from=function(e){return Xe.isValid(e)?parseInt(e,10):void 0};Xe.getPenaltyN1=function(e){let t=e.size,i=0,n=0,s=0,o=null,a=null;for(let f=0;f=5&&(i+=us.N1+(n-5)),o=g,n=1),g=e.get(u,f),g===a?s++:(s>=5&&(i+=us.N1+(s-5)),a=g,s=1)}n>=5&&(i+=us.N1+(n-5)),s>=5&&(i+=us.N1+(s-5))}return i};Xe.getPenaltyN2=function(e){let t=e.size,i=0;for(let n=0;n=10&&(n===1488||n===93)&&i++,s=s<<1&2047|e.get(a,o),a>=10&&(s===1488||s===93)&&i++}return i*us.N3};Xe.getPenaltyN4=function(e){let t=0,i=e.data.length;for(let s=0;s{var yn=_u(),Su=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Iu=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];q0.getBlocksCount=function(e,t){switch(t){case yn.L:return Su[(e-1)*4+0];case yn.M:return Su[(e-1)*4+1];case yn.Q:return Su[(e-1)*4+2];case yn.H:return Su[(e-1)*4+3];default:return}};q0.getTotalCodewordsCount=function(e,t){switch(t){case yn.L:return Iu[(e-1)*4+0];case yn.M:return Iu[(e-1)*4+1];case yn.Q:return Iu[(e-1)*4+2];case yn.H:return Iu[(e-1)*4+3];default:return}}});var j2=J(Mu=>{var ja=new Uint8Array(512),Au=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)ja[t]=e,Au[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)ja[t]=ja[t-255]})();Mu.log=function(e){if(e<1)throw new Error("log("+e+")");return Au[e]};Mu.exp=function(e){return ja[e]};Mu.mul=function(e,t){return e===0||t===0?0:ja[Au[e]+Au[t]]}});var K2=J(Ka=>{var k0=j2();Ka.mul=function(e,t){let i=new Uint8Array(e.length+t.length-1);for(let n=0;n=0;){let n=i[0];for(let o=0;o{var V2=K2();function z0(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}z0.prototype.initialize=function(e){this.degree=e,this.genPoly=V2.generateECPolynomial(this.degree)};z0.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let i=V2.mod(t,this.genPoly),n=this.degree-i.length;if(n>0){let s=new Uint8Array(this.degree);return s.set(i,n),s}return i};$2.exports=z0});var j0=J(G2=>{G2.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}});var K0=J(zi=>{var W2="[0-9]+",kM="[A-Z $%*+\\-./:]+",Va="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Va=Va.replace(/u/g,"\\u");var zM="(?:(?![A-Z0-9 $%*+\\-./:]|"+Va+`)(?:.|[\r -]))+`;zi.KANJI=new RegExp(Va,"g");zi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");zi.BYTE=new RegExp(zM,"g");zi.NUMERIC=new RegExp(W2,"g");zi.ALPHANUMERIC=new RegExp(kM,"g");var jM=new RegExp("^"+Va+"$"),KM=new RegExp("^"+W2+"$"),VM=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");zi.testKanji=function(e){return jM.test(e)};zi.testNumeric=function(e){return KM.test(e)};zi.testAlphanumeric=function(e){return VM.test(e)}});var wn=J(ht=>{var $M=j0(),V0=K0();ht.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};ht.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};ht.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};ht.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};ht.MIXED={bit:-1};ht.getCharCountIndicator=function(e,t){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!$M.isValid(t))throw new Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]};ht.getBestModeForData=function(e){return V0.testNumeric(e)?ht.NUMERIC:V0.testAlphanumeric(e)?ht.ALPHANUMERIC:V0.testKanji(e)?ht.KANJI:ht.BYTE};ht.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")};ht.isValid=function(e){return e&&e.bit&&e.ccBits};function HM(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return ht.NUMERIC;case"alphanumeric":return ht.ALPHANUMERIC;case"kanji":return ht.KANJI;case"byte":return ht.BYTE;default:throw new Error("Unknown mode: "+r)}}ht.from=function(e,t){if(ht.isValid(e))return e;try{return HM(e)}catch{return t}}});var Z2=J(hs=>{var Tu=vn(),GM=B0(),J2=_u(),xn=wn(),$0=j0(),X2=7973,Y2=Tu.getBCHDigit(X2);function WM(r,e,t){for(let i=1;i<=40;i++)if(e<=hs.getCapacity(i,t,r))return i}function Q2(r,e){return xn.getCharCountIndicator(r,e)+4}function JM(r,e){let t=0;return r.forEach(function(i){let n=Q2(i.mode,e);t+=n+i.getBitsLength()}),t}function YM(r,e){for(let t=1;t<=40;t++)if(JM(r,t)<=hs.getCapacity(t,e,xn.MIXED))return t}hs.from=function(e,t){return $0.isValid(e)?parseInt(e,10):t};hs.getCapacity=function(e,t,i){if(!$0.isValid(e))throw new Error("Invalid QR Code version");typeof i>"u"&&(i=xn.BYTE);let n=Tu.getSymbolTotalCodewords(e),s=GM.getTotalCodewordsCount(e,t),o=(n-s)*8;if(i===xn.MIXED)return o;let a=o-Q2(i,e);switch(i){case xn.NUMERIC:return Math.floor(a/10*3);case xn.ALPHANUMERIC:return Math.floor(a/11*2);case xn.KANJI:return Math.floor(a/13);case xn.BYTE:default:return Math.floor(a/8)}};hs.getBestVersionForData=function(e,t){let i,n=J2.from(t,J2.M);if(Array.isArray(e)){if(e.length>1)return YM(e,n);if(e.length===0)return 1;i=e[0]}else i=e;return WM(i.mode,i.getLength(),n)};hs.getEncodedBits=function(e){if(!$0.isValid(e)||e<7)throw new Error("Invalid QR Code version");let t=e<<12;for(;Tu.getBCHDigit(t)-Y2>=0;)t^=X2<{var H0=vn(),t3=1335,XM=21522,e3=H0.getBCHDigit(t3);r3.getEncodedBits=function(e,t){let i=e.bit<<3|t,n=i<<10;for(;H0.getBCHDigit(n)-e3>=0;)n^=t3<{var QM=wn();function wo(r){this.mode=QM.NUMERIC,this.data=r.toString()}wo.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};wo.prototype.getLength=function(){return this.data.length};wo.prototype.getBitsLength=function(){return wo.getBitsLength(this.data.length)};wo.prototype.write=function(e){let t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);let s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};n3.exports=wo});var a3=J((mF,o3)=>{var ZM=wn(),G0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function xo(r){this.mode=ZM.ALPHANUMERIC,this.data=r}xo.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};xo.prototype.getLength=function(){return this.data.length};xo.prototype.getBitsLength=function(){return xo.getBitsLength(this.data.length)};xo.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let i=G0.indexOf(this.data[t])*45;i+=G0.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(G0.indexOf(this.data[t]),6)};o3.exports=xo});var f3=J((bF,c3)=>{var eT=wn();function _o(r){this.mode=eT.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}_o.getBitsLength=function(e){return e*8};_o.prototype.getLength=function(){return this.data.length};_o.prototype.getBitsLength=function(){return _o.getBitsLength(this.data.length)};_o.prototype.write=function(r){for(let e=0,t=this.data.length;e{var tT=wn(),rT=vn();function Eo(r){this.mode=tT.KANJI,this.data=r}Eo.getBitsLength=function(e){return e*13};Eo.prototype.getLength=function(){return this.data.length};Eo.prototype.getBitsLength=function(){return Eo.getBitsLength(this.data.length)};Eo.prototype.write=function(r){let e;for(e=0;e=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` -Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};u3.exports=Eo});var d3=J((yF,W0)=>{"use strict";var $a={single_source_shortest_paths:function(r,e,t){var i={},n={};n[e]=0;var s=$a.PriorityQueue.make();s.push(e,0);for(var o,a,f,u,g,y,S,I,A;!s.empty();){o=s.pop(),a=o.value,u=o.cost,g=r[a]||{};for(f in g)g.hasOwnProperty(f)&&(y=g[f],S=u+y,I=n[f],A=typeof n[f]>"u",(A||I>S)&&(n[f]=S,s.push(f,S),i[f]=a))}if(typeof t<"u"&&typeof n[t]>"u"){var P=["Could not find a path from ",e," to ",t,"."].join("");throw new Error(P)}return i},extract_shortest_path_from_predecessor_list:function(r,e){for(var t=[],i=e,n;i;)t.push(i),n=r[i],i=r[i];return t.reverse(),t},find_path:function(r,e,t){var i=$a.single_source_shortest_paths(r,e,t);return $a.extract_shortest_path_from_predecessor_list(i,t)},PriorityQueue:{make:function(r){var e=$a.PriorityQueue,t={},i;r=r||{};for(i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.queue=[],t.sorter=r.sorter||e.default_sorter,t},default_sorter:function(r,e){return r.cost-e.cost},push:function(r,e){var t={value:r,cost:e};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof W0<"u"&&(W0.exports=$a)});var w3=J(So=>{var je=wn(),g3=s3(),m3=a3(),b3=f3(),v3=h3(),Ha=K0(),Pu=vn(),iT=d3();function l3(r){return unescape(encodeURIComponent(r)).length}function Ga(r,e,t){let i=[],n;for(;(n=r.exec(t))!==null;)i.push({data:n[0],index:n.index,mode:e,length:n[0].length});return i}function y3(r){let e=Ga(Ha.NUMERIC,je.NUMERIC,r),t=Ga(Ha.ALPHANUMERIC,je.ALPHANUMERIC,r),i,n;return Pu.isKanjiModeEnabled()?(i=Ga(Ha.BYTE,je.BYTE,r),n=Ga(Ha.KANJI,je.KANJI,r)):(i=Ga(Ha.BYTE_KANJI,je.BYTE,r),n=[]),e.concat(t,i,n).sort(function(o,a){return o.index-a.index}).map(function(o){return{data:o.data,mode:o.mode,length:o.length}})}function J0(r,e){switch(e){case je.NUMERIC:return g3.getBitsLength(r);case je.ALPHANUMERIC:return m3.getBitsLength(r);case je.KANJI:return v3.getBitsLength(r);case je.BYTE:return b3.getBitsLength(r)}}function nT(r){return r.reduce(function(e,t){let i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function sT(r){let e=[];for(let t=0;t{var Nu=vn(),Y0=_u(),aT=O2(),cT=F2(),fT=U2(),uT=k2(),Z0=z2(),ep=B0(),hT=H2(),Ru=Z2(),dT=i3(),lT=wn(),X0=w3();function pT(r,e){let t=r.size,i=uT.getPositions(e);for(let n=0;n=0&&a<=6&&(f===0||f===6)||f>=0&&f<=6&&(a===0||a===6)||a>=2&&a<=4&&f>=2&&f<=4?r.set(s+a,o+f,!0,!0):r.set(s+a,o+f,!1,!0))}}function gT(r){let e=r.size;for(let t=8;t>a&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function Q0(r,e,t){let i=r.size,n=dT.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function vT(r,e){let t=r.size,i=-1,n=t-1,s=7,o=0;for(let a=t-1;a>0;a-=2)for(a===6&&a--;;){for(let f=0;f<2;f++)if(!r.isReserved(n,a-f)){let u=!1;o>>s&1)===1),r.set(n,a-f,u),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function yT(r,e,t){let i=new aT;t.forEach(function(f){i.put(f.mode.bit,4),i.put(f.getLength(),lT.getCharCountIndicator(f.mode,r)),f.write(i)});let n=Nu.getSymbolTotalCodewords(r),s=ep.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);let a=(o-i.getLengthInBits())/8;for(let f=0;ftypeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var e6=(r,e)=>()=>(r&&(e=r(r=0)),e);var J=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),qt=(r,e)=>{for(var t in e)tc(r,t,{get:e[t],enumerable:!0})},ec=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of X3(e))!Z3.call(r,n)&&n!==t&&tc(r,n,{get:()=>e[n],enumerable:!(i=Y3(e,n))||i.enumerable});return r},Ht=(r,e,t)=>(ec(r,e,"default"),t&&ec(t,e,"default")),Be=(r,e,t)=>(t=r!=null?J3(Q3(r)):{},ec(e||!r||!r.__esModule?tc(t,"default",{value:r,enumerable:!0}):t,r)),No=r=>ec(tc({},"__esModule",{value:!0}),r);var kn=J((NR,Xu)=>{"use strict";var xs=typeof Reflect=="object"?Reflect:null,Fp=xs&&typeof xs.apply=="function"?xs.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},pc;xs&&typeof xs.ownKeys=="function"?pc=xs.ownKeys:Object.getOwnPropertySymbols?pc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pc=function(e){return Object.getOwnPropertyNames(e)};var qp=Number.isNaN||function(e){return e!==e};function $e(){$e.init.call(this)}Xu.exports=$e;Xu.exports.once=h6;$e.EventEmitter=$e;$e.prototype._events=void 0;$e.prototype._eventsCount=0;$e.prototype._maxListeners=void 0;var Up=10;function gc(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty($e,"defaultMaxListeners",{enumerable:!0,get:function(){return Up},set:function(r){if(typeof r!="number"||r<0||qp(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Up=r}});$e.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};$e.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||qp(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Bp(r){return r._maxListeners===void 0?$e.defaultMaxListeners:r._maxListeners}$e.prototype.getMaxListeners=function(){return Bp(this)};$e.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")Fp(f,this,t);else for(var u=f.length,g=Vp(f,u),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=o.length}return r}$e.prototype.addListener=function(e,t){return kp(this,e,t,!1)};$e.prototype.on=$e.prototype.addListener;$e.prototype.prependListener=function(e,t){return kp(this,e,t,!0)};function c6(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function zp(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=c6.bind(i);return n.listener=t,i.wrapFn=n,n}$e.prototype.once=function(e,t){return gc(t),this.on(e,zp(this,e,t)),this};$e.prototype.prependOnceListener=function(e,t){return gc(t),this.prependListener(e,zp(this,e,t)),this};$e.prototype.removeListener=function(e,t){var i,n,s,o,a;if(gc(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():f6(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};$e.prototype.off=$e.prototype.removeListener;$e.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function jp(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?u6(n):Vp(n,n.length)}$e.prototype.listeners=function(e){return jp(this,e,!0)};$e.prototype.rawListeners=function(e){return jp(this,e,!1)};$e.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Kp.call(r,e)};$e.prototype.listenerCount=Kp;function Kp(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}$e.prototype.eventNames=function(){return this._eventsCount>0?pc(this._events):[]};function Vp(r,e){for(var t=new Array(e),i=0;iZu,__asyncDelegator:()=>I6,__asyncGenerator:()=>S6,__asyncValues:()=>A6,__await:()=>Bo,__awaiter:()=>v6,__classPrivateFieldGet:()=>P6,__classPrivateFieldSet:()=>N6,__createBinding:()=>w6,__decorate:()=>g6,__exportStar:()=>x6,__extends:()=>l6,__generator:()=>y6,__importDefault:()=>R6,__importStar:()=>M6,__makeTemplateObject:()=>T6,__metadata:()=>b6,__param:()=>m6,__read:()=>Hp,__rest:()=>p6,__spread:()=>_6,__spreadArrays:()=>E6,__values:()=>eh});function l6(r,e){Qu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function p6(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;a--)(o=r[a])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function m6(r,e){return function(t,i){e(t,i,r)}}function b6(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function v6(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(g){try{u(i.next(g))}catch(y){o(y)}}function f(g){try{u(i.throw(g))}catch(y){o(y)}}function u(g){g.done?s(g.value):n(g.value).then(a,f)}u((i=i.apply(r,e||[])).next())})}function y6(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(g){return f([u,g])}}function f(u){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Hp(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function _6(){for(var r=[],e=0;e1||a(S,I)})})}function a(S,I){try{f(i[S](I))}catch(A){y(s[0][3],A)}}function f(S){S.value instanceof Bo?Promise.resolve(S.value.v).then(u,g):y(s[0][2],S)}function u(S){a("next",S)}function g(S){a("throw",S)}function y(S,I){S(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function I6(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Bo(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function A6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof eh=="function"?eh(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(a,f){o=r[s](o),n(a,f,o.done,o.value)})}}function n(s,o,a,f){Promise.resolve(f).then(function(u){s({value:u,done:a})},o)}}function T6(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function M6(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function R6(r){return r&&r.__esModule?r:{default:r}}function P6(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function N6(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var Qu,Zu,Es=e6(()=>{Qu=function(r,e){return Qu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},Qu(r,e)};Zu=function(){return Zu=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});mc.delay=void 0;function C6(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}mc.delay=C6});var Wp=J(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.ONE_THOUSAND=Ss.ONE_HUNDRED=void 0;Ss.ONE_HUNDRED=100;Ss.ONE_THOUSAND=1e3});var Jp=J(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.ONE_YEAR=Z.FOUR_WEEKS=Z.THREE_WEEKS=Z.TWO_WEEKS=Z.ONE_WEEK=Z.THIRTY_DAYS=Z.SEVEN_DAYS=Z.FIVE_DAYS=Z.THREE_DAYS=Z.ONE_DAY=Z.TWENTY_FOUR_HOURS=Z.TWELVE_HOURS=Z.SIX_HOURS=Z.THREE_HOURS=Z.ONE_HOUR=Z.SIXTY_MINUTES=Z.THIRTY_MINUTES=Z.TEN_MINUTES=Z.FIVE_MINUTES=Z.ONE_MINUTE=Z.SIXTY_SECONDS=Z.THIRTY_SECONDS=Z.TEN_SECONDS=Z.FIVE_SECONDS=Z.ONE_SECOND=void 0;Z.ONE_SECOND=1;Z.FIVE_SECONDS=5;Z.TEN_SECONDS=10;Z.THIRTY_SECONDS=30;Z.SIXTY_SECONDS=60;Z.ONE_MINUTE=Z.SIXTY_SECONDS;Z.FIVE_MINUTES=Z.ONE_MINUTE*5;Z.TEN_MINUTES=Z.ONE_MINUTE*10;Z.THIRTY_MINUTES=Z.ONE_MINUTE*30;Z.SIXTY_MINUTES=Z.ONE_MINUTE*60;Z.ONE_HOUR=Z.SIXTY_MINUTES;Z.THREE_HOURS=Z.ONE_HOUR*3;Z.SIX_HOURS=Z.ONE_HOUR*6;Z.TWELVE_HOURS=Z.ONE_HOUR*12;Z.TWENTY_FOUR_HOURS=Z.ONE_HOUR*24;Z.ONE_DAY=Z.TWENTY_FOUR_HOURS;Z.THREE_DAYS=Z.ONE_DAY*3;Z.FIVE_DAYS=Z.ONE_DAY*5;Z.SEVEN_DAYS=Z.ONE_DAY*7;Z.THIRTY_DAYS=Z.ONE_DAY*30;Z.ONE_WEEK=Z.SEVEN_DAYS;Z.TWO_WEEKS=Z.ONE_WEEK*2;Z.THREE_WEEKS=Z.ONE_WEEK*3;Z.FOUR_WEEKS=Z.ONE_WEEK*4;Z.ONE_YEAR=Z.ONE_DAY*365});var th=J(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var Yp=(Es(),No(_s));Yp.__exportStar(Wp(),bc);Yp.__exportStar(Jp(),bc)});var Qp=J(Is=>{"use strict";Object.defineProperty(Is,"__esModule",{value:!0});Is.fromMiliseconds=Is.toMiliseconds=void 0;var Xp=th();function D6(r){return r*Xp.ONE_THOUSAND}Is.toMiliseconds=D6;function O6(r){return Math.floor(r/Xp.ONE_THOUSAND)}Is.fromMiliseconds=O6});var eg=J(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var Zp=(Es(),No(_s));Zp.__exportStar(Gp(),vc);Zp.__exportStar(Qp(),vc)});var tg=J(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.Watch=void 0;var yc=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};ko.Watch=yc;ko.default=yc});var rg=J(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.IWatch=void 0;var rh=class{};wc.IWatch=rh});var ig=J(ih=>{"use strict";Object.defineProperty(ih,"__esModule",{value:!0});var L6=(Es(),No(_s));L6.__exportStar(rg(),ih)});var Ts=J(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});var xc=(Es(),No(_s));xc.__exportStar(eg(),As);xc.__exportStar(tg(),As);xc.__exportStar(ig(),As);xc.__exportStar(th(),As)});var yg=J((nP,vg)=>{"use strict";function i5(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}vg.exports=n5;function n5(r,e,t){var i=t&&t.stringify||i5,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var a=1;a-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(g>=f||e[g]==null)break;y=f||e[g]==null)break;y=f||e[g]===void 0)break;y",y=I+2,I++;break}u+=i(e[g]),y=I+2,I++;break;case 115:if(g>=f)break;y{"use strict";var wg=yg();Eg.exports=ti;var $o=p5().console||{},s5={mapHttpRequest:Ac,mapHttpResponse:Ac,wrapRequestSerializer:dh,wrapResponseSerializer:dh,wrapErrorSerializer:dh,req:Ac,res:Ac,err:u5};function o5(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function ti(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||$o;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=o5(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let a=r.level||"info",f=Object.create(t);f.log||(f.log=Ho),Object.defineProperty(f,"levelVal",{get:g}),Object.defineProperty(f,"level",{get:y,set:S});let u={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:h5(r)};f.levels=ti.levels,f.level=a,f.setMaxListeners=f.getMaxListeners=f.emit=f.addListener=f.on=f.prependListener=f.once=f.prependOnceListener=f.removeListener=f.removeAllListeners=f.listeners=f.listenerCount=f.eventNames=f.write=f.flush=Ho,f.serializers=i,f._serialize=n,f._stdErrSerialize=s,f.child=I,e&&(f._logEvent=lh());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(A){if(A!=="silent"&&!this.levels.values[A])throw Error("unknown level "+A);this._level=A,Ms(u,f,"error","log"),Ms(u,f,"fatal","error"),Ms(u,f,"warn","error"),Ms(u,f,"info","log"),Ms(u,f,"debug","log"),Ms(u,f,"trace","log")}function I(A,R){if(!A)throw new Error("missing bindings for child Pino");R=R||{},n&&A.serializers&&(R.serializers=A.serializers);let O=R.serializers;if(n&&O){var N=Object.assign({},i,O),U=r.browser.serialize===!0?Object.keys(N):n;delete A.serializers,Tc([A],U,N,this._stdErrSerialize)}function k(B){this._childLevel=(B._childLevel|0)+1,this.error=Rs(B,A,"error"),this.fatal=Rs(B,A,"fatal"),this.warn=Rs(B,A,"warn"),this.info=Rs(B,A,"info"),this.debug=Rs(B,A,"debug"),this.trace=Rs(B,A,"trace"),N&&(this.serializers=N,this._serialize=U),e&&(this._logEvent=lh([].concat(B._logEvent.bindings,A)))}return k.prototype=this,new k(this)}return f}ti.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};ti.stdSerializers=s5;ti.stdTimeFunctions=Object.assign({},{nullTime:xg,epochTime:_g,unixTime:d5,isoTime:l5});function Ms(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?Ho:n[t]?n[t]:$o[t]||$o[i]||Ho,a5(r,e,t)}function a5(r,e,t){!r.transmit&&e[t]===Ho||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===$o?$o:this;for(var f=0;f-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function Rs(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.BrowserRandomSource=void 0;var Mg=65536,yh=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(wh,"__esModule",{value:!0});function A5(r){for(var e=0;e{});var Pg=J(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.NodeRandomSource=void 0;var T5=fr(),_h=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof gp<"u"){let e=xh();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.SystemRandomSource=void 0;var M5=Rg(),R5=Pg(),Eh=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new M5.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new R5.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Gc.SystemRandomSource=Eh});var Cg=J(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});function P5(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Jt.mul=Math.imul||P5;function N5(r,e){return r+e|0}Jt.add=N5;function C5(r,e){return r-e|0}Jt.sub=C5;function D5(r,e){return r<>>32-e}Jt.rotl=D5;function O5(r,e){return r<<32-e|r>>>e}Jt.rotr=O5;function L5(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Jt.isInteger=Number.isInteger||L5;Jt.MAX_SAFE_INTEGER=9007199254740991;Jt.isSafeInteger=function(r){return Jt.isInteger(r)&&r>=-Jt.MAX_SAFE_INTEGER&&r<=Jt.MAX_SAFE_INTEGER}});var Ps=J(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});var Dg=Cg();function F5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Ue.readInt16BE=F5;function U5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Ue.readUint16BE=U5;function q5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Ue.readInt16LE=q5;function B5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Ue.readUint16LE=B5;function Og(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Ue.writeUint16BE=Og;Ue.writeInt16BE=Og;function Lg(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Ue.writeUint16LE=Lg;Ue.writeInt16LE=Lg;function Sh(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Ue.readInt32BE=Sh;function Ih(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Ue.readUint32BE=Ih;function Ah(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Ue.readInt32LE=Ah;function Th(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Ue.readUint32LE=Th;function Wc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Ue.writeUint32BE=Wc;Ue.writeInt32BE=Wc;function Jc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Ue.writeUint32LE=Jc;Ue.writeInt32LE=Jc;function k5(r,e){e===void 0&&(e=0);var t=Sh(r,e),i=Sh(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Ue.readInt64BE=k5;function z5(r,e){e===void 0&&(e=0);var t=Ih(r,e),i=Ih(r,e+4);return t*4294967296+i}Ue.readUint64BE=z5;function j5(r,e){e===void 0&&(e=0);var t=Ah(r,e),i=Ah(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Ue.readInt64LE=j5;function K5(r,e){e===void 0&&(e=0);var t=Th(r,e),i=Th(r,e+4);return i*4294967296+t}Ue.readUint64LE=K5;function Fg(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Wc(r/4294967296>>>0,e,t),Wc(r>>>0,e,t+4),e}Ue.writeUint64BE=Fg;Ue.writeInt64BE=Fg;function Ug(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Jc(r>>>0,e,t),Jc(r/4294967296>>>0,e,t+4),e}Ue.writeUint64LE=Ug;Ue.writeInt64LE=Ug;function V5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Ue.readUintBE=V5;function $5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Ue.writeUintBE=H5;function G5(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Dg.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.randomStringForEntropy=Mt.randomString=Mt.randomUint32=Mt.randomBytes=Mt.defaultRandomSource=void 0;var r4=Ng(),i4=Ps(),qg=fr();Mt.defaultRandomSource=new r4.SystemRandomSource;function Mh(r,e=Mt.defaultRandomSource){return e.randomBytes(r)}Mt.randomBytes=Mh;function n4(r=Mt.defaultRandomSource){let e=Mh(4,r),t=(0,i4.readUint32LE)(e);return(0,qg.wipe)(e),t}Mt.randomUint32=n4;var Bg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function kg(r,e=Bg,t=Mt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Mh(Math.ceil(r*256/s),t);for(let a=0;a0;a++){let f=o[a];f{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});var Cs=Ps(),Ns=fr();Ai.DIGEST_LENGTH=64;Ai.BLOCK_SIZE=128;var jg=function(){function r(){this.digestLength=Ai.DIGEST_LENGTH,this.blockSize=Ai.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Ns.wipe(this._buffer),Ns.wipe(this._tempHi),Ns.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(Rh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=Rh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Ns.wipe(e.stateHi),Ns.wipe(e.stateLo),e.buffer&&Ns.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Ai.SHA512=jg;var zg=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Rh(r,e,t,i,n,s,o){for(var a=t[0],f=t[1],u=t[2],g=t[3],y=t[4],S=t[5],I=t[6],A=t[7],R=i[0],O=i[1],N=i[2],U=i[3],k=i[4],B=i[5],j=i[6],V=i[7],L,D,W,P,l,w,p,c;o>=128;){for(var d=0;d<16;d++){var b=8*d+s;r[d]=Cs.readUint32BE(n,b),e[d]=Cs.readUint32BE(n,b+4)}for(var d=0;d<80;d++){var x=a,v=f,h=u,_=g,T=y,m=S,M=I,z=A,E=R,C=O,F=N,q=U,K=k,Y=B,H=j,$=V;if(L=A,D=V,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=(y>>>14|k<<18)^(y>>>18|k<<14)^(k>>>9|y<<23),D=(k>>>14|y<<18)^(k>>>18|y<<14)^(y>>>9|k<<23),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=y&S^~y&I,D=k&B^~k&j,l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=zg[d*2],D=zg[d*2+1],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=r[d%16],D=e[d%16],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,W=p&65535|c<<16,P=l&65535|w<<16,L=W,D=P,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=(a>>>28|R<<4)^(R>>>2|a<<30)^(R>>>7|a<<25),D=(R>>>28|a<<4)^(a>>>2|R<<30)^(a>>>7|R<<25),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=a&f^a&u^f&u,D=R&O^R&N^O&N,l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,z=p&65535|c<<16,$=l&65535|w<<16,L=_,D=q,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=W,D=P,l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,_=p&65535|c<<16,q=l&65535|w<<16,f=x,u=v,g=h,y=_,S=T,I=m,A=M,a=z,O=E,N=C,U=F,k=q,B=K,j=Y,V=H,R=$,d%16===15)for(var b=0;b<16;b++)L=r[b],D=e[b],l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=r[(b+9)%16],D=e[(b+9)%16],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,W=r[(b+1)%16],P=e[(b+1)%16],L=(W>>>1|P<<31)^(W>>>8|P<<24)^W>>>7,D=(P>>>1|W<<31)^(P>>>8|W<<24)^(P>>>7|W<<25),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,W=r[(b+14)%16],P=e[(b+14)%16],L=(W>>>19|P<<13)^(P>>>29|W<<3)^W>>>6,D=(P>>>19|W<<13)^(W>>>29|P<<3)^(P>>>6|W<<26),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,r[b]=p&65535|c<<16,e[b]=l&65535|w<<16}L=a,D=R,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[0],D=i[0],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[0]=a=p&65535|c<<16,i[0]=R=l&65535|w<<16,L=f,D=O,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[1],D=i[1],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[1]=f=p&65535|c<<16,i[1]=O=l&65535|w<<16,L=u,D=N,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[2],D=i[2],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[2]=u=p&65535|c<<16,i[2]=N=l&65535|w<<16,L=g,D=U,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[3],D=i[3],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[3]=g=p&65535|c<<16,i[3]=U=l&65535|w<<16,L=y,D=k,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[4],D=i[4],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[4]=y=p&65535|c<<16,i[4]=k=l&65535|w<<16,L=S,D=B,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[5],D=i[5],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[5]=S=p&65535|c<<16,i[5]=B=l&65535|w<<16,L=I,D=j,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[6],D=i[6],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[6]=I=p&65535|c<<16,i[6]=j=l&65535|w<<16,L=A,D=V,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[7],D=i[7],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[7]=A=p&65535|c<<16,i[7]=V=l&65535|w<<16,s+=128,o-=128}return s}function o4(r){var e=new jg;e.update(r);var t=e.digest();return e.clean(),t}Ai.hash=o4});var i1=J(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var a4=Yo(),Xo=Kg(),Wg=fr();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function ie(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,Jg(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function Yg(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function Hg(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Qo(t,r),Qo(i,e),Yg(t,i)}function Xg(r){let e=new Uint8Array(32);return Qo(e,r),e[0]&1}function d4(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Kn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function $n(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function He(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,R=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,D=0,W=0,P=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],T=t[1],m=t[2],M=t[3],z=t[4],E=t[5],C=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*T,a+=i*m,f+=i*M,u+=i*z,g+=i*E,y+=i*C,S+=i*F,I+=i*q,A+=i*K,R+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*T,f+=i*m,u+=i*M,g+=i*z,y+=i*E,S+=i*C,I+=i*F,A+=i*q,R+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*T,u+=i*m,g+=i*M,y+=i*z,S+=i*E,I+=i*C,A+=i*F,R+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*T,g+=i*m,y+=i*M,S+=i*z,I+=i*E,A+=i*C,R+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*T,y+=i*m,S+=i*M,I+=i*z,A+=i*E,R+=i*C,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,D+=i*X,i=e[5],g+=i*_,y+=i*T,S+=i*m,I+=i*M,A+=i*z,R+=i*E,O+=i*C,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,D+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*T,I+=i*m,A+=i*M,R+=i*z,O+=i*E,N+=i*C,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,D+=i*ee,W+=i*G,P+=i*X,i=e[7],S+=i*_,I+=i*T,A+=i*m,R+=i*M,O+=i*z,N+=i*E,U+=i*C,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,D+=i*$,W+=i*ee,P+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*T,R+=i*m,O+=i*M,N+=i*z,U+=i*E,k+=i*C,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,D+=i*H,W+=i*$,P+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,R+=i*T,O+=i*m,N+=i*M,U+=i*z,k+=i*E,B+=i*C,j+=i*F,V+=i*q,L+=i*K,D+=i*Y,W+=i*H,P+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],R+=i*_,O+=i*T,N+=i*m,U+=i*M,k+=i*z,B+=i*E,j+=i*C,V+=i*F,L+=i*q,D+=i*K,W+=i*Y,P+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*T,U+=i*m,k+=i*M,B+=i*z,j+=i*E,V+=i*C,L+=i*F,D+=i*q,W+=i*K,P+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*T,k+=i*m,B+=i*M,j+=i*z,V+=i*E,L+=i*C,D+=i*F,W+=i*q,P+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*T,B+=i*m,j+=i*M,V+=i*z,L+=i*E,D+=i*C,W+=i*F,P+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*T,j+=i*m,V+=i*M,L+=i*z,D+=i*E,W+=i*C,P+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*T,V+=i*m,L+=i*M,D+=i*z,W+=i*E,P+=i*C,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*D,u+=38*W,g+=38*P,y+=38*l,S+=38*w,I+=38*p,A+=38*c,R+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=R,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function Vn(r,e){He(r,e,e)}function Qg(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)Vn(t,t),i!==2&&i!==4&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function l4(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)Vn(t,t),i!==1&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Dh(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie(),u=ie(),g=ie();$n(t,r[1],r[0]),$n(g,e[1],e[0]),He(t,t,g),Kn(i,r[0],r[1]),Kn(g,e[0],e[1]),He(i,i,g),He(n,r[3],e[3]),He(n,n,u4),He(s,r[2],e[2]),Kn(s,s,s),$n(o,i,t),$n(a,s,n),Kn(f,s,n),Kn(u,i,t),He(r[0],o,a),He(r[1],u,f),He(r[2],f,a),He(r[3],o,u)}function Gg(r,e,t){for(let i=0;i<4;i++)Jg(r[i],e[i],t)}function Lh(r,e){let t=ie(),i=ie(),n=ie();Qg(n,e[2]),He(t,e[0],n),He(i,e[1],n),Qo(r,i),r[31]^=Xg(t)<<7}function Zg(r,e,t){Ji(r[0],Ch),Ji(r[1],Ds),Ji(r[2],Ds),Ji(r[3],Ch);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;Gg(r,e,n),Dh(e,r),Dh(r,r),Gg(r,e,n)}}function Fh(r,e){let t=[ie(),ie(),ie(),ie()];Ji(t[0],Vg),Ji(t[1],$g),Ji(t[2],Ds),He(t[3],Vg,$g),Zg(r,t,e)}function e1(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Xo.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[ie(),ie(),ie(),ie()];Fh(i,e),Lh(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=e1;function p4(r){let e=(0,a4.randomBytes)(32,r),t=e1(e);return(0,Wg.wipe)(e),t}ze.generateKeyPair=p4;function g4(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=g4;var Nh=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function t1(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*Nh[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*Nh[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Oh(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;t1(r,e)}function m4(r,e){let t=new Float64Array(64),i=[ie(),ie(),ie(),ie()],n=(0,Xo.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Xo.SHA512;o.update(s.subarray(32)),o.update(e);let a=o.digest();o.clean(),Oh(a),Fh(i,a),Lh(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let f=o.digest();Oh(f);for(let u=0;u<32;u++)t[u]=a[u];for(let u=0;u<32;u++)for(let g=0;g<32;g++)t[u+g]+=f[u]*n[g];return t1(s.subarray(32),t),s}ze.sign=m4;function r1(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie();return Ji(r[2],Ds),d4(r[1],e),Vn(n,r[1]),He(s,n,f4),$n(n,n,r[2]),Kn(s,r[2],s),Vn(o,s),Vn(a,o),He(f,a,o),He(t,f,n),He(t,t,s),l4(t,t),He(t,t,n),He(t,t,s),He(t,t,s),He(r[0],t,s),Vn(i,r[0]),He(i,i,s),Hg(i,n)&&He(r[0],r[0],h4),Vn(i,r[0]),He(i,i,s),Hg(i,n)?-1:(Xg(r[0])===e[31]>>7&&$n(r[0],Ch,r[0]),He(r[3],r[0],r[1]),0)}function b4(r,e,t){let i=new Uint8Array(32),n=[ie(),ie(),ie(),ie()],s=[ie(),ie(),ie(),ie()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(r1(s,r))return!1;let o=new Xo.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let a=o.digest();return Oh(a),Zg(n,s,a),Fh(s,t.subarray(32)),Dh(n,s),Lh(i,n),!Yg(t,i)}ze.verify=b4;function v4(r){let e=[ie(),ie(),ie(),ie()];if(r1(e,r))throw new Error("Ed25519: invalid public key");let t=ie(),i=ie(),n=e[1];Kn(t,Ds,n),$n(i,Ds,n),Qg(i,i),He(t,t,i);let s=new Uint8Array(32);return Qo(s,t),s}ze.convertPublicKeyToX25519=v4;function y4(r){let e=(0,Xo.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,Wg.wipe)(e),t}ze.convertSecretKeyToX25519=y4});var nf=J(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.getLocalStorage=Je.getLocalStorageOrThrow=Je.getCrypto=Je.getCryptoOrThrow=Je.getLocation=Je.getLocationOrThrow=Je.getNavigator=Je.getNavigatorOrThrow=Je.getDocument=Je.getDocumentOrThrow=Je.getFromWindowOrThrow=Je.getFromWindow=void 0;function Wn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Je.getFromWindow=Wn;function ks(r){let e=Wn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Je.getFromWindowOrThrow=ks;function Hx(){return ks("document")}Je.getDocumentOrThrow=Hx;function Gx(){return Wn("document")}Je.getDocument=Gx;function Wx(){return ks("navigator")}Je.getNavigatorOrThrow=Wx;function Jx(){return Wn("navigator")}Je.getNavigator=Jx;function Yx(){return ks("location")}Je.getLocationOrThrow=Yx;function Xx(){return Wn("location")}Je.getLocation=Xx;function Qx(){return ks("crypto")}Je.getCryptoOrThrow=Qx;function Zx(){return Wn("crypto")}Je.getCrypto=Zx;function e8(){return ks("localStorage")}Je.getLocalStorageOrThrow=e8;function t8(){return Wn("localStorage")}Je.getLocalStorage=t8});var K1=J(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.getWindowMetadata=void 0;var j1=nf();function r8(){let r,e;try{r=j1.getDocumentOrThrow(),e=j1.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=A.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let N=e.protocol+"//"+e.host;if(O.indexOf("/")===0)N+=O;else{let U=e.pathname.split("/");U.pop();let k=U.join("/");N+=k+"/"+O}S.push(N)}else if(O.indexOf("//")===0){let N=e.protocol+O;S.push(N)}else S.push(O)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IA.getAttribute(O)).filter(O=>O?y.includes(O):!1);if(R.length&&R){let O=A.getAttribute("content");if(O)return O}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),a=s(),f=e.origin,u=t();return{description:a,url:f,icons:u,name:o}}sf.getWindowMetadata=r8});var $1=J((PN,V1)=>{"use strict";V1.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var Y1=J((NN,J1)=>{"use strict";var W1="%[a-f0-9]{2}",H1=new RegExp("("+W1+")|([^%]+?)","gi"),G1=new RegExp("("+W1+")+","gi");function cd(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],cd(t),cd(i))}function i8(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(H1)||[],t=1;t{"use strict";X1.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var em=J((DN,Z1)=>{"use strict";Z1.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var s8=$1(),o8=Y1(),rm=Q1(),a8=em(),c8=r=>r==null,fd=Symbol("encodeFragmentIdentifier");function f8(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[",n,"]"].join("")]:[...t,[ct(e,r),"[",ct(n,r),"]=",ct(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[]"].join("")]:[...t,[ct(e,r),"[]=",ct(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),":list="].join("")]:[...t,[ct(e,r),":list=",ct(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[ct(t,r),e,ct(n,r)].join("")]:[[i,ct(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,ct(e,r)]:[...t,[ct(e,r),"=",ct(i,r)].join("")]}}function u8(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&Mi(i,r).includes(r.arrayFormatSeparator);i=o?Mi(i,r):i;let a=s||o?i.split(r.arrayFormatSeparator).map(f=>Mi(f,r)):i===null?i:Mi(i,r);n[t]=a};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&Mi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(a=>Mi(a,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function im(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function ct(r,e){return e.encode?e.strict?s8(r):encodeURIComponent(r):r}function Mi(r,e){return e.decode?o8(r):r}function nm(r){return Array.isArray(r)?r.sort():typeof r=="object"?nm(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function sm(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function h8(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function om(r){r=sm(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function tm(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function am(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),im(e.arrayFormatSeparator);let t=u8(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=rm(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:Mi(o,e),t(Mi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=tm(s[o],e);else i[n]=tm(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=nm(o):n[s]=o,n},Object.create(null))}zt.extract=om;zt.parse=am;zt.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),im(e.arrayFormatSeparator);let t=o=>e.skipNull&&c8(r[o])||e.skipEmptyString&&r[o]==="",i=f8(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let a=r[o];return a===void 0?"":a===null?ct(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?ct(o,e)+"[]":a.reduce(i(o),[]).join("&"):ct(o,e)+"="+ct(a,e)}).filter(o=>o.length>0).join("&")};zt.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=rm(r,"#");return Object.assign({url:t.split("?")[0]||"",query:am(om(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:Mi(i,e)}:{})};zt.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[fd]:!0},e);let t=sm(r.url).split("?")[0]||"",i=zt.extract(r.url),n=zt.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=zt.stringify(s,e);o&&(o=`?${o}`);let a=h8(r.url);return r.fragmentIdentifier&&(a=`#${e[fd]?ct(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${a}`};zt.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[fd]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=zt.parseUrl(r,t);return zt.stringifyUrl({url:i,query:a8(n,e),fragmentIdentifier:s},t)};zt.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return zt.pick(r,i,t)}});var fm=J((LN,of)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=global:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof of=="object"&&of.exports,a=typeof define=="function"&&define.amd,f=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],A=[0,8,16,24],R=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],N=[128,256],U=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),f&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var B=function(E,C,F){return function(q){return new m(E,C,E).update(q)[F]()}},j=function(E,C,F){return function(q,K){return new m(E,C,K).update(q)[F]()}},V=function(E,C,F){return function(q,K,Y,H){return c["cshake"+E].update(q,K,Y,H)[F]()}},L=function(E,C,F){return function(q,K,Y,H){return c["kmac"+E].update(q,K,Y,H)[F]()}},D=function(E,C,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}m.prototype.update=function(E){if(this.finalized)throw new Error(e);var C,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}for(var q=this.blocks,K=this.byteCount,Y=E.length,H=this.blockCount,$=0,ee=this.s,G,X;$>2]|=E[$]<>2]|=X<>2]|=(192|X>>6)<>2]|=(128|X&63)<=57344?(q[G>>2]|=(224|X>>12)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<>2]|=(240|X>>18)<>2]|=(128|X>>12&63)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<=K){for(this.start=G-K,this.block=q[H],G=0;G>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return C?K.push(q):K.unshift(q),this.update(K),K.length},m.prototype.encodeString=function(E){var C,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}var q=0,K=E.length;if(C)q=K;else for(var Y=0;Y=57344?q+=3:(H=65536+((H&1023)<<10|E.charCodeAt(++Y)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},m.prototype.bytepad=function(E,C){for(var F=this.encode(C),q=0;q>2]|=this.padding[C&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],C=1;C>4&15]+u[$&15]+u[$>>12&15]+u[$>>8&15]+u[$>>20&15]+u[$>>16&15]+u[$>>28&15]+u[$>>24&15];Y%E===0&&(z(C),K=0)}return q&&($=C[K],H+=u[$>>4&15]+u[$&15],q>1&&(H+=u[$>>12&15]+u[$>>8&15]),q>2&&(H+=u[$>>20&15]+u[$>>16&15])),H},m.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,C=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,Y=0,H=this.outputBits>>3,$;q?$=new ArrayBuffer(F+1<<2):$=new ArrayBuffer(H);for(var ee=new Uint32Array($);Y>8&255,H[$+2]=ee>>16&255,H[$+3]=ee>>24&255;Y%E===0&&z(C)}return q&&($=Y<<2,ee=C[K],H[$]=ee&255,q>1&&(H[$+1]=ee>>8&255),q>2&&(H[$+2]=ee>>16&255)),H};function M(E,C,F){m.call(this,E,C,F)}M.prototype=new m,M.prototype.finalize=function(){return this.encode(this.outputBits,!0),m.prototype.finalize.call(this)};var z=function(E){var C,F,q,K,Y,H,$,ee,G,X,qr,se,oe,Br,ae,ce,kr,fe,ue,zr,he,de,jr,le,pe,Kr,ge,me,Vr,be,ve,$r,ye,we,Hr,xe,_e,Gr,Ee,Se,Wr,Ie,Ae,Jr,Te,Me,Yr,Re,Pe,Xr,Ne,Ce,Qr,De,Oe,yr,Ke,Ve,rr,ir,nr,sr,or;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],Y=E[1]^E[11]^E[21]^E[31]^E[41],H=E[2]^E[12]^E[22]^E[32]^E[42],$=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],X=E[6]^E[16]^E[26]^E[36]^E[46],qr=E[7]^E[17]^E[27]^E[37]^E[47],se=E[8]^E[18]^E[28]^E[38]^E[48],oe=E[9]^E[19]^E[29]^E[39]^E[49],C=se^(H<<1|$>>>31),F=oe^($<<1|H>>>31),E[0]^=C,E[1]^=F,E[10]^=C,E[11]^=F,E[20]^=C,E[21]^=F,E[30]^=C,E[31]^=F,E[40]^=C,E[41]^=F,C=K^(ee<<1|G>>>31),F=Y^(G<<1|ee>>>31),E[2]^=C,E[3]^=F,E[12]^=C,E[13]^=F,E[22]^=C,E[23]^=F,E[32]^=C,E[33]^=F,E[42]^=C,E[43]^=F,C=H^(X<<1|qr>>>31),F=$^(qr<<1|X>>>31),E[4]^=C,E[5]^=F,E[14]^=C,E[15]^=F,E[24]^=C,E[25]^=F,E[34]^=C,E[35]^=F,E[44]^=C,E[45]^=F,C=ee^(se<<1|oe>>>31),F=G^(oe<<1|se>>>31),E[6]^=C,E[7]^=F,E[16]^=C,E[17]^=F,E[26]^=C,E[27]^=F,E[36]^=C,E[37]^=F,E[46]^=C,E[47]^=F,C=X^(K<<1|Y>>>31),F=qr^(Y<<1|K>>>31),E[8]^=C,E[9]^=F,E[18]^=C,E[19]^=F,E[28]^=C,E[29]^=F,E[38]^=C,E[39]^=F,E[48]^=C,E[49]^=F,Br=E[0],ae=E[1],Me=E[11]<<4|E[10]>>>28,Yr=E[10]<<4|E[11]>>>28,me=E[20]<<3|E[21]>>>29,Vr=E[21]<<3|E[20]>>>29,ir=E[31]<<9|E[30]>>>23,nr=E[30]<<9|E[31]>>>23,Ie=E[40]<<18|E[41]>>>14,Ae=E[41]<<18|E[40]>>>14,we=E[2]<<1|E[3]>>>31,Hr=E[3]<<1|E[2]>>>31,ce=E[13]<<12|E[12]>>>20,kr=E[12]<<12|E[13]>>>20,Re=E[22]<<10|E[23]>>>22,Pe=E[23]<<10|E[22]>>>22,be=E[33]<<13|E[32]>>>19,ve=E[32]<<13|E[33]>>>19,sr=E[42]<<2|E[43]>>>30,or=E[43]<<2|E[42]>>>30,De=E[5]<<30|E[4]>>>2,Oe=E[4]<<30|E[5]>>>2,xe=E[14]<<6|E[15]>>>26,_e=E[15]<<6|E[14]>>>26,fe=E[25]<<11|E[24]>>>21,ue=E[24]<<11|E[25]>>>21,Xr=E[34]<<15|E[35]>>>17,Ne=E[35]<<15|E[34]>>>17,$r=E[45]<<29|E[44]>>>3,ye=E[44]<<29|E[45]>>>3,le=E[6]<<28|E[7]>>>4,pe=E[7]<<28|E[6]>>>4,yr=E[17]<<23|E[16]>>>9,Ke=E[16]<<23|E[17]>>>9,Gr=E[26]<<25|E[27]>>>7,Ee=E[27]<<25|E[26]>>>7,zr=E[36]<<21|E[37]>>>11,he=E[37]<<21|E[36]>>>11,Ce=E[47]<<24|E[46]>>>8,Qr=E[46]<<24|E[47]>>>8,Jr=E[8]<<27|E[9]>>>5,Te=E[9]<<27|E[8]>>>5,Kr=E[18]<<20|E[19]>>>12,ge=E[19]<<20|E[18]>>>12,Ve=E[29]<<7|E[28]>>>25,rr=E[28]<<7|E[29]>>>25,Se=E[38]<<8|E[39]>>>24,Wr=E[39]<<8|E[38]>>>24,de=E[48]<<14|E[49]>>>18,jr=E[49]<<14|E[48]>>>18,E[0]=Br^~ce&fe,E[1]=ae^~kr&ue,E[10]=le^~Kr&me,E[11]=pe^~ge&Vr,E[20]=we^~xe&Gr,E[21]=Hr^~_e&Ee,E[30]=Jr^~Me&Re,E[31]=Te^~Yr&Pe,E[40]=De^~yr&Ve,E[41]=Oe^~Ke&rr,E[2]=ce^~fe&zr,E[3]=kr^~ue&he,E[12]=Kr^~me&be,E[13]=ge^~Vr&ve,E[22]=xe^~Gr&Se,E[23]=_e^~Ee&Wr,E[32]=Me^~Re&Xr,E[33]=Yr^~Pe&Ne,E[42]=yr^~Ve&ir,E[43]=Ke^~rr&nr,E[4]=fe^~zr&de,E[5]=ue^~he&jr,E[14]=me^~be&$r,E[15]=Vr^~ve&ye,E[24]=Gr^~Se&Ie,E[25]=Ee^~Wr&Ae,E[34]=Re^~Xr&Ce,E[35]=Pe^~Ne&Qr,E[44]=Ve^~ir&sr,E[45]=rr^~nr&or,E[6]=zr^~de&Br,E[7]=he^~jr&ae,E[16]=be^~$r&le,E[17]=ve^~ye&pe,E[26]=Se^~Ie&we,E[27]=Wr^~Ae&Hr,E[36]=Xr^~Ce&Jr,E[37]=Ne^~Qr&Te,E[46]=ir^~sr&De,E[47]=nr^~or&Oe,E[8]=de^~Br&ce,E[9]=jr^~ae&kr,E[18]=$r^~le&Kr,E[19]=ye^~pe&ge,E[28]=Ie^~we&xe,E[29]=Ae^~Hr&_e,E[38]=Ce^~Jr&Me,E[39]=Qr^~Te&Yr,E[48]=sr^~De&yr,E[49]=or^~Oe&Ke,E[0]^=R[q],E[1]^=R[q+1]};if(o)of.exports=c;else{for(b=0;b{});var bd=J((xm,md)=>{(function(r,e){"use strict";function t(p,c){if(!p)throw new Error(c||"Assertion failed")}function i(p,c){p.super_=c;var d=function(){};d.prototype=c.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,c,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((c==="le"||c==="be")&&(d=c,c=10),this._init(p||0,c||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=gd().Buffer}catch{}n.isBN=function(c){return c instanceof n?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===n.wordSize&&Array.isArray(c.words)},n.max=function(c,d){return c.cmp(d)>0?c:d},n.min=function(c,d){return c.cmp(d)<0?c:d},n.prototype._init=function(c,d,b){if(typeof c=="number")return this._initNumber(c,d,b);if(typeof c=="object")return this._initArray(c,d,b);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),c=c.toString().replace(/\s+/g,"");var x=0;c[0]==="-"&&(x++,this.negative=1),x=0;x-=3)h=c[x]|c[x-1]<<8|c[x-2]<<16,this.words[v]|=h<<_&67108863,this.words[v+1]=h>>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);else if(b==="le")for(x=0,v=0;x>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);return this._strip()};function o(p,c){var d=p.charCodeAt(c);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function a(p,c,d){var b=o(p,d);return d-1>=c&&(b|=o(p,d-1)<<4),b}n.prototype._parseHex=function(c,d,b){this.length=Math.ceil((c.length-d)/6),this.words=new Array(this.length);for(var x=0;x=d;x-=2)_=a(c,d,x)<=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8;else{var T=c.length-d;for(x=T%2===0?d+1:d;x=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8}this._strip()};function f(p,c,d,b){for(var x=0,v=0,h=Math.min(p.length,d),_=c;_=49?v=T-49+10:T>=17?v=T-17+10:v=T,t(T>=0&&v1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{n.prototype.inspect=g}else n.prototype.inspect=g;function g(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(c,d){c=c||10,d=d|0||1;var b;if(c===16||c==="hex"){b="";for(var x=0,v=0,h=0;h>>24-x&16777215,x+=2,x>=26&&(x-=26,h--),v!==0||h!==this.length-1?b=y[6-T.length]+T+b:b=T+b}for(v!==0&&(b=v.toString(16)+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(c===(c|0)&&c>=2&&c<=36){var m=S[c],M=I[c];b="";var z=this.clone();for(z.negative=0;!z.isZero();){var E=z.modrn(M).toString(c);z=z.idivn(M),z.isZero()?b=E+b:b=y[m-E.length]+E+b}for(this.isZero()&&(b="0"+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(c,d){return this.toArrayLike(s,c,d)}),n.prototype.toArray=function(c,d){return this.toArrayLike(Array,c,d)};var A=function(c,d){return c.allocUnsafe?c.allocUnsafe(d):new c(d)};n.prototype.toArrayLike=function(c,d,b){this._strip();var x=this.byteLength(),v=b||Math.max(1,x);t(x<=v,"byte array longer than desired length"),t(v>0,"Requested array length <= 0");var h=A(c,v),_=d==="le"?"LE":"BE";return this["_toArrayLike"+_](h,x),h},n.prototype._toArrayLikeLE=function(c,d){for(var b=0,x=0,v=0,h=0;v>8&255),b>16&255),h===6?(b>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b=0&&(c[b--]=_>>8&255),b>=0&&(c[b--]=_>>16&255),h===6?(b>=0&&(c[b--]=_>>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b>=0)for(c[b--]=x;b>=0;)c[b--]=0},Math.clz32?n.prototype._countBits=function(c){return 32-Math.clz32(c)}:n.prototype._countBits=function(c){var d=c,b=0;return d>=4096&&(b+=13,d>>>=13),d>=64&&(b+=7,d>>>=7),d>=8&&(b+=4,d>>>=4),d>=2&&(b+=2,d>>>=2),b+d},n.prototype._zeroBits=function(c){if(c===0)return 26;var d=c,b=0;return d&8191||(b+=13,d>>>=13),d&127||(b+=7,d>>>=7),d&15||(b+=4,d>>>=4),d&3||(b+=2,d>>>=2),d&1||b++,b},n.prototype.bitLength=function(){var c=this.words[this.length-1],d=this._countBits(c);return(this.length-1)*26+d};function R(p){for(var c=new Array(p.bitLength()),d=0;d>>x&1}return c}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,d=0;dc.length?this.clone().ior(c):c.clone().ior(this)},n.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},n.prototype.iuand=function(c){var d;this.length>c.length?d=c:d=this;for(var b=0;bc.length?this.clone().iand(c):c.clone().iand(this)},n.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},n.prototype.iuxor=function(c){var d,b;this.length>c.length?(d=this,b=c):(d=c,b=this);for(var x=0;xc.length?this.clone().ixor(c):c.clone().ixor(this)},n.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},n.prototype.inotn=function(c){t(typeof c=="number"&&c>=0);var d=Math.ceil(c/26)|0,b=c%26;this._expand(d),b>0&&d--;for(var x=0;x0&&(this.words[x]=~this.words[x]&67108863>>26-b),this._strip()},n.prototype.notn=function(c){return this.clone().inotn(c)},n.prototype.setn=function(c,d){t(typeof c=="number"&&c>=0);var b=c/26|0,x=c%26;return this._expand(b+1),d?this.words[b]=this.words[b]|1<c.length?(b=this,x=c):(b=c,x=this);for(var v=0,h=0;h>>26;for(;v!==0&&h>>26;if(this.length=b.length,v!==0)this.words[this.length]=v,this.length++;else if(b!==this)for(;hc.length?this.clone().iadd(c):c.clone().iadd(this)},n.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var d=this.iadd(c);return c.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var b=this.cmp(c);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,v;b>0?(x=this,v=c):(x=c,v=this);for(var h=0,_=0;_>26,this.words[_]=d&67108863;for(;h!==0&&_>26,this.words[_]=d&67108863;if(h===0&&_>>26,z=T&67108863,E=Math.min(m,c.length-1),C=Math.max(0,m-p.length+1);C<=E;C++){var F=m-C|0;x=p.words[F]|0,v=c.words[C]|0,h=x*v+z,M+=h/67108864|0,z=h&67108863}d.words[m]=z|0,T=M|0}return T!==0?d.words[m]=T|0:d.length--,d._strip()}var N=function(c,d,b){var x=c.words,v=d.words,h=b.words,_=0,T,m,M,z=x[0]|0,E=z&8191,C=z>>>13,F=x[1]|0,q=F&8191,K=F>>>13,Y=x[2]|0,H=Y&8191,$=Y>>>13,ee=x[3]|0,G=ee&8191,X=ee>>>13,qr=x[4]|0,se=qr&8191,oe=qr>>>13,Br=x[5]|0,ae=Br&8191,ce=Br>>>13,kr=x[6]|0,fe=kr&8191,ue=kr>>>13,zr=x[7]|0,he=zr&8191,de=zr>>>13,jr=x[8]|0,le=jr&8191,pe=jr>>>13,Kr=x[9]|0,ge=Kr&8191,me=Kr>>>13,Vr=v[0]|0,be=Vr&8191,ve=Vr>>>13,$r=v[1]|0,ye=$r&8191,we=$r>>>13,Hr=v[2]|0,xe=Hr&8191,_e=Hr>>>13,Gr=v[3]|0,Ee=Gr&8191,Se=Gr>>>13,Wr=v[4]|0,Ie=Wr&8191,Ae=Wr>>>13,Jr=v[5]|0,Te=Jr&8191,Me=Jr>>>13,Yr=v[6]|0,Re=Yr&8191,Pe=Yr>>>13,Xr=v[7]|0,Ne=Xr&8191,Ce=Xr>>>13,Qr=v[8]|0,De=Qr&8191,Oe=Qr>>>13,yr=v[9]|0,Ke=yr&8191,Ve=yr>>>13;b.negative=c.negative^d.negative,b.length=19,T=Math.imul(E,be),m=Math.imul(E,ve),m=m+Math.imul(C,be)|0,M=Math.imul(C,ve);var rr=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(rr>>>26)|0,rr&=67108863,T=Math.imul(q,be),m=Math.imul(q,ve),m=m+Math.imul(K,be)|0,M=Math.imul(K,ve),T=T+Math.imul(E,ye)|0,m=m+Math.imul(E,we)|0,m=m+Math.imul(C,ye)|0,M=M+Math.imul(C,we)|0;var ir=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(ir>>>26)|0,ir&=67108863,T=Math.imul(H,be),m=Math.imul(H,ve),m=m+Math.imul($,be)|0,M=Math.imul($,ve),T=T+Math.imul(q,ye)|0,m=m+Math.imul(q,we)|0,m=m+Math.imul(K,ye)|0,M=M+Math.imul(K,we)|0,T=T+Math.imul(E,xe)|0,m=m+Math.imul(E,_e)|0,m=m+Math.imul(C,xe)|0,M=M+Math.imul(C,_e)|0;var nr=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(nr>>>26)|0,nr&=67108863,T=Math.imul(G,be),m=Math.imul(G,ve),m=m+Math.imul(X,be)|0,M=Math.imul(X,ve),T=T+Math.imul(H,ye)|0,m=m+Math.imul(H,we)|0,m=m+Math.imul($,ye)|0,M=M+Math.imul($,we)|0,T=T+Math.imul(q,xe)|0,m=m+Math.imul(q,_e)|0,m=m+Math.imul(K,xe)|0,M=M+Math.imul(K,_e)|0,T=T+Math.imul(E,Ee)|0,m=m+Math.imul(E,Se)|0,m=m+Math.imul(C,Ee)|0,M=M+Math.imul(C,Se)|0;var sr=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(sr>>>26)|0,sr&=67108863,T=Math.imul(se,be),m=Math.imul(se,ve),m=m+Math.imul(oe,be)|0,M=Math.imul(oe,ve),T=T+Math.imul(G,ye)|0,m=m+Math.imul(G,we)|0,m=m+Math.imul(X,ye)|0,M=M+Math.imul(X,we)|0,T=T+Math.imul(H,xe)|0,m=m+Math.imul(H,_e)|0,m=m+Math.imul($,xe)|0,M=M+Math.imul($,_e)|0,T=T+Math.imul(q,Ee)|0,m=m+Math.imul(q,Se)|0,m=m+Math.imul(K,Ee)|0,M=M+Math.imul(K,Se)|0,T=T+Math.imul(E,Ie)|0,m=m+Math.imul(E,Ae)|0,m=m+Math.imul(C,Ie)|0,M=M+Math.imul(C,Ae)|0;var or=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(or>>>26)|0,or&=67108863,T=Math.imul(ae,be),m=Math.imul(ae,ve),m=m+Math.imul(ce,be)|0,M=Math.imul(ce,ve),T=T+Math.imul(se,ye)|0,m=m+Math.imul(se,we)|0,m=m+Math.imul(oe,ye)|0,M=M+Math.imul(oe,we)|0,T=T+Math.imul(G,xe)|0,m=m+Math.imul(G,_e)|0,m=m+Math.imul(X,xe)|0,M=M+Math.imul(X,_e)|0,T=T+Math.imul(H,Ee)|0,m=m+Math.imul(H,Se)|0,m=m+Math.imul($,Ee)|0,M=M+Math.imul($,Se)|0,T=T+Math.imul(q,Ie)|0,m=m+Math.imul(q,Ae)|0,m=m+Math.imul(K,Ie)|0,M=M+Math.imul(K,Ae)|0,T=T+Math.imul(E,Te)|0,m=m+Math.imul(E,Me)|0,m=m+Math.imul(C,Te)|0,M=M+Math.imul(C,Me)|0;var Tn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,T=Math.imul(fe,be),m=Math.imul(fe,ve),m=m+Math.imul(ue,be)|0,M=Math.imul(ue,ve),T=T+Math.imul(ae,ye)|0,m=m+Math.imul(ae,we)|0,m=m+Math.imul(ce,ye)|0,M=M+Math.imul(ce,we)|0,T=T+Math.imul(se,xe)|0,m=m+Math.imul(se,_e)|0,m=m+Math.imul(oe,xe)|0,M=M+Math.imul(oe,_e)|0,T=T+Math.imul(G,Ee)|0,m=m+Math.imul(G,Se)|0,m=m+Math.imul(X,Ee)|0,M=M+Math.imul(X,Se)|0,T=T+Math.imul(H,Ie)|0,m=m+Math.imul(H,Ae)|0,m=m+Math.imul($,Ie)|0,M=M+Math.imul($,Ae)|0,T=T+Math.imul(q,Te)|0,m=m+Math.imul(q,Me)|0,m=m+Math.imul(K,Te)|0,M=M+Math.imul(K,Me)|0,T=T+Math.imul(E,Re)|0,m=m+Math.imul(E,Pe)|0,m=m+Math.imul(C,Re)|0,M=M+Math.imul(C,Pe)|0;var Mn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,T=Math.imul(he,be),m=Math.imul(he,ve),m=m+Math.imul(de,be)|0,M=Math.imul(de,ve),T=T+Math.imul(fe,ye)|0,m=m+Math.imul(fe,we)|0,m=m+Math.imul(ue,ye)|0,M=M+Math.imul(ue,we)|0,T=T+Math.imul(ae,xe)|0,m=m+Math.imul(ae,_e)|0,m=m+Math.imul(ce,xe)|0,M=M+Math.imul(ce,_e)|0,T=T+Math.imul(se,Ee)|0,m=m+Math.imul(se,Se)|0,m=m+Math.imul(oe,Ee)|0,M=M+Math.imul(oe,Se)|0,T=T+Math.imul(G,Ie)|0,m=m+Math.imul(G,Ae)|0,m=m+Math.imul(X,Ie)|0,M=M+Math.imul(X,Ae)|0,T=T+Math.imul(H,Te)|0,m=m+Math.imul(H,Me)|0,m=m+Math.imul($,Te)|0,M=M+Math.imul($,Me)|0,T=T+Math.imul(q,Re)|0,m=m+Math.imul(q,Pe)|0,m=m+Math.imul(K,Re)|0,M=M+Math.imul(K,Pe)|0,T=T+Math.imul(E,Ne)|0,m=m+Math.imul(E,Ce)|0,m=m+Math.imul(C,Ne)|0,M=M+Math.imul(C,Ce)|0;var Rn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,T=Math.imul(le,be),m=Math.imul(le,ve),m=m+Math.imul(pe,be)|0,M=Math.imul(pe,ve),T=T+Math.imul(he,ye)|0,m=m+Math.imul(he,we)|0,m=m+Math.imul(de,ye)|0,M=M+Math.imul(de,we)|0,T=T+Math.imul(fe,xe)|0,m=m+Math.imul(fe,_e)|0,m=m+Math.imul(ue,xe)|0,M=M+Math.imul(ue,_e)|0,T=T+Math.imul(ae,Ee)|0,m=m+Math.imul(ae,Se)|0,m=m+Math.imul(ce,Ee)|0,M=M+Math.imul(ce,Se)|0,T=T+Math.imul(se,Ie)|0,m=m+Math.imul(se,Ae)|0,m=m+Math.imul(oe,Ie)|0,M=M+Math.imul(oe,Ae)|0,T=T+Math.imul(G,Te)|0,m=m+Math.imul(G,Me)|0,m=m+Math.imul(X,Te)|0,M=M+Math.imul(X,Me)|0,T=T+Math.imul(H,Re)|0,m=m+Math.imul(H,Pe)|0,m=m+Math.imul($,Re)|0,M=M+Math.imul($,Pe)|0,T=T+Math.imul(q,Ne)|0,m=m+Math.imul(q,Ce)|0,m=m+Math.imul(K,Ne)|0,M=M+Math.imul(K,Ce)|0,T=T+Math.imul(E,De)|0,m=m+Math.imul(E,Oe)|0,m=m+Math.imul(C,De)|0,M=M+Math.imul(C,Oe)|0;var Pn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,T=Math.imul(ge,be),m=Math.imul(ge,ve),m=m+Math.imul(me,be)|0,M=Math.imul(me,ve),T=T+Math.imul(le,ye)|0,m=m+Math.imul(le,we)|0,m=m+Math.imul(pe,ye)|0,M=M+Math.imul(pe,we)|0,T=T+Math.imul(he,xe)|0,m=m+Math.imul(he,_e)|0,m=m+Math.imul(de,xe)|0,M=M+Math.imul(de,_e)|0,T=T+Math.imul(fe,Ee)|0,m=m+Math.imul(fe,Se)|0,m=m+Math.imul(ue,Ee)|0,M=M+Math.imul(ue,Se)|0,T=T+Math.imul(ae,Ie)|0,m=m+Math.imul(ae,Ae)|0,m=m+Math.imul(ce,Ie)|0,M=M+Math.imul(ce,Ae)|0,T=T+Math.imul(se,Te)|0,m=m+Math.imul(se,Me)|0,m=m+Math.imul(oe,Te)|0,M=M+Math.imul(oe,Me)|0,T=T+Math.imul(G,Re)|0,m=m+Math.imul(G,Pe)|0,m=m+Math.imul(X,Re)|0,M=M+Math.imul(X,Pe)|0,T=T+Math.imul(H,Ne)|0,m=m+Math.imul(H,Ce)|0,m=m+Math.imul($,Ne)|0,M=M+Math.imul($,Ce)|0,T=T+Math.imul(q,De)|0,m=m+Math.imul(q,Oe)|0,m=m+Math.imul(K,De)|0,M=M+Math.imul(K,Oe)|0,T=T+Math.imul(E,Ke)|0,m=m+Math.imul(E,Ve)|0,m=m+Math.imul(C,Ke)|0,M=M+Math.imul(C,Ve)|0;var Nn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,T=Math.imul(ge,ye),m=Math.imul(ge,we),m=m+Math.imul(me,ye)|0,M=Math.imul(me,we),T=T+Math.imul(le,xe)|0,m=m+Math.imul(le,_e)|0,m=m+Math.imul(pe,xe)|0,M=M+Math.imul(pe,_e)|0,T=T+Math.imul(he,Ee)|0,m=m+Math.imul(he,Se)|0,m=m+Math.imul(de,Ee)|0,M=M+Math.imul(de,Se)|0,T=T+Math.imul(fe,Ie)|0,m=m+Math.imul(fe,Ae)|0,m=m+Math.imul(ue,Ie)|0,M=M+Math.imul(ue,Ae)|0,T=T+Math.imul(ae,Te)|0,m=m+Math.imul(ae,Me)|0,m=m+Math.imul(ce,Te)|0,M=M+Math.imul(ce,Me)|0,T=T+Math.imul(se,Re)|0,m=m+Math.imul(se,Pe)|0,m=m+Math.imul(oe,Re)|0,M=M+Math.imul(oe,Pe)|0,T=T+Math.imul(G,Ne)|0,m=m+Math.imul(G,Ce)|0,m=m+Math.imul(X,Ne)|0,M=M+Math.imul(X,Ce)|0,T=T+Math.imul(H,De)|0,m=m+Math.imul(H,Oe)|0,m=m+Math.imul($,De)|0,M=M+Math.imul($,Oe)|0,T=T+Math.imul(q,Ke)|0,m=m+Math.imul(q,Ve)|0,m=m+Math.imul(K,Ke)|0,M=M+Math.imul(K,Ve)|0;var Cn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Cn>>>26)|0,Cn&=67108863,T=Math.imul(ge,xe),m=Math.imul(ge,_e),m=m+Math.imul(me,xe)|0,M=Math.imul(me,_e),T=T+Math.imul(le,Ee)|0,m=m+Math.imul(le,Se)|0,m=m+Math.imul(pe,Ee)|0,M=M+Math.imul(pe,Se)|0,T=T+Math.imul(he,Ie)|0,m=m+Math.imul(he,Ae)|0,m=m+Math.imul(de,Ie)|0,M=M+Math.imul(de,Ae)|0,T=T+Math.imul(fe,Te)|0,m=m+Math.imul(fe,Me)|0,m=m+Math.imul(ue,Te)|0,M=M+Math.imul(ue,Me)|0,T=T+Math.imul(ae,Re)|0,m=m+Math.imul(ae,Pe)|0,m=m+Math.imul(ce,Re)|0,M=M+Math.imul(ce,Pe)|0,T=T+Math.imul(se,Ne)|0,m=m+Math.imul(se,Ce)|0,m=m+Math.imul(oe,Ne)|0,M=M+Math.imul(oe,Ce)|0,T=T+Math.imul(G,De)|0,m=m+Math.imul(G,Oe)|0,m=m+Math.imul(X,De)|0,M=M+Math.imul(X,Oe)|0,T=T+Math.imul(H,Ke)|0,m=m+Math.imul(H,Ve)|0,m=m+Math.imul($,Ke)|0,M=M+Math.imul($,Ve)|0;var Dn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,T=Math.imul(ge,Ee),m=Math.imul(ge,Se),m=m+Math.imul(me,Ee)|0,M=Math.imul(me,Se),T=T+Math.imul(le,Ie)|0,m=m+Math.imul(le,Ae)|0,m=m+Math.imul(pe,Ie)|0,M=M+Math.imul(pe,Ae)|0,T=T+Math.imul(he,Te)|0,m=m+Math.imul(he,Me)|0,m=m+Math.imul(de,Te)|0,M=M+Math.imul(de,Me)|0,T=T+Math.imul(fe,Re)|0,m=m+Math.imul(fe,Pe)|0,m=m+Math.imul(ue,Re)|0,M=M+Math.imul(ue,Pe)|0,T=T+Math.imul(ae,Ne)|0,m=m+Math.imul(ae,Ce)|0,m=m+Math.imul(ce,Ne)|0,M=M+Math.imul(ce,Ce)|0,T=T+Math.imul(se,De)|0,m=m+Math.imul(se,Oe)|0,m=m+Math.imul(oe,De)|0,M=M+Math.imul(oe,Oe)|0,T=T+Math.imul(G,Ke)|0,m=m+Math.imul(G,Ve)|0,m=m+Math.imul(X,Ke)|0,M=M+Math.imul(X,Ve)|0;var On=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(On>>>26)|0,On&=67108863,T=Math.imul(ge,Ie),m=Math.imul(ge,Ae),m=m+Math.imul(me,Ie)|0,M=Math.imul(me,Ae),T=T+Math.imul(le,Te)|0,m=m+Math.imul(le,Me)|0,m=m+Math.imul(pe,Te)|0,M=M+Math.imul(pe,Me)|0,T=T+Math.imul(he,Re)|0,m=m+Math.imul(he,Pe)|0,m=m+Math.imul(de,Re)|0,M=M+Math.imul(de,Pe)|0,T=T+Math.imul(fe,Ne)|0,m=m+Math.imul(fe,Ce)|0,m=m+Math.imul(ue,Ne)|0,M=M+Math.imul(ue,Ce)|0,T=T+Math.imul(ae,De)|0,m=m+Math.imul(ae,Oe)|0,m=m+Math.imul(ce,De)|0,M=M+Math.imul(ce,Oe)|0,T=T+Math.imul(se,Ke)|0,m=m+Math.imul(se,Ve)|0,m=m+Math.imul(oe,Ke)|0,M=M+Math.imul(oe,Ve)|0;var Ln=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Ln>>>26)|0,Ln&=67108863,T=Math.imul(ge,Te),m=Math.imul(ge,Me),m=m+Math.imul(me,Te)|0,M=Math.imul(me,Me),T=T+Math.imul(le,Re)|0,m=m+Math.imul(le,Pe)|0,m=m+Math.imul(pe,Re)|0,M=M+Math.imul(pe,Pe)|0,T=T+Math.imul(he,Ne)|0,m=m+Math.imul(he,Ce)|0,m=m+Math.imul(de,Ne)|0,M=M+Math.imul(de,Ce)|0,T=T+Math.imul(fe,De)|0,m=m+Math.imul(fe,Oe)|0,m=m+Math.imul(ue,De)|0,M=M+Math.imul(ue,Oe)|0,T=T+Math.imul(ae,Ke)|0,m=m+Math.imul(ae,Ve)|0,m=m+Math.imul(ce,Ke)|0,M=M+Math.imul(ce,Ve)|0;var Fn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Fn>>>26)|0,Fn&=67108863,T=Math.imul(ge,Re),m=Math.imul(ge,Pe),m=m+Math.imul(me,Re)|0,M=Math.imul(me,Pe),T=T+Math.imul(le,Ne)|0,m=m+Math.imul(le,Ce)|0,m=m+Math.imul(pe,Ne)|0,M=M+Math.imul(pe,Ce)|0,T=T+Math.imul(he,De)|0,m=m+Math.imul(he,Oe)|0,m=m+Math.imul(de,De)|0,M=M+Math.imul(de,Oe)|0,T=T+Math.imul(fe,Ke)|0,m=m+Math.imul(fe,Ve)|0,m=m+Math.imul(ue,Ke)|0,M=M+Math.imul(ue,Ve)|0;var Un=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Un>>>26)|0,Un&=67108863,T=Math.imul(ge,Ne),m=Math.imul(ge,Ce),m=m+Math.imul(me,Ne)|0,M=Math.imul(me,Ce),T=T+Math.imul(le,De)|0,m=m+Math.imul(le,Oe)|0,m=m+Math.imul(pe,De)|0,M=M+Math.imul(pe,Oe)|0,T=T+Math.imul(he,Ke)|0,m=m+Math.imul(he,Ve)|0,m=m+Math.imul(de,Ke)|0,M=M+Math.imul(de,Ve)|0;var Ku=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Ku>>>26)|0,Ku&=67108863,T=Math.imul(ge,De),m=Math.imul(ge,Oe),m=m+Math.imul(me,De)|0,M=Math.imul(me,Oe),T=T+Math.imul(le,Ke)|0,m=m+Math.imul(le,Ve)|0,m=m+Math.imul(pe,Ke)|0,M=M+Math.imul(pe,Ve)|0;var Vu=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Vu>>>26)|0,Vu&=67108863,T=Math.imul(ge,Ke),m=Math.imul(ge,Ve),m=m+Math.imul(me,Ke)|0,M=Math.imul(me,Ve);var $u=(_+T|0)+((m&8191)<<13)|0;return _=(M+(m>>>13)|0)+($u>>>26)|0,$u&=67108863,h[0]=rr,h[1]=ir,h[2]=nr,h[3]=sr,h[4]=or,h[5]=Tn,h[6]=Mn,h[7]=Rn,h[8]=Pn,h[9]=Nn,h[10]=Cn,h[11]=Dn,h[12]=On,h[13]=Ln,h[14]=Fn,h[15]=Un,h[16]=Ku,h[17]=Vu,h[18]=$u,_!==0&&(h[19]=_,b.length++),b};Math.imul||(N=O);function U(p,c,d){d.negative=c.negative^p.negative,d.length=p.length+c.length;for(var b=0,x=0,v=0;v>>26)|0,x+=h>>>26,h&=67108863}d.words[v]=_,b=h,h=x}return b!==0?d.words[v]=b:d.length--,d._strip()}function k(p,c,d){return U(p,c,d)}n.prototype.mulTo=function(c,d){var b,x=this.length+c.length;return this.length===10&&c.length===10?b=N(this,c,d):x<63?b=O(this,c,d):x<1024?b=U(this,c,d):b=k(this,c,d),b};function B(p,c){this.x=p,this.y=c}B.prototype.makeRBT=function(c){for(var d=new Array(c),b=n.prototype._countBits(c)-1,x=0;x>=1;return x},B.prototype.permute=function(c,d,b,x,v,h){for(var _=0;_>>1)v++;return 1<>>13,b[2*h+1]=v&8191,v=v>>>13;for(h=2*d;h>=26,b+=v/67108864|0,b+=h>>>26,this.words[x]=h&67108863}return b!==0&&(this.words[x]=b,this.length++),d?this.ineg():this},n.prototype.muln=function(c){return this.clone().imuln(c)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(c){var d=R(c);if(d.length===0)return new n(1);for(var b=this,x=0;x=0);var d=c%26,b=(c-d)/26,x=67108863>>>26-d<<26-d,v;if(d!==0){var h=0;for(v=0;v>>26-d}h&&(this.words[v]=h,this.length++)}if(b!==0){for(v=this.length-1;v>=0;v--)this.words[v+b]=this.words[v];for(v=0;v=0);var x;d?x=(d-d%26)/26:x=0;var v=c%26,h=Math.min((c-v)/26,this.length),_=67108863^67108863>>>v<h)for(this.length-=h,m=0;m=0&&(M!==0||m>=x);m--){var z=this.words[m]|0;this.words[m]=M<<26-v|z>>>v,M=z&_}return T&&M!==0&&(T.words[T.length++]=M),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(c,d,b){return t(this.negative===0),this.iushrn(c,d,b)},n.prototype.shln=function(c){return this.clone().ishln(c)},n.prototype.ushln=function(c){return this.clone().iushln(c)},n.prototype.shrn=function(c){return this.clone().ishrn(c)},n.prototype.ushrn=function(c){return this.clone().iushrn(c)},n.prototype.testn=function(c){t(typeof c=="number"&&c>=0);var d=c%26,b=(c-d)/26,x=1<=0);var d=c%26,b=(c-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(d!==0&&b++,this.length=Math.min(b,this.length),d!==0){var x=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(c){if(t(typeof c=="number"),t(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(T/67108864|0),this.words[v+b]=h&67108863}for(;v>26,this.words[v+b]=h&67108863;if(_===0)return this._strip();for(t(_===-1),_=0,v=0;v>26,this.words[v]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(c,d){var b=this.length-c.length,x=this.clone(),v=c,h=v.words[v.length-1]|0,_=this._countBits(h);b=26-_,b!==0&&(v=v.ushln(b),x.iushln(b),h=v.words[v.length-1]|0);var T=x.length-v.length,m;if(d!=="mod"){m=new n(null),m.length=T+1,m.words=new Array(m.length);for(var M=0;M=0;E--){var C=(x.words[v.length+E]|0)*67108864+(x.words[v.length+E-1]|0);for(C=Math.min(C/h|0,67108863),x._ishlnsubmul(v,C,E);x.negative!==0;)C--,x.negative=0,x._ishlnsubmul(v,1,E),x.isZero()||(x.negative^=1);m&&(m.words[E]=C)}return m&&m._strip(),x._strip(),d!=="div"&&b!==0&&x.iushrn(b),{div:m||null,mod:x}},n.prototype.divmod=function(c,d,b){if(t(!c.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var x,v,h;return this.negative!==0&&c.negative===0?(h=this.neg().divmod(c,d),d!=="mod"&&(x=h.div.neg()),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.iadd(c)),{div:x,mod:v}):this.negative===0&&c.negative!==0?(h=this.divmod(c.neg(),d),d!=="mod"&&(x=h.div.neg()),{div:x,mod:h.mod}):this.negative&c.negative?(h=this.neg().divmod(c.neg(),d),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.isub(c)),{div:h.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new n(0),mod:this}:c.length===1?d==="div"?{div:this.divn(c.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new n(this.modrn(c.words[0]))}:this._wordDiv(c,d)},n.prototype.div=function(c){return this.divmod(c,"div",!1).div},n.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},n.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},n.prototype.divRound=function(c){var d=this.divmod(c);if(d.mod.isZero())return d.div;var b=d.div.negative!==0?d.mod.isub(c):d.mod,x=c.ushrn(1),v=c.andln(1),h=b.cmp(x);return h<0||v===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=(1<<26)%c,x=0,v=this.length-1;v>=0;v--)x=(b*x+(this.words[v]|0))%c;return d?-x:x},n.prototype.modn=function(c){return this.modrn(c)},n.prototype.idivn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=0,x=this.length-1;x>=0;x--){var v=(this.words[x]|0)+b*67108864;this.words[x]=v/c|0,b=v%c}return this._strip(),d?this.ineg():this},n.prototype.divn=function(c){return this.clone().idivn(c)},n.prototype.egcd=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=new n(0),_=new n(1),T=0;d.isEven()&&b.isEven();)d.iushrn(1),b.iushrn(1),++T;for(var m=b.clone(),M=d.clone();!d.isZero();){for(var z=0,E=1;!(d.words[0]&E)&&z<26;++z,E<<=1);if(z>0)for(d.iushrn(z);z-- >0;)(x.isOdd()||v.isOdd())&&(x.iadd(m),v.isub(M)),x.iushrn(1),v.iushrn(1);for(var C=0,F=1;!(b.words[0]&F)&&C<26;++C,F<<=1);if(C>0)for(b.iushrn(C);C-- >0;)(h.isOdd()||_.isOdd())&&(h.iadd(m),_.isub(M)),h.iushrn(1),_.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(h),v.isub(_)):(b.isub(d),h.isub(x),_.isub(v))}return{a:h,b:_,gcd:b.iushln(T)}},n.prototype._invmp=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=b.clone();d.cmpn(1)>0&&b.cmpn(1)>0;){for(var _=0,T=1;!(d.words[0]&T)&&_<26;++_,T<<=1);if(_>0)for(d.iushrn(_);_-- >0;)x.isOdd()&&x.iadd(h),x.iushrn(1);for(var m=0,M=1;!(b.words[0]&M)&&m<26;++m,M<<=1);if(m>0)for(b.iushrn(m);m-- >0;)v.isOdd()&&v.iadd(h),v.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(v)):(b.isub(d),v.isub(x))}var z;return d.cmpn(1)===0?z=x:z=v,z.cmpn(0)<0&&z.iadd(c),z},n.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var d=this.clone(),b=c.clone();d.negative=0,b.negative=0;for(var x=0;d.isEven()&&b.isEven();x++)d.iushrn(1),b.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;b.isEven();)b.iushrn(1);var v=d.cmp(b);if(v<0){var h=d;d=b,b=h}else if(v===0||b.cmpn(1)===0)break;d.isub(b)}while(!0);return b.iushln(x)},n.prototype.invm=function(c){return this.egcd(c).a.umod(c)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(c){return this.words[0]&c},n.prototype.bincn=function(c){t(typeof c=="number");var d=c%26,b=(c-d)/26,x=1<>>26,_&=67108863,this.words[h]=_}return v!==0&&(this.words[h]=v,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(c){var d=c<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var b;if(this.length>1)b=1;else{d&&(c=-c),t(c<=67108863,"Number is too big");var x=this.words[0]|0;b=x===c?0:xc.length)return 1;if(this.length=0;b--){var x=this.words[b]|0,v=c.words[b]|0;if(x!==v){xv&&(d=1);break}}return d},n.prototype.gtn=function(c){return this.cmpn(c)===1},n.prototype.gt=function(c){return this.cmp(c)===1},n.prototype.gten=function(c){return this.cmpn(c)>=0},n.prototype.gte=function(c){return this.cmp(c)>=0},n.prototype.ltn=function(c){return this.cmpn(c)===-1},n.prototype.lt=function(c){return this.cmp(c)===-1},n.prototype.lten=function(c){return this.cmpn(c)<=0},n.prototype.lte=function(c){return this.cmp(c)<=0},n.prototype.eqn=function(c){return this.cmpn(c)===0},n.prototype.eq=function(c){return this.cmp(c)===0},n.red=function(c){return new l(c)},n.prototype.toRed=function(c){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(c){return this.red=c,this},n.prototype.forceRed=function(c){return t(!this.red,"Already a number in reduction context"),this._forceRed(c)},n.prototype.redAdd=function(c){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},n.prototype.redIAdd=function(c){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},n.prototype.redSub=function(c){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},n.prototype.redISub=function(c){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},n.prototype.redShl=function(c){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},n.prototype.redMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},n.prototype.redIMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(c){return t(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var j={k256:null,p224:null,p192:null,p25519:null};function V(p,c){this.name=p,this.p=new n(c,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var c=new n(null);return c.words=new Array(Math.ceil(this.n/13)),c},V.prototype.ireduce=function(c){var d=c,b;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),b=d.bitLength();while(b>this.n);var x=b0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},V.prototype.split=function(c,d){c.iushrn(this.n,0,d)},V.prototype.imulK=function(c){return c.imul(this.k)};function L(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,V),L.prototype.split=function(c,d){for(var b=4194303,x=Math.min(c.length,9),v=0;v>>22,h=_}h>>>=22,c.words[v-10]=h,h===0&&c.length>10?c.length-=10:c.length-=9},L.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var d=0,b=0;b>>=26,c.words[b]=v,d=x}return d!==0&&(c.words[c.length++]=d),c},n._prime=function(c){if(j[c])return j[c];var d;if(c==="k256")d=new L;else if(c==="p224")d=new D;else if(c==="p192")d=new W;else if(c==="p25519")d=new P;else throw new Error("Unknown prime "+c);return j[c]=d,d};function l(p){if(typeof p=="string"){var c=n._prime(p);this.m=c.p,this.prime=c}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(c){t(c.negative===0,"red works only with positives"),t(c.red,"red works only with red numbers")},l.prototype._verify2=function(c,d){t((c.negative|d.negative)===0,"red works only with positives"),t(c.red&&c.red===d.red,"red works only with red numbers")},l.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(u(c,c.umod(this.m)._forceRed(this)),c)},l.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},l.prototype.add=function(c,d){this._verify2(c,d);var b=c.add(d);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},l.prototype.iadd=function(c,d){this._verify2(c,d);var b=c.iadd(d);return b.cmp(this.m)>=0&&b.isub(this.m),b},l.prototype.sub=function(c,d){this._verify2(c,d);var b=c.sub(d);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},l.prototype.isub=function(c,d){this._verify2(c,d);var b=c.isub(d);return b.cmpn(0)<0&&b.iadd(this.m),b},l.prototype.shl=function(c,d){return this._verify1(c),this.imod(c.ushln(d))},l.prototype.imul=function(c,d){return this._verify2(c,d),this.imod(c.imul(d))},l.prototype.mul=function(c,d){return this._verify2(c,d),this.imod(c.mul(d))},l.prototype.isqr=function(c){return this.imul(c,c.clone())},l.prototype.sqr=function(c){return this.mul(c,c)},l.prototype.sqrt=function(c){if(c.isZero())return c.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var b=this.m.add(new n(1)).iushrn(2);return this.pow(c,b)}for(var x=this.m.subn(1),v=0;!x.isZero()&&x.andln(1)===0;)v++,x.iushrn(1);t(!x.isZero());var h=new n(1).toRed(this),_=h.redNeg(),T=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new n(2*m*m).toRed(this);this.pow(m,T).cmp(_)!==0;)m.redIAdd(_);for(var M=this.pow(m,x),z=this.pow(c,x.addn(1).iushrn(1)),E=this.pow(c,x),C=v;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;v--){for(var M=d.words[v],z=m-1;z>=0;z--){var E=M>>z&1;if(h!==x[0]&&(h=this.sqr(h)),E===0&&_===0){T=0;continue}_<<=1,_|=E,T++,!(T!==b&&(v!==0||z!==0))&&(h=this.mul(h,x[_]),T=0,_=0)}m=26}return h},l.prototype.convertTo=function(c){var d=c.umod(this.m);return d===c?d.clone():d},l.prototype.convertFrom=function(c){var d=c.clone();return d.red=null,d},n.mont=function(c){return new w(c)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},w.prototype.convertFrom=function(c){var d=this.imod(c.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(c,d){if(c.isZero()||d.isZero())return c.words[0]=0,c.length=1,c;var b=c.imul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(c,d){if(c.isZero()||d.isZero())return new n(0)._forceRed(this);var b=c.mul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(c){var d=this.imod(c._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof md>"u"||md,xm)});var Qi=J((RC,Om)=>{Om.exports=Dm;function Dm(r,e){if(!r)throw new Error(e||"Assertion failed")}Dm.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var ua=J((PC,wd)=>{typeof Object.create=="function"?wd.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:wd.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var Ir=J(Ge=>{"use strict";var E8=Qi(),S8=ua();Ge.inherits=S8;function I8(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function A8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):I8(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ge.htonl=Lm;function M8(r,e){for(var t="",i=0;i>>0}return s}Ge.join32=R8;function P8(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ge.split32=P8;function N8(r,e){return r>>>e|r<<32-e}Ge.rotr32=N8;function C8(r,e){return r<>>32-e}Ge.rotl32=C8;function D8(r,e){return r+e>>>0}Ge.sum32=D8;function O8(r,e,t){return r+e+t>>>0}Ge.sum32_3=O8;function L8(r,e,t,i){return r+e+t+i>>>0}Ge.sum32_4=L8;function F8(r,e,t,i,n){return r+e+t+i+n>>>0}Ge.sum32_5=F8;function U8(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,a=(o>>0,r[e+1]=o}Ge.sum64=U8;function q8(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ge.sum64_hi=q8;function B8(r,e,t,i){var n=e+i;return n>>>0}Ge.sum64_lo=B8;function k8(r,e,t,i,n,s,o,a){var f=0,u=e;u=u+i>>>0,f+=u>>0,f+=u>>0,f+=u>>0}Ge.sum64_4_hi=k8;function z8(r,e,t,i,n,s,o,a){var f=e+i+s+a;return f>>>0}Ge.sum64_4_lo=z8;function j8(r,e,t,i,n,s,o,a,f,u){var g=0,y=e;y=y+i>>>0,g+=y>>0,g+=y>>0,g+=y>>0,g+=y>>0}Ge.sum64_5_hi=j8;function K8(r,e,t,i,n,s,o,a,f,u){var g=e+i+s+a+u;return g>>>0}Ge.sum64_5_lo=K8;function V8(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ge.rotr64_hi=V8;function $8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.rotr64_lo=$8;function H8(r,e,t){return r>>>t}Ge.shr64_hi=H8;function G8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.shr64_lo=G8});var Vs=J(Bm=>{"use strict";var qm=Ir(),W8=Qi();function df(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Bm.BlockHash=df;df.prototype.update=function(e,t){if(e=qm.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=qm.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var J8=Ir(),ii=J8.rotr32;function Y8(r,e,t,i){if(r===0)return km(e,t,i);if(r===1||r===3)return jm(e,t,i);if(r===2)return zm(e,t,i)}Ri.ft_1=Y8;function km(r,e,t){return r&e^~r&t}Ri.ch32=km;function zm(r,e,t){return r&e^r&t^e&t}Ri.maj32=zm;function jm(r,e,t){return r^e^t}Ri.p32=jm;function X8(r){return ii(r,2)^ii(r,13)^ii(r,22)}Ri.s0_256=X8;function Q8(r){return ii(r,6)^ii(r,11)^ii(r,25)}Ri.s1_256=Q8;function Z8(r){return ii(r,7)^ii(r,18)^r>>>3}Ri.g0_256=Z8;function e_(r){return ii(r,17)^ii(r,19)^r>>>10}Ri.g1_256=e_});var $m=J((OC,Vm)=>{"use strict";var $s=Ir(),t_=Vs(),r_=xd(),_d=$s.rotl32,ha=$s.sum32,i_=$s.sum32_5,n_=r_.ft_1,Km=t_.BlockHash,s_=[1518500249,1859775393,2400959708,3395469782];function ni(){if(!(this instanceof ni))return new ni;Km.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}$s.inherits(ni,Km);Vm.exports=ni;ni.blockSize=512;ni.outSize=160;ni.hmacStrength=80;ni.padLength=64;ni.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Hs=Ir(),o_=Vs(),Gs=xd(),a_=Qi(),Ar=Hs.sum32,c_=Hs.sum32_4,f_=Hs.sum32_5,u_=Gs.ch32,h_=Gs.maj32,d_=Gs.s0_256,l_=Gs.s1_256,p_=Gs.g0_256,g_=Gs.g1_256,Hm=o_.BlockHash,m_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function si(){if(!(this instanceof si))return new si;Hm.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m_,this.W=new Array(64)}Hs.inherits(si,Hm);Gm.exports=si;si.blockSize=512;si.outSize=256;si.hmacStrength=192;si.padLength=64;si.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Sd=Ir(),Wm=Ed();function Pi(){if(!(this instanceof Pi))return new Pi;Wm.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Sd.inherits(Pi,Wm);Jm.exports=Pi;Pi.blockSize=512;Pi.outSize=224;Pi.hmacStrength=192;Pi.padLength=64;Pi.prototype._digest=function(e){return e==="hex"?Sd.toHex32(this.h.slice(0,7),"big"):Sd.split32(this.h.slice(0,7),"big")}});var Td=J((UC,eb)=>{"use strict";var jt=Ir(),b_=Vs(),v_=Qi(),oi=jt.rotr64_hi,ai=jt.rotr64_lo,Xm=jt.shr64_hi,Qm=jt.shr64_lo,Zi=jt.sum64,Id=jt.sum64_hi,Ad=jt.sum64_lo,y_=jt.sum64_4_hi,w_=jt.sum64_4_lo,x_=jt.sum64_5_hi,__=jt.sum64_5_lo,Zm=b_.BlockHash,E_=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Tr(){if(!(this instanceof Tr))return new Tr;Zm.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=E_,this.W=new Array(160)}jt.inherits(Tr,Zm);eb.exports=Tr;Tr.blockSize=1024;Tr.outSize=512;Tr.hmacStrength=192;Tr.padLength=128;Tr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Md=Ir(),tb=Td();function Ni(){if(!(this instanceof Ni))return new Ni;tb.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Md.inherits(Ni,tb);rb.exports=Ni;Ni.blockSize=1024;Ni.outSize=384;Ni.hmacStrength=192;Ni.padLength=128;Ni.prototype._digest=function(e){return e==="hex"?Md.toHex32(this.h.slice(0,12),"big"):Md.split32(this.h.slice(0,12),"big")}});var nb=J(Ws=>{"use strict";Ws.sha1=$m();Ws.sha224=Ym();Ws.sha256=Ed();Ws.sha384=ib();Ws.sha512=Td()});var ub=J(fb=>{"use strict";var Yn=Ir(),F_=Vs(),lf=Yn.rotl32,sb=Yn.sum32,da=Yn.sum32_3,ob=Yn.sum32_4,cb=F_.BlockHash;function ci(){if(!(this instanceof ci))return new ci;cb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Yn.inherits(ci,cb);fb.ripemd160=ci;ci.blockSize=512;ci.outSize=160;ci.hmacStrength=192;ci.padLength=64;ci.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],f=i,u=n,g=s,y=o,S=a,I=0;I<80;I++){var A=sb(lf(ob(i,ab(I,n,s,o),e[B_[I]+t],U_(I)),z_[I]),a);i=a,a=o,o=lf(s,10),s=n,n=A,A=sb(lf(ob(f,ab(79-I,u,g,y),e[k_[I]+t],q_(I)),j_[I]),S),f=S,S=y,y=lf(g,10),g=u,u=A}A=da(this.h[1],s,y),this.h[1]=da(this.h[2],o,S),this.h[2]=da(this.h[3],a,f),this.h[3]=da(this.h[4],i,u),this.h[4]=da(this.h[0],n,g),this.h[0]=A};ci.prototype._digest=function(e){return e==="hex"?Yn.toHex32(this.h,"little"):Yn.split32(this.h,"little")};function ab(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function U_(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function q_(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var B_=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],k_=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],z_=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],j_=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var db=J((zC,hb)=>{"use strict";var K_=Ir(),V_=Qi();function Js(r,e,t){if(!(this instanceof Js))return new Js(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(K_.toArray(e,t))}hb.exports=Js;Js.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),V_(e.length<=this.blockSize);for(var t=e.length;t{var xt=lb;xt.utils=Ir();xt.common=Vs();xt.sha=nb();xt.ripemd=ub();xt.hmac=db();xt.sha1=xt.sha.sha1;xt.sha256=xt.sha.sha256;xt.sha224=xt.sha.sha224;xt.sha384=xt.sha.sha384;xt.sha512=xt.sha.sha512;xt.ripemd160=xt.ripemd.ripemd160});var Ib=J(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});var Nt=Ps(),Bd=fr(),tE=20;function rE(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,a=t[3]<<24|t[2]<<16|t[1]<<8|t[0],f=t[7]<<24|t[6]<<16|t[5]<<8|t[4],u=t[11]<<24|t[10]<<16|t[9]<<8|t[8],g=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],A=t[31]<<24|t[30]<<16|t[29]<<8|t[28],R=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],N=e[11]<<24|e[10]<<16|e[9]<<8|e[8],U=e[15]<<24|e[14]<<16|e[13]<<8|e[12],k=i,B=n,j=s,V=o,L=a,D=f,W=u,P=g,l=y,w=S,p=I,c=A,d=R,b=O,x=N,v=U,h=0;h>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,B=B+D|0,b^=B,b=b>>>16|b<<16,w=w+b|0,D^=w,D=D>>>20|D<<12,j=j+W|0,x^=j,x=x>>>16|x<<16,p=p+x|0,W^=p,W=W>>>20|W<<12,V=V+P|0,v^=V,v=v>>>16|v<<16,c=c+v|0,P^=c,P=P>>>20|P<<12,j=j+W|0,x^=j,x=x>>>24|x<<8,p=p+x|0,W^=p,W=W>>>25|W<<7,V=V+P|0,v^=V,v=v>>>24|v<<8,c=c+v|0,P^=c,P=P>>>25|P<<7,B=B+D|0,b^=B,b=b>>>24|b<<8,w=w+b|0,D^=w,D=D>>>25|D<<7,k=k+L|0,d^=k,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,k=k+D|0,v^=k,v=v>>>16|v<<16,p=p+v|0,D^=p,D=D>>>20|D<<12,B=B+W|0,d^=B,d=d>>>16|d<<16,c=c+d|0,W^=c,W=W>>>20|W<<12,j=j+P|0,b^=j,b=b>>>16|b<<16,l=l+b|0,P^=l,P=P>>>20|P<<12,V=V+L|0,x^=V,x=x>>>16|x<<16,w=w+x|0,L^=w,L=L>>>20|L<<12,j=j+P|0,b^=j,b=b>>>24|b<<8,l=l+b|0,P^=l,P=P>>>25|P<<7,V=V+L|0,x^=V,x=x>>>24|x<<8,w=w+x|0,L^=w,L=L>>>25|L<<7,B=B+W|0,d^=B,d=d>>>24|d<<8,c=c+d|0,W^=c,W=W>>>25|W<<7,k=k+D|0,v^=k,v=v>>>24|v<<8,p=p+v|0,D^=p,D=D>>>25|D<<7;Nt.writeUint32LE(k+i|0,r,0),Nt.writeUint32LE(B+n|0,r,4),Nt.writeUint32LE(j+s|0,r,8),Nt.writeUint32LE(V+o|0,r,12),Nt.writeUint32LE(L+a|0,r,16),Nt.writeUint32LE(D+f|0,r,20),Nt.writeUint32LE(W+u|0,r,24),Nt.writeUint32LE(P+g|0,r,28),Nt.writeUint32LE(l+y|0,r,32),Nt.writeUint32LE(w+S|0,r,36),Nt.writeUint32LE(p+I|0,r,40),Nt.writeUint32LE(c+A|0,r,44),Nt.writeUint32LE(d+R|0,r,48),Nt.writeUint32LE(b+O|0,r,52),Nt.writeUint32LE(x+N|0,r,56),Nt.writeUint32LE(v+U|0,r,60)}function Sb(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var xf=J(Xs=>{"use strict";Object.defineProperty(Xs,"__esModule",{value:!0});function sE(r,e,t){return~(r-1)&e|r-1&t}Xs.select=sE;function oE(r,e){return(r|0)-(e|0)-1>>>31&1}Xs.lessOrEqual=oE;function Ab(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Xs.compare=Ab;function aE(r,e){return r.length===0||e.length===0?!1:Ab(r,e)!==0}Xs.equal=aE});var Mb=J(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});var cE=xf(),_f=fr();Ci.DIGEST_LENGTH=16;var Tb=function(){function r(e){this.digestLength=Ci.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=(o>>>14|a<<2)&8191;var f=e[12]|e[13]<<8;this._r[7]=(a>>>11|f<<5)&8065;var u=e[14]|e[15]<<8;this._r[8]=(f>>>8|u<<8)&8191,this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],a=this._h[2],f=this._h[3],u=this._h[4],g=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],A=this._h[9],R=this._r[0],O=this._r[1],N=this._r[2],U=this._r[3],k=this._r[4],B=this._r[5],j=this._r[6],V=this._r[7],L=this._r[8],D=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var P=e[t+2]|e[t+3]<<8;o+=(W>>>13|P<<3)&8191;var l=e[t+4]|e[t+5]<<8;a+=(P>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;f+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;u+=(w>>>4|p<<12)&8191,g+=p>>>1&8191;var c=e[t+10]|e[t+11]<<8;y+=(p>>>14|c<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(c>>>11|d<<5)&8191;var b=e[t+14]|e[t+15]<<8;I+=(d>>>8|b<<8)&8191,A+=b>>>5|n;var x=0,v=x;v+=s*R,v+=o*(5*D),v+=a*(5*L),v+=f*(5*V),v+=u*(5*j),x=v>>>13,v&=8191,v+=g*(5*B),v+=y*(5*k),v+=S*(5*U),v+=I*(5*N),v+=A*(5*O),x+=v>>>13,v&=8191;var h=x;h+=s*O,h+=o*R,h+=a*(5*D),h+=f*(5*L),h+=u*(5*V),x=h>>>13,h&=8191,h+=g*(5*j),h+=y*(5*B),h+=S*(5*k),h+=I*(5*U),h+=A*(5*N),x+=h>>>13,h&=8191;var _=x;_+=s*N,_+=o*O,_+=a*R,_+=f*(5*D),_+=u*(5*L),x=_>>>13,_&=8191,_+=g*(5*V),_+=y*(5*j),_+=S*(5*B),_+=I*(5*k),_+=A*(5*U),x+=_>>>13,_&=8191;var T=x;T+=s*U,T+=o*N,T+=a*O,T+=f*R,T+=u*(5*D),x=T>>>13,T&=8191,T+=g*(5*L),T+=y*(5*V),T+=S*(5*j),T+=I*(5*B),T+=A*(5*k),x+=T>>>13,T&=8191;var m=x;m+=s*k,m+=o*U,m+=a*N,m+=f*O,m+=u*R,x=m>>>13,m&=8191,m+=g*(5*D),m+=y*(5*L),m+=S*(5*V),m+=I*(5*j),m+=A*(5*B),x+=m>>>13,m&=8191;var M=x;M+=s*B,M+=o*k,M+=a*U,M+=f*N,M+=u*O,x=M>>>13,M&=8191,M+=g*R,M+=y*(5*D),M+=S*(5*L),M+=I*(5*V),M+=A*(5*j),x+=M>>>13,M&=8191;var z=x;z+=s*j,z+=o*B,z+=a*k,z+=f*U,z+=u*N,x=z>>>13,z&=8191,z+=g*O,z+=y*R,z+=S*(5*D),z+=I*(5*L),z+=A*(5*V),x+=z>>>13,z&=8191;var E=x;E+=s*V,E+=o*j,E+=a*B,E+=f*k,E+=u*U,x=E>>>13,E&=8191,E+=g*N,E+=y*O,E+=S*R,E+=I*(5*D),E+=A*(5*L),x+=E>>>13,E&=8191;var C=x;C+=s*L,C+=o*V,C+=a*j,C+=f*B,C+=u*k,x=C>>>13,C&=8191,C+=g*U,C+=y*N,C+=S*O,C+=I*R,C+=A*(5*D),x+=C>>>13,C&=8191;var F=x;F+=s*D,F+=o*L,F+=a*V,F+=f*j,F+=u*B,x=F>>>13,F&=8191,F+=g*k,F+=y*U,F+=S*N,F+=I*O,F+=A*R,x+=F>>>13,F&=8191,x=(x<<2)+x|0,x=x+v|0,v=x&8191,x=x>>>13,h+=x,s=v,o=h,a=_,f=T,u=m,g=M,y=z,S=E,I=C,A=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=a,this._h[3]=f,this._h[4]=u,this._h[5]=g,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=A},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,a;if(this._leftover){for(a=this._leftover,this._buffer[a++]=1;a<16;a++)this._buffer[a]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,a=2;a<10;a++)this._h[a]+=n,n=this._h[a]>>>13,this._h[a]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,a=1;a<10;a++)i[a]=this._h[a]+n,n=i[a]>>>13,i[a]&=8191;for(i[9]-=8192,s=(n^1)-1,a=0;a<10;a++)i[a]&=s;for(s=~s,a=0;a<10;a++)this._h[a]=this._h[a]&s|i[a];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,a=1;a<8;a++)o=(this._h[a]+this._pad[a]|0)+(o>>>16)|0,this._h[a]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});var Ef=Ib(),hE=Mb(),pa=fr(),Rb=Ps(),dE=xf();Di.KEY_LENGTH=32;Di.NONCE_LENGTH=12;Di.TAG_LENGTH=16;var Pb=new Uint8Array(16),lE=function(){function r(e){if(this.nonceLength=Di.NONCE_LENGTH,this.tagLength=Di.TAG_LENGTH,e.length!==Di.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);Ef.stream(this._key,s,o,4);var a=t.length+this.tagLength,f;if(n){if(n.length!==a)throw new Error("ChaCha20Poly1305: incorrect destination length");f=n}else f=new Uint8Array(a);return Ef.streamXOR(this._key,s,t,f,4),this._authenticate(f.subarray(f.length-this.tagLength,f.length),o,f.subarray(0,f.length-this.tagLength),i),pa.wipe(s),f},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(Pb.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(Pb.subarray(i.length%16));var o=new Uint8Array(8);n&&Rb.writeUint64LE(n.length,o),s.update(o),Rb.writeUint64LE(i.length,o),s.update(o);for(var a=s.digest(),f=0;f{"use strict";Object.defineProperty(kd,"__esModule",{value:!0});function pE(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}kd.isSerializableHash=pE});var Ob=J(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});var hi=Cb(),gE=xf(),mE=fr(),Db=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(zd,"__esModule",{value:!0});var Lb=Ob(),Fb=fr(),vE=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Lb.hmac(this._hash,i,t);this._hmac=new Lb.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});var If=Ps(),Sf=fr();rn.DIGEST_LENGTH=32;rn.BLOCK_SIZE=64;var qb=function(){function r(){this.digestLength=rn.DIGEST_LENGTH,this.blockSize=rn.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Sf.wipe(this._buffer),Sf.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jd(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jd(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Sf.wipe(e.state),e.buffer&&Sf.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();rn.SHA256=qb;var yE=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function jd(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],a=e[2],f=e[3],u=e[4],g=e[5],y=e[6],S=e[7],I=0;I<16;I++){var A=i+I*4;r[I]=If.readUint32BE(t,A)}for(var I=16;I<64;I++){var R=r[I-2],O=(R>>>17|R<<15)^(R>>>19|R<<13)^R>>>10;R=r[I-15];var N=(R>>>7|R<<25)^(R>>>18|R<<14)^R>>>3;r[I]=(O+r[I-7]|0)+(N+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&g^~u&y)|0)+(S+(yE[I]+r[I]|0)|0)|0,N=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&a^o&a)|0;S=y,y=g,g=u,u=f+O|0,f=a,a=o,o=s,s=O+N|0}e[0]+=s,e[1]+=o,e[2]+=a,e[3]+=f,e[4]+=u,e[5]+=g,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function wE(r){var e=new qb;e.update(r);var t=e.digest();return e.clean(),t}rn.hash=wE});var Kb=J(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.sharedKey=it.generateKeyPair=it.generateKeyPairFromSeed=it.scalarMultBase=it.scalarMult=it.SHARED_KEY_LENGTH=it.SECRET_KEY_LENGTH=it.PUBLIC_KEY_LENGTH=void 0;var xE=Yo(),_E=fr();it.PUBLIC_KEY_LENGTH=32;it.SECRET_KEY_LENGTH=32;it.SHARED_KEY_LENGTH=32;function di(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,ma(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function IE(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Af(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function Tf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function Oi(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,R=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,D=0,W=0,P=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],T=t[1],m=t[2],M=t[3],z=t[4],E=t[5],C=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*T,a+=i*m,f+=i*M,u+=i*z,g+=i*E,y+=i*C,S+=i*F,I+=i*q,A+=i*K,R+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*T,f+=i*m,u+=i*M,g+=i*z,y+=i*E,S+=i*C,I+=i*F,A+=i*q,R+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*T,u+=i*m,g+=i*M,y+=i*z,S+=i*E,I+=i*C,A+=i*F,R+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*T,g+=i*m,y+=i*M,S+=i*z,I+=i*E,A+=i*C,R+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*T,y+=i*m,S+=i*M,I+=i*z,A+=i*E,R+=i*C,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,D+=i*X,i=e[5],g+=i*_,y+=i*T,S+=i*m,I+=i*M,A+=i*z,R+=i*E,O+=i*C,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,D+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*T,I+=i*m,A+=i*M,R+=i*z,O+=i*E,N+=i*C,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,D+=i*ee,W+=i*G,P+=i*X,i=e[7],S+=i*_,I+=i*T,A+=i*m,R+=i*M,O+=i*z,N+=i*E,U+=i*C,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,D+=i*$,W+=i*ee,P+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*T,R+=i*m,O+=i*M,N+=i*z,U+=i*E,k+=i*C,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,D+=i*H,W+=i*$,P+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,R+=i*T,O+=i*m,N+=i*M,U+=i*z,k+=i*E,B+=i*C,j+=i*F,V+=i*q,L+=i*K,D+=i*Y,W+=i*H,P+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],R+=i*_,O+=i*T,N+=i*m,U+=i*M,k+=i*z,B+=i*E,j+=i*C,V+=i*F,L+=i*q,D+=i*K,W+=i*Y,P+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*T,U+=i*m,k+=i*M,B+=i*z,j+=i*E,V+=i*C,L+=i*F,D+=i*q,W+=i*K,P+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*T,k+=i*m,B+=i*M,j+=i*z,V+=i*E,L+=i*C,D+=i*F,W+=i*q,P+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*T,B+=i*m,j+=i*M,V+=i*z,L+=i*E,D+=i*C,W+=i*F,P+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*T,j+=i*m,V+=i*M,L+=i*z,D+=i*E,W+=i*C,P+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*T,V+=i*m,L+=i*M,D+=i*z,W+=i*E,P+=i*C,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*D,u+=38*W,g+=38*P,y+=38*l,S+=38*w,I+=38*p,A+=38*c,R+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=R,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function ba(r,e){Oi(r,e,e)}function AE(r,e){let t=di();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)ba(t,t),i!==2&&i!==4&&Oi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function Vd(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=di(),s=di(),o=di(),a=di(),f=di(),u=di();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,IE(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=a[0]=1;for(let I=254;I>=0;--I){let A=t[I>>>3]>>>(I&7)&1;ma(n,s,A),ma(o,a,A),Af(f,n,o),Tf(n,n,o),Af(o,s,a),Tf(s,s,a),ba(a,f),ba(u,n),Oi(n,o,n),Oi(o,s,f),Af(f,n,o),Tf(n,n,o),ba(s,n),Tf(o,a,u),Oi(n,o,EE),Af(n,n,a),Oi(o,o,n),Oi(n,a,u),Oi(a,s,i),ba(s,f),ma(n,s,A),ma(o,a,A)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=a[I];let g=i.subarray(32),y=i.subarray(16);AE(g,g),Oi(y,y,g);let S=new Uint8Array(32);return SE(S,y),S}it.scalarMult=Vd;function zb(r){return Vd(r,kb)}it.scalarMultBase=zb;function jb(r){if(r.length!==it.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${it.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:zb(e),secretKey:e}}it.generateKeyPairFromSeed=jb;function TE(r){let e=(0,xE.randomBytes)(32,r),t=jb(e);return(0,_E.wipe)(e),t}it.generateKeyPair=TE;function ME(r,e,t=!1){if(r.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=Vd(r,e);if(t){let n=0;for(let s=0;s{RE.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var li=J(($b,$d)=>{(function(r,e){"use strict";function t(P,l){if(!P)throw new Error(l||"Assertion failed")}function i(P,l){P.super_=l;var w=function(){};w.prototype=l.prototype,P.prototype=new w,P.prototype.constructor=P}function n(P,l,w){if(n.isBN(P))return P;this.negative=0,this.words=null,this.length=0,this.red=null,P!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(P||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=gd().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var c=0;l[0]==="-"&&(c++,this.negative=1),c=0;c-=3)b=l[c]|l[c-1]<<8|l[c-2]<<16,this.words[d]|=b<>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);else if(p==="le")for(c=0,d=0;c>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);return this.strip()};function o(P,l){var w=P.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function a(P,l,w){var p=o(P,w);return w-1>=l&&(p|=o(P,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var c=0;c=w;c-=2)x=a(l,w,c)<=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8;else{var v=l.length-w;for(c=v%2===0?w+1:w;c=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8}this.strip()};function f(P,l,w,p){for(var c=0,d=Math.min(P.length,w),b=l;b=49?c+=x-49+10:x>=17?c+=x-17+10:c+=x}return c}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var c=0,d=1;d<=67108863;d*=w)c++;c--,d=d/w|0;for(var b=l.length-p,x=b%c,v=Math.min(b,b-x)+p,h=0,_=p;_1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var c=0,d=0,b=0;b>>24-c&16777215,d!==0||b!==this.length-1?p=u[6-v.length]+v+p:p=v+p,c+=2,c>=26&&(c-=26,b--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=g[l],_=y[l];p="";var T=this.clone();for(T.negative=0;!T.isZero();){var m=T.modn(_).toString(l);T=T.idivn(_),T.isZero()?p=m+p:p=u[h-m.length]+m+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var c=this.byteLength(),d=p||Math.max(1,c);t(c<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var b=w==="le",x=new l(d),v,h,_=this.clone();if(b){for(h=0;!_.isZero();h++)v=_.andln(255),_.iushrn(8),x[h]=v;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(P){for(var l=new Array(P.bitLength()),w=0;w>>c}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var c=0;cl.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var c=0;c0&&(this.words[c]=~this.words[c]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,c=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,c=l):(p=l,c=this);for(var d=0,b=0;b>>26;for(;d!==0&&b>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;bl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var c,d;p>0?(c=this,d=l):(c=l,d=this);for(var b=0,x=0;x>26,this.words[x]=w&67108863;for(;b!==0&&x>26,this.words[x]=w&67108863;if(b===0&&x>>26,T=v&67108863,m=Math.min(h,l.length-1),M=Math.max(0,h-P.length+1);M<=m;M++){var z=h-M|0;c=P.words[z]|0,d=l.words[M]|0,b=c*d+T,_+=b/67108864|0,T=b&67108863}w.words[h]=T|0,v=_|0}return v!==0?w.words[h]=v|0:w.length--,w.strip()}var A=function(l,w,p){var c=l.words,d=w.words,b=p.words,x=0,v,h,_,T=c[0]|0,m=T&8191,M=T>>>13,z=c[1]|0,E=z&8191,C=z>>>13,F=c[2]|0,q=F&8191,K=F>>>13,Y=c[3]|0,H=Y&8191,$=Y>>>13,ee=c[4]|0,G=ee&8191,X=ee>>>13,qr=c[5]|0,se=qr&8191,oe=qr>>>13,Br=c[6]|0,ae=Br&8191,ce=Br>>>13,kr=c[7]|0,fe=kr&8191,ue=kr>>>13,zr=c[8]|0,he=zr&8191,de=zr>>>13,jr=c[9]|0,le=jr&8191,pe=jr>>>13,Kr=d[0]|0,ge=Kr&8191,me=Kr>>>13,Vr=d[1]|0,be=Vr&8191,ve=Vr>>>13,$r=d[2]|0,ye=$r&8191,we=$r>>>13,Hr=d[3]|0,xe=Hr&8191,_e=Hr>>>13,Gr=d[4]|0,Ee=Gr&8191,Se=Gr>>>13,Wr=d[5]|0,Ie=Wr&8191,Ae=Wr>>>13,Jr=d[6]|0,Te=Jr&8191,Me=Jr>>>13,Yr=d[7]|0,Re=Yr&8191,Pe=Yr>>>13,Xr=d[8]|0,Ne=Xr&8191,Ce=Xr>>>13,Qr=d[9]|0,De=Qr&8191,Oe=Qr>>>13;p.negative=l.negative^w.negative,p.length=19,v=Math.imul(m,ge),h=Math.imul(m,me),h=h+Math.imul(M,ge)|0,_=Math.imul(M,me);var yr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(yr>>>26)|0,yr&=67108863,v=Math.imul(E,ge),h=Math.imul(E,me),h=h+Math.imul(C,ge)|0,_=Math.imul(C,me),v=v+Math.imul(m,be)|0,h=h+Math.imul(m,ve)|0,h=h+Math.imul(M,be)|0,_=_+Math.imul(M,ve)|0;var Ke=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,v=Math.imul(q,ge),h=Math.imul(q,me),h=h+Math.imul(K,ge)|0,_=Math.imul(K,me),v=v+Math.imul(E,be)|0,h=h+Math.imul(E,ve)|0,h=h+Math.imul(C,be)|0,_=_+Math.imul(C,ve)|0,v=v+Math.imul(m,ye)|0,h=h+Math.imul(m,we)|0,h=h+Math.imul(M,ye)|0,_=_+Math.imul(M,we)|0;var Ve=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,v=Math.imul(H,ge),h=Math.imul(H,me),h=h+Math.imul($,ge)|0,_=Math.imul($,me),v=v+Math.imul(q,be)|0,h=h+Math.imul(q,ve)|0,h=h+Math.imul(K,be)|0,_=_+Math.imul(K,ve)|0,v=v+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(C,ye)|0,_=_+Math.imul(C,we)|0,v=v+Math.imul(m,xe)|0,h=h+Math.imul(m,_e)|0,h=h+Math.imul(M,xe)|0,_=_+Math.imul(M,_e)|0;var rr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(rr>>>26)|0,rr&=67108863,v=Math.imul(G,ge),h=Math.imul(G,me),h=h+Math.imul(X,ge)|0,_=Math.imul(X,me),v=v+Math.imul(H,be)|0,h=h+Math.imul(H,ve)|0,h=h+Math.imul($,be)|0,_=_+Math.imul($,ve)|0,v=v+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,_=_+Math.imul(K,we)|0,v=v+Math.imul(E,xe)|0,h=h+Math.imul(E,_e)|0,h=h+Math.imul(C,xe)|0,_=_+Math.imul(C,_e)|0,v=v+Math.imul(m,Ee)|0,h=h+Math.imul(m,Se)|0,h=h+Math.imul(M,Ee)|0,_=_+Math.imul(M,Se)|0;var ir=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(ir>>>26)|0,ir&=67108863,v=Math.imul(se,ge),h=Math.imul(se,me),h=h+Math.imul(oe,ge)|0,_=Math.imul(oe,me),v=v+Math.imul(G,be)|0,h=h+Math.imul(G,ve)|0,h=h+Math.imul(X,be)|0,_=_+Math.imul(X,ve)|0,v=v+Math.imul(H,ye)|0,h=h+Math.imul(H,we)|0,h=h+Math.imul($,ye)|0,_=_+Math.imul($,we)|0,v=v+Math.imul(q,xe)|0,h=h+Math.imul(q,_e)|0,h=h+Math.imul(K,xe)|0,_=_+Math.imul(K,_e)|0,v=v+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(C,Ee)|0,_=_+Math.imul(C,Se)|0,v=v+Math.imul(m,Ie)|0,h=h+Math.imul(m,Ae)|0,h=h+Math.imul(M,Ie)|0,_=_+Math.imul(M,Ae)|0;var nr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,v=Math.imul(ae,ge),h=Math.imul(ae,me),h=h+Math.imul(ce,ge)|0,_=Math.imul(ce,me),v=v+Math.imul(se,be)|0,h=h+Math.imul(se,ve)|0,h=h+Math.imul(oe,be)|0,_=_+Math.imul(oe,ve)|0,v=v+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(X,ye)|0,_=_+Math.imul(X,we)|0,v=v+Math.imul(H,xe)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul($,xe)|0,_=_+Math.imul($,_e)|0,v=v+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,_=_+Math.imul(K,Se)|0,v=v+Math.imul(E,Ie)|0,h=h+Math.imul(E,Ae)|0,h=h+Math.imul(C,Ie)|0,_=_+Math.imul(C,Ae)|0,v=v+Math.imul(m,Te)|0,h=h+Math.imul(m,Me)|0,h=h+Math.imul(M,Te)|0,_=_+Math.imul(M,Me)|0;var sr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(sr>>>26)|0,sr&=67108863,v=Math.imul(fe,ge),h=Math.imul(fe,me),h=h+Math.imul(ue,ge)|0,_=Math.imul(ue,me),v=v+Math.imul(ae,be)|0,h=h+Math.imul(ae,ve)|0,h=h+Math.imul(ce,be)|0,_=_+Math.imul(ce,ve)|0,v=v+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,_=_+Math.imul(oe,we)|0,v=v+Math.imul(G,xe)|0,h=h+Math.imul(G,_e)|0,h=h+Math.imul(X,xe)|0,_=_+Math.imul(X,_e)|0,v=v+Math.imul(H,Ee)|0,h=h+Math.imul(H,Se)|0,h=h+Math.imul($,Ee)|0,_=_+Math.imul($,Se)|0,v=v+Math.imul(q,Ie)|0,h=h+Math.imul(q,Ae)|0,h=h+Math.imul(K,Ie)|0,_=_+Math.imul(K,Ae)|0,v=v+Math.imul(E,Te)|0,h=h+Math.imul(E,Me)|0,h=h+Math.imul(C,Te)|0,_=_+Math.imul(C,Me)|0,v=v+Math.imul(m,Re)|0,h=h+Math.imul(m,Pe)|0,h=h+Math.imul(M,Re)|0,_=_+Math.imul(M,Pe)|0;var or=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(or>>>26)|0,or&=67108863,v=Math.imul(he,ge),h=Math.imul(he,me),h=h+Math.imul(de,ge)|0,_=Math.imul(de,me),v=v+Math.imul(fe,be)|0,h=h+Math.imul(fe,ve)|0,h=h+Math.imul(ue,be)|0,_=_+Math.imul(ue,ve)|0,v=v+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(ce,ye)|0,_=_+Math.imul(ce,we)|0,v=v+Math.imul(se,xe)|0,h=h+Math.imul(se,_e)|0,h=h+Math.imul(oe,xe)|0,_=_+Math.imul(oe,_e)|0,v=v+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(X,Ee)|0,_=_+Math.imul(X,Se)|0,v=v+Math.imul(H,Ie)|0,h=h+Math.imul(H,Ae)|0,h=h+Math.imul($,Ie)|0,_=_+Math.imul($,Ae)|0,v=v+Math.imul(q,Te)|0,h=h+Math.imul(q,Me)|0,h=h+Math.imul(K,Te)|0,_=_+Math.imul(K,Me)|0,v=v+Math.imul(E,Re)|0,h=h+Math.imul(E,Pe)|0,h=h+Math.imul(C,Re)|0,_=_+Math.imul(C,Pe)|0,v=v+Math.imul(m,Ne)|0,h=h+Math.imul(m,Ce)|0,h=h+Math.imul(M,Ne)|0,_=_+Math.imul(M,Ce)|0;var Tn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,v=Math.imul(le,ge),h=Math.imul(le,me),h=h+Math.imul(pe,ge)|0,_=Math.imul(pe,me),v=v+Math.imul(he,be)|0,h=h+Math.imul(he,ve)|0,h=h+Math.imul(de,be)|0,_=_+Math.imul(de,ve)|0,v=v+Math.imul(fe,ye)|0,h=h+Math.imul(fe,we)|0,h=h+Math.imul(ue,ye)|0,_=_+Math.imul(ue,we)|0,v=v+Math.imul(ae,xe)|0,h=h+Math.imul(ae,_e)|0,h=h+Math.imul(ce,xe)|0,_=_+Math.imul(ce,_e)|0,v=v+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,_=_+Math.imul(oe,Se)|0,v=v+Math.imul(G,Ie)|0,h=h+Math.imul(G,Ae)|0,h=h+Math.imul(X,Ie)|0,_=_+Math.imul(X,Ae)|0,v=v+Math.imul(H,Te)|0,h=h+Math.imul(H,Me)|0,h=h+Math.imul($,Te)|0,_=_+Math.imul($,Me)|0,v=v+Math.imul(q,Re)|0,h=h+Math.imul(q,Pe)|0,h=h+Math.imul(K,Re)|0,_=_+Math.imul(K,Pe)|0,v=v+Math.imul(E,Ne)|0,h=h+Math.imul(E,Ce)|0,h=h+Math.imul(C,Ne)|0,_=_+Math.imul(C,Ce)|0,v=v+Math.imul(m,De)|0,h=h+Math.imul(m,Oe)|0,h=h+Math.imul(M,De)|0,_=_+Math.imul(M,Oe)|0;var Mn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,v=Math.imul(le,be),h=Math.imul(le,ve),h=h+Math.imul(pe,be)|0,_=Math.imul(pe,ve),v=v+Math.imul(he,ye)|0,h=h+Math.imul(he,we)|0,h=h+Math.imul(de,ye)|0,_=_+Math.imul(de,we)|0,v=v+Math.imul(fe,xe)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(ue,xe)|0,_=_+Math.imul(ue,_e)|0,v=v+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(ce,Ee)|0,_=_+Math.imul(ce,Se)|0,v=v+Math.imul(se,Ie)|0,h=h+Math.imul(se,Ae)|0,h=h+Math.imul(oe,Ie)|0,_=_+Math.imul(oe,Ae)|0,v=v+Math.imul(G,Te)|0,h=h+Math.imul(G,Me)|0,h=h+Math.imul(X,Te)|0,_=_+Math.imul(X,Me)|0,v=v+Math.imul(H,Re)|0,h=h+Math.imul(H,Pe)|0,h=h+Math.imul($,Re)|0,_=_+Math.imul($,Pe)|0,v=v+Math.imul(q,Ne)|0,h=h+Math.imul(q,Ce)|0,h=h+Math.imul(K,Ne)|0,_=_+Math.imul(K,Ce)|0,v=v+Math.imul(E,De)|0,h=h+Math.imul(E,Oe)|0,h=h+Math.imul(C,De)|0,_=_+Math.imul(C,Oe)|0;var Rn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,v=Math.imul(le,ye),h=Math.imul(le,we),h=h+Math.imul(pe,ye)|0,_=Math.imul(pe,we),v=v+Math.imul(he,xe)|0,h=h+Math.imul(he,_e)|0,h=h+Math.imul(de,xe)|0,_=_+Math.imul(de,_e)|0,v=v+Math.imul(fe,Ee)|0,h=h+Math.imul(fe,Se)|0,h=h+Math.imul(ue,Ee)|0,_=_+Math.imul(ue,Se)|0,v=v+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Ae)|0,h=h+Math.imul(ce,Ie)|0,_=_+Math.imul(ce,Ae)|0,v=v+Math.imul(se,Te)|0,h=h+Math.imul(se,Me)|0,h=h+Math.imul(oe,Te)|0,_=_+Math.imul(oe,Me)|0,v=v+Math.imul(G,Re)|0,h=h+Math.imul(G,Pe)|0,h=h+Math.imul(X,Re)|0,_=_+Math.imul(X,Pe)|0,v=v+Math.imul(H,Ne)|0,h=h+Math.imul(H,Ce)|0,h=h+Math.imul($,Ne)|0,_=_+Math.imul($,Ce)|0,v=v+Math.imul(q,De)|0,h=h+Math.imul(q,Oe)|0,h=h+Math.imul(K,De)|0,_=_+Math.imul(K,Oe)|0;var Pn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,v=Math.imul(le,xe),h=Math.imul(le,_e),h=h+Math.imul(pe,xe)|0,_=Math.imul(pe,_e),v=v+Math.imul(he,Ee)|0,h=h+Math.imul(he,Se)|0,h=h+Math.imul(de,Ee)|0,_=_+Math.imul(de,Se)|0,v=v+Math.imul(fe,Ie)|0,h=h+Math.imul(fe,Ae)|0,h=h+Math.imul(ue,Ie)|0,_=_+Math.imul(ue,Ae)|0,v=v+Math.imul(ae,Te)|0,h=h+Math.imul(ae,Me)|0,h=h+Math.imul(ce,Te)|0,_=_+Math.imul(ce,Me)|0,v=v+Math.imul(se,Re)|0,h=h+Math.imul(se,Pe)|0,h=h+Math.imul(oe,Re)|0,_=_+Math.imul(oe,Pe)|0,v=v+Math.imul(G,Ne)|0,h=h+Math.imul(G,Ce)|0,h=h+Math.imul(X,Ne)|0,_=_+Math.imul(X,Ce)|0,v=v+Math.imul(H,De)|0,h=h+Math.imul(H,Oe)|0,h=h+Math.imul($,De)|0,_=_+Math.imul($,Oe)|0;var Nn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,v=Math.imul(le,Ee),h=Math.imul(le,Se),h=h+Math.imul(pe,Ee)|0,_=Math.imul(pe,Se),v=v+Math.imul(he,Ie)|0,h=h+Math.imul(he,Ae)|0,h=h+Math.imul(de,Ie)|0,_=_+Math.imul(de,Ae)|0,v=v+Math.imul(fe,Te)|0,h=h+Math.imul(fe,Me)|0,h=h+Math.imul(ue,Te)|0,_=_+Math.imul(ue,Me)|0,v=v+Math.imul(ae,Re)|0,h=h+Math.imul(ae,Pe)|0,h=h+Math.imul(ce,Re)|0,_=_+Math.imul(ce,Pe)|0,v=v+Math.imul(se,Ne)|0,h=h+Math.imul(se,Ce)|0,h=h+Math.imul(oe,Ne)|0,_=_+Math.imul(oe,Ce)|0,v=v+Math.imul(G,De)|0,h=h+Math.imul(G,Oe)|0,h=h+Math.imul(X,De)|0,_=_+Math.imul(X,Oe)|0;var Cn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Cn>>>26)|0,Cn&=67108863,v=Math.imul(le,Ie),h=Math.imul(le,Ae),h=h+Math.imul(pe,Ie)|0,_=Math.imul(pe,Ae),v=v+Math.imul(he,Te)|0,h=h+Math.imul(he,Me)|0,h=h+Math.imul(de,Te)|0,_=_+Math.imul(de,Me)|0,v=v+Math.imul(fe,Re)|0,h=h+Math.imul(fe,Pe)|0,h=h+Math.imul(ue,Re)|0,_=_+Math.imul(ue,Pe)|0,v=v+Math.imul(ae,Ne)|0,h=h+Math.imul(ae,Ce)|0,h=h+Math.imul(ce,Ne)|0,_=_+Math.imul(ce,Ce)|0,v=v+Math.imul(se,De)|0,h=h+Math.imul(se,Oe)|0,h=h+Math.imul(oe,De)|0,_=_+Math.imul(oe,Oe)|0;var Dn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,v=Math.imul(le,Te),h=Math.imul(le,Me),h=h+Math.imul(pe,Te)|0,_=Math.imul(pe,Me),v=v+Math.imul(he,Re)|0,h=h+Math.imul(he,Pe)|0,h=h+Math.imul(de,Re)|0,_=_+Math.imul(de,Pe)|0,v=v+Math.imul(fe,Ne)|0,h=h+Math.imul(fe,Ce)|0,h=h+Math.imul(ue,Ne)|0,_=_+Math.imul(ue,Ce)|0,v=v+Math.imul(ae,De)|0,h=h+Math.imul(ae,Oe)|0,h=h+Math.imul(ce,De)|0,_=_+Math.imul(ce,Oe)|0;var On=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(On>>>26)|0,On&=67108863,v=Math.imul(le,Re),h=Math.imul(le,Pe),h=h+Math.imul(pe,Re)|0,_=Math.imul(pe,Pe),v=v+Math.imul(he,Ne)|0,h=h+Math.imul(he,Ce)|0,h=h+Math.imul(de,Ne)|0,_=_+Math.imul(de,Ce)|0,v=v+Math.imul(fe,De)|0,h=h+Math.imul(fe,Oe)|0,h=h+Math.imul(ue,De)|0,_=_+Math.imul(ue,Oe)|0;var Ln=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ln>>>26)|0,Ln&=67108863,v=Math.imul(le,Ne),h=Math.imul(le,Ce),h=h+Math.imul(pe,Ne)|0,_=Math.imul(pe,Ce),v=v+Math.imul(he,De)|0,h=h+Math.imul(he,Oe)|0,h=h+Math.imul(de,De)|0,_=_+Math.imul(de,Oe)|0;var Fn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Fn>>>26)|0,Fn&=67108863,v=Math.imul(le,De),h=Math.imul(le,Oe),h=h+Math.imul(pe,De)|0,_=Math.imul(pe,Oe);var Un=(x+v|0)+((h&8191)<<13)|0;return x=(_+(h>>>13)|0)+(Un>>>26)|0,Un&=67108863,b[0]=yr,b[1]=Ke,b[2]=Ve,b[3]=rr,b[4]=ir,b[5]=nr,b[6]=sr,b[7]=or,b[8]=Tn,b[9]=Mn,b[10]=Rn,b[11]=Pn,b[12]=Nn,b[13]=Cn,b[14]=Dn,b[15]=On,b[16]=Ln,b[17]=Fn,b[18]=Un,x!==0&&(b[19]=x,p.length++),p};Math.imul||(A=I);function R(P,l,w){w.negative=l.negative^P.negative,w.length=P.length+l.length;for(var p=0,c=0,d=0;d>>26)|0,c+=b>>>26,b&=67108863}w.words[d]=x,p=b,b=c}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(P,l,w){var p=new N;return p.mulp(P,l,w)}n.prototype.mulTo=function(l,w){var p,c=this.length+l.length;return this.length===10&&l.length===10?p=A(this,l,w):c<63?p=I(this,l,w):c<1024?p=R(this,l,w):p=O(this,l,w),p};function N(P,l){this.x=P,this.y=l}N.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,c=0;c>=1;return c},N.prototype.permute=function(l,w,p,c,d,b){for(var x=0;x>>1)d++;return 1<>>13,p[2*b+1]=d&8191,d=d>>>13;for(b=2*w;b>=26,w+=c/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,c=0;c=0);var w=l%26,p=(l-w)/26,c=67108863>>>26-w<<26-w,d;if(w!==0){var b=0;for(d=0;d>>26-w}b&&(this.words[d]=b,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var c;w?c=(w-w%26)/26:c=0;var d=l%26,b=Math.min((l-d)/26,this.length),x=67108863^67108863>>>d<b)for(this.length-=b,h=0;h=0&&(_!==0||h>=c);h--){var T=this.words[h]|0;this.words[h]=_<<26-d|T>>>d,_=T&x}return v&&_!==0&&(v.words[v.length++]=_),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,c=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var c=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(v/67108864|0),this.words[d+p]=b&67108863}for(;d>26,this.words[d+p]=b&67108863;if(x===0)return this.strip();for(t(x===-1),x=0,d=0;d>26,this.words[d]=b&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,c=this.clone(),d=l,b=d.words[d.length-1]|0,x=this._countBits(b);p=26-x,p!==0&&(d=d.ushln(p),c.iushln(p),b=d.words[d.length-1]|0);var v=c.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=v+1,h.words=new Array(h.length);for(var _=0;_=0;m--){var M=(c.words[d.length+m]|0)*67108864+(c.words[d.length+m-1]|0);for(M=Math.min(M/b|0,67108863),c._ishlnsubmul(d,M,m);c.negative!==0;)M--,c.negative=0,c._ishlnsubmul(d,1,m),c.isZero()||(c.negative^=1);h&&(h.words[m]=M)}return h&&h.strip(),c.strip(),w!=="div"&&p!==0&&c.iushrn(p),{div:h||null,mod:c}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var c,d,b;return this.negative!==0&&l.negative===0?(b=this.neg().divmod(l,w),w!=="mod"&&(c=b.div.neg()),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:c,mod:d}):this.negative===0&&l.negative!==0?(b=this.divmod(l.neg(),w),w!=="mod"&&(c=b.div.neg()),{div:c,mod:b.mod}):this.negative&l.negative?(b=this.neg().divmod(l.neg(),w),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:b.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,c=l.ushrn(1),d=l.andln(1),b=p.cmp(c);return b<0||d===1&&b===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,c=this.length-1;c>=0;c--)p=(w*p+(this.words[c]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var c=(this.words[p]|0)+w*67108864;this.words[p]=c/l|0,w=c%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=new n(0),x=new n(1),v=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++v;for(var h=p.clone(),_=w.clone();!w.isZero();){for(var T=0,m=1;!(w.words[0]&m)&&T<26;++T,m<<=1);if(T>0)for(w.iushrn(T);T-- >0;)(c.isOdd()||d.isOdd())&&(c.iadd(h),d.isub(_)),c.iushrn(1),d.iushrn(1);for(var M=0,z=1;!(p.words[0]&z)&&M<26;++M,z<<=1);if(M>0)for(p.iushrn(M);M-- >0;)(b.isOdd()||x.isOdd())&&(b.iadd(h),x.isub(_)),b.iushrn(1),x.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(b),d.isub(x)):(p.isub(w),b.isub(c),x.isub(d))}return{a:b,b:x,gcd:p.iushln(v)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var x=0,v=1;!(w.words[0]&v)&&x<26;++x,v<<=1);if(x>0)for(w.iushrn(x);x-- >0;)c.isOdd()&&c.iadd(b),c.iushrn(1);for(var h=0,_=1;!(p.words[0]&_)&&h<26;++h,_<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(b),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(d)):(p.isub(w),d.isub(c))}var T;return w.cmpn(1)===0?T=c:T=d,T.cmpn(0)<0&&T.iadd(l),T},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var c=0;w.isEven()&&p.isEven();c++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var b=w;w=p,p=b}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(c)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,c=1<>>26,x&=67108863,this.words[b]=x}return d!==0&&(this.words[b]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var c=this.words[0]|0;p=c===l?0:cl.length)return 1;if(this.length=0;p--){var c=this.words[p]|0,d=l.words[p]|0;if(c!==d){cd&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new D(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var U={k256:null,p224:null,p192:null,p25519:null};function k(P,l){this.name=P,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}k.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},k.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var c=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},k.prototype.split=function(l,w){l.iushrn(this.n,0,w)},k.prototype.imulK=function(l){return l.imul(this.k)};function B(){k.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(B,k),B.prototype.split=function(l,w){for(var p=4194303,c=Math.min(l.length,9),d=0;d>>22,b=x}b>>>=22,l.words[d-10]=b,b===0&&l.length>10?l.length-=10:l.length-=9},B.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=c}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(U[l])return U[l];var w;if(l==="k256")w=new B;else if(l==="p224")w=new j;else if(l==="p192")w=new V;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return U[l]=w,w};function D(P){if(typeof P=="string"){var l=n._prime(P);this.m=l.p,this.prime=l}else t(P.gtn(1),"modulus must be greater than 1"),this.m=P,this.prime=null}D.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},D.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},D.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},D.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},D.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},D.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},D.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},D.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},D.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},D.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},D.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},D.prototype.isqr=function(l){return this.imul(l,l.clone())},D.prototype.sqr=function(l){return this.mul(l,l)},D.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var c=this.m.subn(1),d=0;!c.isZero()&&c.andln(1)===0;)d++,c.iushrn(1);t(!c.isZero());var b=new n(1).toRed(this),x=b.redNeg(),v=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,v).cmp(x)!==0;)h.redIAdd(x);for(var _=this.pow(h,c),T=this.pow(l,c.addn(1).iushrn(1)),m=this.pow(l,c),M=d;m.cmp(b)!==0;){for(var z=m,E=0;z.cmp(b)!==0;E++)z=z.redSqr();t(E=0;d--){for(var _=w.words[d],T=h-1;T>=0;T--){var m=_>>T&1;if(b!==c[0]&&(b=this.sqr(b)),m===0&&x===0){v=0;continue}x<<=1,x|=m,v++,!(v!==p&&(d!==0||T!==0))&&(b=this.mul(b,c[x]),v=0,x=0)}h=26}return b},D.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},D.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(P){D.call(this,P),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,D),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof $d>"u"||$d,$b)});var Hd=J(Wb=>{"use strict";var Mf=Wb;function PE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}Mf.toArray=PE;function Hb(r){return r.length===1?"0"+r:r}Mf.zero2=Hb;function Gb(r){for(var e="",t=0;t{"use strict";var Rr=Jb,NE=li(),CE=Qi(),Rf=Hd();Rr.assert=CE;Rr.toArray=Rf.toArray;Rr.zero2=Rf.zero2;Rr.toHex=Rf.toHex;Rr.encode=Rf.encode;function DE(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?a=(s>>1)-f:a=f,o.isubn(a)):a=0,i[n]=a,o.iushrn(1)}return i}Rr.getNAF=DE;function OE(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,a=e.andln(3)+n&3;o===3&&(o=-1),a===3&&(a=-1);var f;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&a===2?f=-o:f=o):f=0,t[0].push(f);var u;a&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?u=-a:u=a):u=0,t[1].push(u),2*i===f+1&&(i=1-i),2*n===u+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}Rr.getJSF=OE;function LE(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}Rr.cachedProperty=LE;function FE(r){return typeof r=="string"?Rr.toArray(r,"hex"):r}Rr.parseBytes=FE;function UE(r){return new NE(r,"hex","le")}Rr.intFromLE=UE});var Yd=J((DD,Jd)=>{var Gd;Jd.exports=function(e){return Gd||(Gd=new nn(null)),Gd.generate(e)};function nn(r){this.rand=r}Jd.exports.Rand=nn;nn.prototype.generate=function(e){return this._rand(e)};nn.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var Qn=li(),va=Xt(),Pf=va.getNAF,qE=va.getJSF,Nf=va.assert;function sn(r,e){this.type=r,this.p=new Qn(e.p,16),this.red=e.prime?Qn.red(e.prime):Qn.mont(this.p),this.zero=new Qn(0).toRed(this.red),this.one=new Qn(1).toRed(this.red),this.two=new Qn(2).toRed(this.red),this.n=e.n&&new Qn(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Yb.exports=sn;sn.prototype.point=function(){throw new Error("Not implemented")};sn.prototype.validate=function(){throw new Error("Not implemented")};sn.prototype._fixedNafMul=function(e,t){Nf(e.precomputed);var i=e._getDoubles(),n=Pf(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];Nf(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};sn.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,R=g;if(o[A]!==1||o[R]!==1){f[A]=Pf(i[A],o[A],this._bitLength),f[R]=Pf(i[R],o[R],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[R].length,u);continue}var O=[t[A],null,null,t[R]];t[A].y.cmp(t[R].y)===0?(O[1]=t[A].add(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg())):t[A].y.cmp(t[R].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].add(t[R].neg())):(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=qE(i[A],i[R]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[R]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var D=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};lr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var BE=Xt(),nt=li(),Xd=ua(),Qs=ya(),kE=BE.assert;function pr(r){Qs.call(this,"short",r),this.a=new nt(r.a,16).toRed(this.red),this.b=new nt(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Xd(pr,Qs);Xb.exports=pr;pr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new nt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new nt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],kE(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new nt(a.a,16),b:new nt(a.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};pr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:nt.mont(e),i=new nt(2).toRed(t).redInvm(),n=i.redNeg(),s=new nt(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]};pr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new nt(1),o=new nt(0),a=new nt(0),f=new nt(1),u,g,y,S,I,A,R,O=0,N,U;i.cmpn(0)!==0;){var k=n.div(i);N=n.sub(k.mul(i)),U=a.sub(k.mul(s));var B=f.sub(k.mul(o));if(!y&&N.cmp(t)<0)u=R.neg(),g=s,y=N.neg(),S=U;else if(y&&++O===2)break;R=N,n=i,i=N,a=s,s=U,f=o,o=B}I=N.neg(),A=U;var j=y.sqr().add(S.sqr()),V=I.sqr().add(A.sqr());return V.cmp(j)>=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};pr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};pr.prototype.pointFromX=function(e,t){e=new nt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};pr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};pr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};gt.prototype.isInfinity=function(){return this.inf};gt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};gt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};gt.prototype.getX=function(){return this.x.fromRed()};gt.prototype.getY=function(){return this.y.fromRed()};gt.prototype.mul=function(e){return e=new nt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};gt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};gt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};gt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};gt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};gt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Et(r,e,t,i){Qs.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nt(0)):(this.x=new nt(e,16),this.y=new nt(t,16),this.z=new nt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Xd(Et,Qs.BasePoint);pr.prototype.jpoint=function(e,t,i){return new Et(this,e,t,i)};Et.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};Et.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Et.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),R=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,R)};Et.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};Et.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};Et.prototype.inspect=function(){return this.isInfinity()?"":""};Et.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var tv=J((FD,ev)=>{"use strict";var Zs=li(),Zb=ua(),Cf=ya(),zE=Xt();function eo(r){Cf.call(this,"mont",r),this.a=new Zs(r.a,16).toRed(this.red),this.b=new Zs(r.b,16).toRed(this.red),this.i4=new Zs(4).toRed(this.red).redInvm(),this.two=new Zs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Zb(eo,Cf);ev.exports=eo;eo.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function mt(r,e,t){Cf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Zs(e,16),this.z=new Zs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Zb(mt,Cf.BasePoint);eo.prototype.decodePoint=function(e,t){return this.point(zE.toArray(e,t),1)};eo.prototype.point=function(e,t){return new mt(this,e,t)};eo.prototype.pointFromJSON=function(e){return mt.fromJSON(this,e)};mt.prototype.precompute=function(){};mt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};mt.fromJSON=function(e,t){return new mt(e,t[0],t[1]||e.one)};mt.prototype.inspect=function(){return this.isInfinity()?"":""};mt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};mt.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)};mt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),f=s.redMul(n),u=t.z.redMul(a.redAdd(f).redSqr()),g=t.x.redMul(a.redISub(f).redSqr());return this.curve.point(u,g)};mt.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};mt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};mt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};mt.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var nv=J((UD,iv)=>{"use strict";var jE=Xt(),Li=li(),rv=ua(),Df=ya(),KE=jE.assert;function pi(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,Df.call(this,"edwards",r),this.a=new Li(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Li(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Li(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),KE(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}rv(pi,Df);iv.exports=pi;pi.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};pi.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};pi.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};pi.prototype.pointFromX=function(e,t){e=new Li(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var f=a.fromRed().isOdd();return(t&&!f||!t&&f)&&(a=a.redNeg()),this.point(e,a)};pi.prototype.pointFromY=function(e,t){e=new Li(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)};pi.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ye(r,e,t,i,n){Df.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Li(e,16),this.y=new Li(t,16),this.z=i?new Li(i,16):this.curve.one,this.t=n&&new Li(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}rv(Ye,Df.BasePoint);pi.prototype.pointFromJSON=function(e){return Ye.fromJSON(this,e)};pi.prototype.point=function(e,t,i,n){return new Ye(this,e,t,i,n)};Ye.fromJSON=function(e,t){return new Ye(e,t[0],t[1],t[2])};Ye.prototype.inspect=function(){return this.isInfinity()?"":""};Ye.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ye.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(i),f=n.redSub(t),u=s.redMul(a),g=o.redMul(f),y=s.redMul(f),S=a.redMul(o);return this.curve.point(u,g,S,y)};Ye.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,f,u;if(this.curve.twisted){a=this.curve._mulA(t);var g=a.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(g.redSub(this.curve.two)),s=g.redMul(a.redSub(i)),o=g.redSqr().redSub(g).redSub(g)):(f=this.z.redSqr(),u=g.redSub(f).redISub(f),n=e.redSub(t).redISub(i).redMul(u),s=g.redMul(a.redSub(i)),o=g.redMul(u))}else a=t.redAdd(i),f=this.curve._mulC(this.z).redSqr(),u=a.redSub(f).redSub(f),n=this.curve._mulC(e.redISub(a)).redMul(u),s=this.curve._mulC(a).redMul(t.redISub(i)),o=a.redMul(u);return this.curve.point(n,s,o)};Ye.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ye.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),a=s.redSub(n),f=s.redAdd(n),u=i.redAdd(t),g=o.redMul(a),y=f.redMul(u),S=o.redMul(u),I=a.redMul(f);return this.curve.point(g,y,I,S)};Ye.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),f=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),g=t.redMul(a).redMul(u),y,S;return this.curve.twisted?(y=t.redMul(f).redMul(s.redSub(this.curve._mulA(n))),S=a.redMul(f)):(y=t.redMul(f).redMul(s.redSub(n)),S=this.curve._mulC(a).redMul(f)),this.curve.point(g,y,S)};Ye.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ye.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ye.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ye.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ye.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ye.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ye.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ye.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ye.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ye.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ye.prototype.toP=Ye.prototype.normalize;Ye.prototype.mixedAdd=Ye.prototype.add});var Qd=J(sv=>{"use strict";var Of=sv;Of.base=ya();Of.short=Qb();Of.mont=tv();Of.edwards=nv()});var av=J((BD,ov)=>{ov.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var Lf=J(uv=>{"use strict";var el=uv,on=la(),Zd=Qd(),VE=Xt(),cv=VE.assert;function fv(r){r.type==="short"?this.curve=new Zd.short(r):r.type==="edwards"?this.curve=new Zd.edwards(r):this.curve=new Zd.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,cv(this.g.validate(),"Invalid curve"),cv(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}el.PresetCurve=fv;function an(r,e){Object.defineProperty(el,r,{configurable:!0,enumerable:!0,get:function(){var t=new fv(e);return Object.defineProperty(el,r,{configurable:!0,enumerable:!0,value:t}),t}})}an("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:on.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});an("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:on.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});an("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:on.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});an("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:on.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});an("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:on.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});an("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:on.sha256,gRed:!1,g:["9"]});an("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:on.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var tl;try{tl=av()}catch{tl=void 0}an("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:on.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",tl]})});var lv=J((zD,dv)=>{"use strict";var $E=la(),Zn=Hd(),hv=Qi();function cn(r){if(!(this instanceof cn))return new cn(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Zn.toArray(r.entropy,r.entropyEnc||"hex"),t=Zn.toArray(r.nonce,r.nonceEnc||"hex"),i=Zn.toArray(r.pers,r.persEnc||"hex");hv(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}dv.exports=cn;cn.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};cn.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Zn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var HE=li(),GE=Xt(),rl=GE.assert;function Ct(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}pv.exports=Ct;Ct.fromPublic=function(e,t,i){return t instanceof Ct?t:new Ct(e,{pub:t,pubEnc:i})};Ct.fromPrivate=function(e,t,i){return t instanceof Ct?t:new Ct(e,{priv:t,privEnc:i})};Ct.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Ct.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};Ct.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Ct.prototype._importPrivate=function(e,t){this.priv=new HE(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};Ct.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?rl(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&rl(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};Ct.prototype.derive=function(e){return e.validate()||rl(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Ct.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};Ct.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};Ct.prototype.inspect=function(){return""}});var vv=J((KD,bv)=>{"use strict";var Ff=li(),sl=Xt(),WE=sl.assert;function Uf(r,e){if(r instanceof Uf)return r;this._importDER(r,e)||(WE(r.r&&r.s,"Signature without r or s"),this.r=new Ff(r.r,16),this.s=new Ff(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}bv.exports=Uf;function JE(){this.place=0}function il(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function mv(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Uf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=mv(t),i=mv(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];nl(n,t.length),n=n.concat(t),n.push(2),nl(n,i.length);var s=n.concat(i),o=[48];return nl(o,s.length),o=o.concat(s),sl.encode(o,e)}});var _v=J((VD,xv)=>{"use strict";var es=li(),yv=lv(),YE=Xt(),ol=Lf(),XE=Yd(),wv=YE.assert,al=gv(),qf=vv();function gr(r){if(!(this instanceof gr))return new gr(r);typeof r=="string"&&(wv(Object.prototype.hasOwnProperty.call(ol,r),"Unknown curve "+r),r=ol[r]),r instanceof ol.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}xv.exports=gr;gr.prototype.keyPair=function(e){return new al(this,e)};gr.prototype.keyFromPrivate=function(e,t){return al.fromPrivate(this,e,t)};gr.prototype.keyFromPublic=function(e,t){return al.fromPublic(this,e,t)};gr.prototype.genKeyPair=function(e){e||(e={});for(var t=new yv({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||XE(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new es(2));;){var s=new es(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};gr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};gr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new es(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new yv({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new es(1)),g=0;;g++){var y=n.k?n.k(g):new es(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var R=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(R=R.umod(this.n),R.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),O^=1),new qf({r:A,s:R,recoveryParam:O})}}}}}};gr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new es(e,16)),i=this.keyFromPublic(i,n),t=new qf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};gr.prototype.recoverPubKey=function(r,e,t,i){wv((3&t)===t,"The recovery param is more than two bits"),e=new qf(e,i);var n=this.n,s=new es(r),o=e.r,a=e.s,f=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};gr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new qf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Av=J(($D,Iv)=>{"use strict";var wa=Xt(),Sv=wa.assert,Ev=wa.parseBytes,to=wa.cachedProperty;function bt(r,e){this.eddsa=r,this._secret=Ev(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Ev(e.pub)}bt.fromPublic=function(e,t){return t instanceof bt?t:new bt(e,{pub:t})};bt.fromSecret=function(e,t){return t instanceof bt?t:new bt(e,{secret:t})};bt.prototype.secret=function(){return this._secret};to(bt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});to(bt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});to(bt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});to(bt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});to(bt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});to(bt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});bt.prototype.sign=function(e){return Sv(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};bt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};bt.prototype.getSecret=function(e){return Sv(this._secret,"KeyPair is public only"),wa.encode(this.secret(),e)};bt.prototype.getPublic=function(e){return wa.encode(this.pubBytes(),e)};Iv.exports=bt});var Rv=J((HD,Mv)=>{"use strict";var QE=li(),Bf=Xt(),Tv=Bf.assert,kf=Bf.cachedProperty,ZE=Bf.parseBytes;function ts(r,e){this.eddsa=r,typeof e!="object"&&(e=ZE(e)),Array.isArray(e)&&(Tv(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Tv(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof QE&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}kf(ts,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});kf(ts,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});kf(ts,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});kf(ts,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});ts.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};ts.prototype.toHex=function(){return Bf.encode(this.toBytes(),"hex").toUpperCase()};Mv.exports=ts});var Ov=J((GD,Dv)=>{"use strict";var e7=la(),t7=Lf(),ro=Xt(),r7=ro.assert,Nv=ro.parseBytes,Cv=Av(),Pv=Rv();function Kt(r){if(r7(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Kt))return new Kt(r);r=t7[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=e7.sha512}Dv.exports=Kt;Kt.prototype.sign=function(e,t){e=Nv(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),f=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:f,Rencoded:o})};Kt.prototype.verify=function(e,t,i){if(e=Nv(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),a=t.R().add(n.pub().mul(s));return a.eq(o)};Kt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var rs=Lv;rs.version=Vb().version;rs.utils=Xt();rs.rand=Yd();rs.curve=Qd();rs.curves=Lf();rs.ec=_v();rs.eddsa=Ov()});var $y=J(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.isBrowserCryptoAvailable=ln.getSubtleCrypto=ln.getBrowerCrypto=void 0;function Ol(){return(global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}ln.getBrowerCrypto=Ol;function Vy(){let r=Ol();return r.subtle||r.webkitSubtle}ln.getSubtleCrypto=Vy;function v9(){return!!Ol()&&!!Vy()}ln.isBrowserCryptoAvailable=v9});var Wy=J(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.isBrowser=pn.isNode=pn.isReactNative=void 0;function Hy(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}pn.isReactNative=Hy;function Gy(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}pn.isNode=Gy;function y9(){return!Hy()&&!Gy()}pn.isBrowser=y9});var Ll=J(Zf=>{"use strict";Object.defineProperty(Zf,"__esModule",{value:!0});var Jy=(Es(),No(_s));Jy.__exportStar($y(),Zf);Jy.__exportStar(Wy(),Zf)});var r2=J((RO,t2)=>{"use strict";t2.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var k2=J((Ua,bo)=>{var N9=200,Jl="__lodash_hash_undefined__",lu=1,b2=2,v2=9007199254740991,ou="[object Arguments]",jl="[object Array]",C9="[object AsyncFunction]",y2="[object Boolean]",w2="[object Date]",x2="[object Error]",_2="[object Function]",D9="[object GeneratorFunction]",au="[object Map]",E2="[object Number]",O9="[object Null]",mo="[object Object]",o2="[object Promise]",L9="[object Proxy]",S2="[object RegExp]",cu="[object Set]",I2="[object String]",F9="[object Symbol]",U9="[object Undefined]",Kl="[object WeakMap]",A2="[object ArrayBuffer]",fu="[object DataView]",q9="[object Float32Array]",B9="[object Float64Array]",k9="[object Int8Array]",z9="[object Int16Array]",j9="[object Int32Array]",K9="[object Uint8Array]",V9="[object Uint8ClampedArray]",$9="[object Uint16Array]",H9="[object Uint32Array]",G9=/[\\^$.*+?()[\]{}|]/g,W9=/^\[object .+?Constructor\]$/,J9=/^(?:0|[1-9]\d*)$/,Ze={};Ze[q9]=Ze[B9]=Ze[k9]=Ze[z9]=Ze[j9]=Ze[K9]=Ze[V9]=Ze[$9]=Ze[H9]=!0;Ze[ou]=Ze[jl]=Ze[A2]=Ze[y2]=Ze[fu]=Ze[w2]=Ze[x2]=Ze[_2]=Ze[au]=Ze[E2]=Ze[mo]=Ze[S2]=Ze[cu]=Ze[I2]=Ze[Kl]=!1;var T2=typeof global=="object"&&global&&global.Object===Object&&global,Y9=typeof self=="object"&&self&&self.Object===Object&&self,Bi=T2||Y9||Function("return this")(),M2=typeof Ua=="object"&&Ua&&!Ua.nodeType&&Ua,a2=M2&&typeof bo=="object"&&bo&&!bo.nodeType&&bo,R2=a2&&a2.exports===M2,Bl=R2&&T2.process,c2=function(){try{return Bl&&Bl.binding&&Bl.binding("util")}catch{}}(),f2=c2&&c2.isTypedArray;function X9(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function TS(r,e){var t=this.__data__,i=gu(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}ki.prototype.clear=ES;ki.prototype.delete=SS;ki.prototype.get=IS;ki.prototype.has=AS;ki.prototype.set=TS;function us(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ea))return!1;var u=s.get(r);if(u&&s.get(e))return u==e;var g=-1,y=!0,S=t&b2?new hu:void 0;for(s.set(r,e),s.set(e,r);++g-1&&r%1==0&&r-1&&r%1==0&&r<=v2}function q2(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function ka(r){return r!=null&&typeof r=="object"}var B2=f2?tS(f2):VS;function nI(r){return rI(r)?kS(r):$S(r)}function sI(){return[]}function oI(){return!1}bo.exports=iI});var Uw=J((_F,Fw)=>{Fw.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var En=J(ls=>{var K0,kT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];ls.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};ls.getSymbolTotalCodewords=function(e){return kT[e]};ls.getBCHDigit=function(r){let e=0;for(;r!==0;)e++,r>>>=1;return e};ls.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');K0=e};ls.isKanjiModeEnabled=function(){return typeof K0<"u"};ls.toSJIS=function(e){return K0(e)}});var Tu=J(vr=>{vr.L={bit:1};vr.M={bit:0};vr.Q={bit:3};vr.H={bit:2};function zT(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return vr.L;case"m":case"medium":return vr.M;case"q":case"quartile":return vr.Q;case"h":case"high":return vr.H;default:throw new Error("Unknown EC Level: "+r)}}vr.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4};vr.from=function(e,t){if(vr.isValid(e))return e;try{return zT(e)}catch{return t}}});var kw=J((IF,Bw)=>{function qw(){this.buffer=[],this.length=0}qw.prototype={get:function(r){let e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(let t=0;t>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};Bw.exports=qw});var jw=J((AF,zw)=>{function Ha(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}Ha.prototype.set=function(r,e,t,i){let n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};Ha.prototype.get=function(r,e){return this.data[r*this.size+e]};Ha.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};Ha.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};zw.exports=Ha});var Kw=J(Mu=>{var jT=En().getSymbolSize;Mu.getRowColCoords=function(e){if(e===1)return[];let t=Math.floor(e/7)+2,i=jT(e),n=i===145?26:Math.ceil((i-13)/(2*t-2))*2,s=[i-7];for(let o=1;o{var KT=En().getSymbolSize,Vw=7;$w.getPositions=function(e){let t=KT(e);return[[0,0],[t-Vw,0],[0,t-Vw]]}});var Gw=J(Xe=>{Xe.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var ps={N1:3,N2:3,N3:40,N4:10};Xe.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7};Xe.from=function(e){return Xe.isValid(e)?parseInt(e,10):void 0};Xe.getPenaltyN1=function(e){let t=e.size,i=0,n=0,s=0,o=null,a=null;for(let f=0;f=5&&(i+=ps.N1+(n-5)),o=g,n=1),g=e.get(u,f),g===a?s++:(s>=5&&(i+=ps.N1+(s-5)),a=g,s=1)}n>=5&&(i+=ps.N1+(n-5)),s>=5&&(i+=ps.N1+(s-5))}return i};Xe.getPenaltyN2=function(e){let t=e.size,i=0;for(let n=0;n=10&&(n===1488||n===93)&&i++,s=s<<1&2047|e.get(a,o),a>=10&&(s===1488||s===93)&&i++}return i*ps.N3};Xe.getPenaltyN4=function(e){let t=0,i=e.data.length;for(let s=0;s{var Sn=Tu(),Ru=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Pu=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];V0.getBlocksCount=function(e,t){switch(t){case Sn.L:return Ru[(e-1)*4+0];case Sn.M:return Ru[(e-1)*4+1];case Sn.Q:return Ru[(e-1)*4+2];case Sn.H:return Ru[(e-1)*4+3];default:return}};V0.getTotalCodewordsCount=function(e,t){switch(t){case Sn.L:return Pu[(e-1)*4+0];case Sn.M:return Pu[(e-1)*4+1];case Sn.Q:return Pu[(e-1)*4+2];case Sn.H:return Pu[(e-1)*4+3];default:return}}});var Ww=J(Cu=>{var Ga=new Uint8Array(512),Nu=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)Ga[t]=e,Nu[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)Ga[t]=Ga[t-255]})();Cu.log=function(e){if(e<1)throw new Error("log("+e+")");return Nu[e]};Cu.exp=function(e){return Ga[e]};Cu.mul=function(e,t){return e===0||t===0?0:Ga[Nu[e]+Nu[t]]}});var Jw=J(Wa=>{var H0=Ww();Wa.mul=function(e,t){let i=new Uint8Array(e.length+t.length-1);for(let n=0;n=0;){let n=i[0];for(let o=0;o{var Yw=Jw();function G0(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}G0.prototype.initialize=function(e){this.degree=e,this.genPoly=Yw.generateECPolynomial(this.degree)};G0.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let i=Yw.mod(t,this.genPoly),n=this.degree-i.length;if(n>0){let s=new Uint8Array(this.degree);return s.set(i,n),s}return i};Xw.exports=G0});var W0=J(Zw=>{Zw.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}});var J0=J(Ki=>{var e3="[0-9]+",$T="[A-Z $%*+\\-./:]+",Ja="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ja=Ja.replace(/u/g,"\\u");var HT="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ja+`)(?:.|[\r +]))+`;Ki.KANJI=new RegExp(Ja,"g");Ki.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Ki.BYTE=new RegExp(HT,"g");Ki.NUMERIC=new RegExp(e3,"g");Ki.ALPHANUMERIC=new RegExp($T,"g");var GT=new RegExp("^"+Ja+"$"),WT=new RegExp("^"+e3+"$"),JT=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Ki.testKanji=function(e){return GT.test(e)};Ki.testNumeric=function(e){return WT.test(e)};Ki.testAlphanumeric=function(e){return JT.test(e)}});var In=J(ht=>{var YT=W0(),Y0=J0();ht.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};ht.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};ht.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};ht.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};ht.MIXED={bit:-1};ht.getCharCountIndicator=function(e,t){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!YT.isValid(t))throw new Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]};ht.getBestModeForData=function(e){return Y0.testNumeric(e)?ht.NUMERIC:Y0.testAlphanumeric(e)?ht.ALPHANUMERIC:Y0.testKanji(e)?ht.KANJI:ht.BYTE};ht.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")};ht.isValid=function(e){return e&&e.bit&&e.ccBits};function XT(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return ht.NUMERIC;case"alphanumeric":return ht.ALPHANUMERIC;case"kanji":return ht.KANJI;case"byte":return ht.BYTE;default:throw new Error("Unknown mode: "+r)}}ht.from=function(e,t){if(ht.isValid(e))return e;try{return XT(e)}catch{return t}}});var s3=J(gs=>{var Du=En(),QT=$0(),t3=Tu(),An=In(),X0=W0(),i3=7973,r3=Du.getBCHDigit(i3);function ZT(r,e,t){for(let i=1;i<=40;i++)if(e<=gs.getCapacity(i,t,r))return i}function n3(r,e){return An.getCharCountIndicator(r,e)+4}function eM(r,e){let t=0;return r.forEach(function(i){let n=n3(i.mode,e);t+=n+i.getBitsLength()}),t}function tM(r,e){for(let t=1;t<=40;t++)if(eM(r,t)<=gs.getCapacity(t,e,An.MIXED))return t}gs.from=function(e,t){return X0.isValid(e)?parseInt(e,10):t};gs.getCapacity=function(e,t,i){if(!X0.isValid(e))throw new Error("Invalid QR Code version");typeof i>"u"&&(i=An.BYTE);let n=Du.getSymbolTotalCodewords(e),s=QT.getTotalCodewordsCount(e,t),o=(n-s)*8;if(i===An.MIXED)return o;let a=o-n3(i,e);switch(i){case An.NUMERIC:return Math.floor(a/10*3);case An.ALPHANUMERIC:return Math.floor(a/11*2);case An.KANJI:return Math.floor(a/13);case An.BYTE:default:return Math.floor(a/8)}};gs.getBestVersionForData=function(e,t){let i,n=t3.from(t,t3.M);if(Array.isArray(e)){if(e.length>1)return tM(e,n);if(e.length===0)return 1;i=e[0]}else i=e;return ZT(i.mode,i.getLength(),n)};gs.getEncodedBits=function(e){if(!X0.isValid(e)||e<7)throw new Error("Invalid QR Code version");let t=e<<12;for(;Du.getBCHDigit(t)-r3>=0;)t^=i3<{var Q0=En(),a3=1335,rM=21522,o3=Q0.getBCHDigit(a3);c3.getEncodedBits=function(e,t){let i=e.bit<<3|t,n=i<<10;for(;Q0.getBCHDigit(n)-o3>=0;)n^=a3<{var iM=In();function Io(r){this.mode=iM.NUMERIC,this.data=r.toString()}Io.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};Io.prototype.getLength=function(){return this.data.length};Io.prototype.getBitsLength=function(){return Io.getBitsLength(this.data.length)};Io.prototype.write=function(e){let t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);let s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};u3.exports=Io});var l3=J((kF,d3)=>{var nM=In(),Z0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ao(r){this.mode=nM.ALPHANUMERIC,this.data=r}Ao.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};Ao.prototype.getLength=function(){return this.data.length};Ao.prototype.getBitsLength=function(){return Ao.getBitsLength(this.data.length)};Ao.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let i=Z0.indexOf(this.data[t])*45;i+=Z0.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(Z0.indexOf(this.data[t]),6)};d3.exports=Ao});var g3=J((zF,p3)=>{var sM=In();function To(r){this.mode=sM.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}To.getBitsLength=function(e){return e*8};To.prototype.getLength=function(){return this.data.length};To.prototype.getBitsLength=function(){return To.getBitsLength(this.data.length)};To.prototype.write=function(r){for(let e=0,t=this.data.length;e{var oM=In(),aM=En();function Mo(r){this.mode=oM.KANJI,this.data=r}Mo.getBitsLength=function(e){return e*13};Mo.prototype.getLength=function(){return this.data.length};Mo.prototype.getBitsLength=function(){return Mo.getBitsLength(this.data.length)};Mo.prototype.write=function(r){let e;for(e=0;e=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` +Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};m3.exports=Mo});var v3=J((KF,ep)=>{"use strict";var Ya={single_source_shortest_paths:function(r,e,t){var i={},n={};n[e]=0;var s=Ya.PriorityQueue.make();s.push(e,0);for(var o,a,f,u,g,y,S,I,A;!s.empty();){o=s.pop(),a=o.value,u=o.cost,g=r[a]||{};for(f in g)g.hasOwnProperty(f)&&(y=g[f],S=u+y,I=n[f],A=typeof n[f]>"u",(A||I>S)&&(n[f]=S,s.push(f,S),i[f]=a))}if(typeof t<"u"&&typeof n[t]>"u"){var R=["Could not find a path from ",e," to ",t,"."].join("");throw new Error(R)}return i},extract_shortest_path_from_predecessor_list:function(r,e){for(var t=[],i=e,n;i;)t.push(i),n=r[i],i=r[i];return t.reverse(),t},find_path:function(r,e,t){var i=Ya.single_source_shortest_paths(r,e,t);return Ya.extract_shortest_path_from_predecessor_list(i,t)},PriorityQueue:{make:function(r){var e=Ya.PriorityQueue,t={},i;r=r||{};for(i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.queue=[],t.sorter=r.sorter||e.default_sorter,t},default_sorter:function(r,e){return r.cost-e.cost},push:function(r,e){var t={value:r,cost:e};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof ep<"u"&&(ep.exports=Ya)});var A3=J(Ro=>{var je=In(),x3=h3(),_3=l3(),E3=g3(),S3=b3(),Xa=J0(),Ou=En(),cM=v3();function y3(r){return unescape(encodeURIComponent(r)).length}function Qa(r,e,t){let i=[],n;for(;(n=r.exec(t))!==null;)i.push({data:n[0],index:n.index,mode:e,length:n[0].length});return i}function I3(r){let e=Qa(Xa.NUMERIC,je.NUMERIC,r),t=Qa(Xa.ALPHANUMERIC,je.ALPHANUMERIC,r),i,n;return Ou.isKanjiModeEnabled()?(i=Qa(Xa.BYTE,je.BYTE,r),n=Qa(Xa.KANJI,je.KANJI,r)):(i=Qa(Xa.BYTE_KANJI,je.BYTE,r),n=[]),e.concat(t,i,n).sort(function(o,a){return o.index-a.index}).map(function(o){return{data:o.data,mode:o.mode,length:o.length}})}function tp(r,e){switch(e){case je.NUMERIC:return x3.getBitsLength(r);case je.ALPHANUMERIC:return _3.getBitsLength(r);case je.KANJI:return S3.getBitsLength(r);case je.BYTE:return E3.getBitsLength(r)}}function fM(r){return r.reduce(function(e,t){let i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function uM(r){let e=[];for(let t=0;t{var Fu=En(),rp=Tu(),dM=kw(),lM=jw(),pM=Kw(),gM=Hw(),sp=Gw(),op=$0(),mM=Qw(),Lu=s3(),bM=f3(),vM=In(),ip=A3();function yM(r,e){let t=r.size,i=gM.getPositions(e);for(let n=0;n=0&&a<=6&&(f===0||f===6)||f>=0&&f<=6&&(a===0||a===6)||a>=2&&a<=4&&f>=2&&f<=4?r.set(s+a,o+f,!0,!0):r.set(s+a,o+f,!1,!0))}}function wM(r){let e=r.size;for(let t=8;t>a&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function np(r,e,t){let i=r.size,n=bM.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function EM(r,e){let t=r.size,i=-1,n=t-1,s=7,o=0;for(let a=t-1;a>0;a-=2)for(a===6&&a--;;){for(let f=0;f<2;f++)if(!r.isReserved(n,a-f)){let u=!1;o>>s&1)===1),r.set(n,a-f,u),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function SM(r,e,t){let i=new dM;t.forEach(function(f){i.put(f.mode.bit,4),i.put(f.getLength(),vM.getCharCountIndicator(f.mode,r)),f.write(i)});let n=Fu.getSymbolTotalCodewords(r),s=op.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);let a=(o-i.getLengthInBits())/8;for(let f=0;f=7&&bT(f,e),vT(f,o),isNaN(i)&&(i=Z0.getBestMask(f,Q0.bind(null,f,t))),Z0.applyMask(i,f),Q0(f,t,i),{modules:f,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}x3.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");let i=Y0.M,n,s;return typeof t<"u"&&(i=Y0.from(t.errorCorrectionLevel,Y0.M),n=Ru.from(t.version),s=Z0.from(t.maskPattern),t.toSJISFunc&&Nu.setToSJISFunction(t.toSJISFunc)),xT(e,n,i,s)}});var tp=J(ds=>{function E3(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let e=r.slice().replace("#","").split("");if(e.length<3||e.length===5||e.length>8)throw new Error("Invalid hex color: "+r);(e.length===3||e.length===4)&&(e=Array.prototype.concat.apply([],e.map(function(i){return[i,i]}))),e.length===6&&e.push("F","F");let t=parseInt(e.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+e.slice(0,6).join("")}}ds.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=typeof e.margin>"u"||e.margin===null||e.margin<0?4:e.margin,i=e.width&&e.width>=21?e.width:void 0,n=e.scale||4;return{width:i,scale:i?4:n,margin:t,color:{dark:E3(e.color.dark||"#000000ff"),light:E3(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}};ds.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale};ds.getImageWidth=function(e,t){let i=ds.getScale(e,t);return Math.floor((e+t.margin*2)*i)};ds.qrToImageData=function(e,t,i){let n=t.modules.size,s=t.modules.data,o=ds.getScale(n,i),a=Math.floor((n+i.margin*2)*o),f=i.margin*o,u=[i.color.light,i.color.dark];for(let g=0;g=f&&y>=f&&g{var rp=tp();function _T(r,e,t){r.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=t,e.width=t,e.style.height=t+"px",e.style.width=t+"px"}function ET(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}Du.render=function(e,t,i){let n=i,s=t;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),t||(s=ET()),n=rp.getOptions(n);let o=rp.getImageWidth(e.modules.size,n),a=s.getContext("2d"),f=a.createImageData(o,o);return rp.qrToImageData(f.data,e,n),_T(a,s,o),a.putImageData(f,0,0),s};Du.renderToDataURL=function(e,t,i){let n=i;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),n||(n={});let s=Du.render(e,t,n),o=n.type||"image/png",a=n.rendererOpts||{};return s.toDataURL(o,a.quality)}});var M3=J(A3=>{var ST=tp();function I3(r,e){let t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function ip(r,e,t){let i=r+e;return typeof t<"u"&&(i+=" "+t),i}function IT(r,e,t){let i="",n=0,s=!1,o=0;for(let a=0;a0&&f>0&&r[a-1]||(i+=s?ip("M",f+t,.5+u+t):ip("m",n,0),n=0,s=!1),f+1':"",u="',g='viewBox="0 0 '+a+" "+a+'"',S=''+f+u+` -`;return typeof i=="function"&&i(null,S),S}});var P3=J(Wa=>{var AT=N2(),np=_3(),T3=S3(),MT=M3();function sp(r,e,t,i,n){let s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!AT())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(f,u){try{let g=np.create(t,i);f(r(g,e,i))}catch(g){u(g)}})}try{let f=np.create(t,i);n(null,r(f,e,i))}catch(f){n(f)}}Wa.create=np.create;Wa.toCanvas=sp.bind(null,T3.render);Wa.toDataURL=sp.bind(null,T3.renderToDataURL);Wa.toString=sp.bind(null,function(r,e,t){return MT.render(r,t)})});var ls="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",up=new Uint8Array(256);for(let r=0;r/^[0-9a-fA-F]{64}$/.test(r),Cn=r=>J3.encode(r),ji=r=>Y3.decode(r),or=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;tArray.from(r).map(e=>e.toString(16).padStart(2,"0")).join(""),Xa=r=>yr(Cn(r)),On=r=>{r=r.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;r.endsWith("==")?e=2:r.endsWith("=")&&(e=1);let t=Math.floor(r.length*6/8-e),i=new Uint8Array(t),n=0,s=0,o=0;for(let a=0;a=8&&(s-=8,i[o++]=n>>s&255)}return i},X3=r=>{let e="",t=r.length;for(let i=0;i>18&63,u=a>>12&63,g=a>>6&63,y=a&63;e+=ls.charAt(f),e+=ls.charAt(u),e+=i+1ji(On(r)),Ki=r=>{let e=typeof r=="string"?Cn(r):r;return X3(e)};function Q3(r){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,i;for(;(i=t.exec(r))!==null;)i[1]!==void 0?e.push(i[1]):i[2]!==void 0&&(i[2]===""?e.push(""):/^\d+$/.test(i[2])?e.push(Number(i[2])):e.push(i[2]));return e}function Z3(r,e,t){let i=r;for(let n=0;n{zu([...r,""],i,t)});else for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&zu([...r,i],e[i],t);else{let i=r.map((n,s)=>s===0?encodeURIComponent(String(n)):n===""?"[]":`[${encodeURIComponent(String(n))}]`).join("");t.push(`${i}=${encodeURIComponent(e)}`)}}function ju(r){let e=new URLSearchParams(r),t={};for(let[i,n]of e.entries()){let s=Q3(i);Z3(t,s,n)}return t}function dp(r){let e=[];return zu([],r,e),e.join("&")}var e6=()=>typeof window<"u"&&typeof window.location<"u",To=()=>{if(e6()){let r=window.location.ancestorOrigins;return r?.[r.length-1]??"*"}return"*"},Ku=()=>{let r=window;return!!(r?.ReactNativeWebView||r?.webkit)};var _i=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";hp(e)&&(this.address=or(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:yr(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return yr(this.address)}};var lp=1e9,pp=0,Qa=2,gp=2,Vu=64,mp=1;var bp="sdk-js";var vp="hook/login",yp="hook/logout";var wp="hook/sign",xp="hook/2fa",_p="hook/sign-message",Po="walletProviderStatus",Za="transactionsSigned",Ep=500,wr="mvx",Sp=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],Ip={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var Ro=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||lp),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||Qa),this.options=Number(e.options?.valueOf()||pp),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var xr=class extends Error{constructor(t,i){super(t);this.inner=void 0;this.inner=i}summary(){let t=[];t.push({name:this.name,message:this.message});let i=this.inner;for(;i;)t.push({name:i.name,message:i.message}),i=i.inner;return t}};var ec=class extends xr{constructor(){super("Async timer already running")}},tc=class extends xr{constructor(){super("Async timer aborted")}};var ps=class extends xr{constructor(){super("Expected transaction status not reached")}},No=class extends xr{constructor(){super("Expected transaction events not found")}};var rc=class extends xr{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var ic=class extends xr{constructor(){super("Cannot sign single transaction.")}},nc=class extends xr{constructor(){super("Account is not connected.")}},Do=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},sc=class extends Error{constructor(){super("Cannot get signed message")}};var gs=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new ec;return this.correlationTag++,new Promise((t,i)=>{this.rejectionFunc=i;let n=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(n,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new tc),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var $u=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Co=class r{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=r.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new $u(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||r.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||r.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||r.DefaultPatience}async awaitPending(e){let t=s=>s.status.isPending(),i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ps;return this.awaitConditionally(t,i,n)}async awaitCompleted(e){let t=s=>{if(s.isCompleted===void 0)throw new rc;return s.isCompleted},i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ps;return this.awaitConditionally(t,i,n)}async awaitAllEvents(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.every(u=>a.includes(u))},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new No;return this.awaitConditionally(i,n,s)}async awaitAnyEvent(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new No;return this.awaitConditionally(i,n,s)}async awaitOnCondition(e,t){let i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ps;return this.awaitConditionally(t,i,n)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==Vu)throw new xr(`Invalid transaction hash length. The length of a hex encoded hash should be ${Vu}.`);return t}async awaitConditionally(e,t,i){let n=new gs("watcher:periodic"),s=new gs("watcher:patience"),o=new gs("watcher:timeout"),a=!1,f,u=!1;for(o.start(this.timeoutMilliseconds).finally(()=>{o.stop(),a=!0});!a&&(await n.start(this.pollingIntervalMilliseconds),f=await t(),u=e(f),!(u||a)););if(u&&await s.start(this.patienceMilliseconds),o.isStopped()||o.stop(),!f||!u)throw i();return f}getAllTransactionEvents(e){let t=[...e.logs.events];for(let i of e.contractResults.items)t.push(...i.logs.events);return t}};var Gt=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||mp,this.signer=e.signer||bp}};var yt=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?Ki(e.senderUsername):void 0,receiverUsername:e.receiverUsername?Ki(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?Ki(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?yr(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?yr(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new Ro({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:Mo(e.receiverUsername||""),sender:e.sender,senderUsername:Mo(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?On(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?or(e.signature):void 0,guardianSignature:e.guardianSignature?or(e.guardianSignature):void 0})}};var Ln=class r{constructor(){this.account={address:""};this.initialized=!1;if(r._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");r._instance=this}static{this._instance=new r}static getInstance(){return r._instance}setAddress(e){return this.account.address=e,r._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,i=t||"";return await this.startBgrMsgChannel("connect",i),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new ic;return t[0]}ensureConnected(){if(!this.account.address)throw new nc}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(i=>yt.transactionToPlainObject(i))});try{return t.map(n=>yt.plainObjectToTransaction(n))}catch(i){throw new Error(`Transaction canceled: ${i.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:ji(e.data)},n=(await this.startBgrMsgChannel("signMessage",t)).signature,s=or(n);return new Gt({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:s})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(i=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let n=s=>{s.isTrusted&&s.data.target==="erdw-contentScript"&&(s.data.type==="connectResponse"?(s.data.data&&s.data.data.address&&(this.account=s.data.data),window.removeEventListener("message",n),i(s.data.data)):(window.removeEventListener("message",n),i(s.data.data)))};window.addEventListener("message",n,!1)})}};var oc="elvenjs_state",Ap="https://devnet-api.multiversx.com";var Vi="/dapp/init",ac="devnet",Mp="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Tp=["wss://relay.walletconnect.com"],At={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var re={get(r){let e=localStorage.getItem(oc);if(!e)return{};let t=JSON.parse(e);return r?t[r]:t},set(r,e){let t=this.get();t[r]=e,localStorage.setItem(oc,JSON.stringify(t))},clear(){localStorage.removeItem(oc)}};var cc=async()=>{let r=Ln.getInstance();try{let e=await r.init(),t=re.get();if(t?.address&&r.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return r}catch{console.warn("Can't initialize the Dapp Provider!")}};var Bi=Be(Fn());var Qp=Be(Fn()),vc=Be(_s());var _r=class{};var Zu=class extends _r{constructor(e){super()}},Xp=vc.FIVE_SECONDS,Un={pulse:"heartbeat_pulse"},bc=class r extends Zu{constructor(e){super(e),this.events=new Qp.EventEmitter,this.interval=Xp,this.interval=e?.interval||Xp}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,vc.toMiliseconds)(this.interval))}pulse(){this.events.emit(Un.pulse)}};var R6=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,N6=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,D6=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function C6(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){O6(r);return}return e}function O6(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Fo(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!D6.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(R6.test(r)||N6.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,C6)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function L6(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function dt(r,...e){try{return L6(r(...e))}catch(t){return Promise.reject(t)}}function F6(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function U6(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function Uo(r){if(F6(r))return String(r);if(U6(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return Uo(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Zp(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var eh="base64:";function eg(r){if(typeof r=="string")return r;Zp();let e=Buffer.from(r).toString("base64");return eh+e}function tg(r){return typeof r!="string"||!r.startsWith(eh)?r:(Zp(),Buffer.from(r.slice(eh.length),"base64"))}function Bt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function rg(...r){return Bt(r.join(":"))}function qo(r){return r=Bt(r),r?r+":":""}var q6="memory",B6=()=>{let r=new Map;return{name:q6,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function sg(r={}){let e={mounts:{"":r.driver||B6()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=u=>{for(let g of e.mountpoints)if(u.startsWith(g))return{base:g,relativeKey:u.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,g)=>e.mountpoints.filter(y=>y.startsWith(u)||g&&u.startsWith(y)).map(y=>({relativeBase:u.length>y.length?u.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(u,g)=>{if(e.watching){g=Bt(g);for(let y of e.watchListeners)y(u,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(let u in e.mounts)e.unwatch[u]=await ig(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(let u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,g,y)=>{let S=new Map,I=A=>{let P=S.get(A.base);return P||(P={driver:A.driver,base:A.base,items:[]},S.set(A.base,P)),P};for(let A of u){let P=typeof A=="string",O=Bt(P?A:A.key),N=P?void 0:A.value,U=P||!A.options?g:{...g,...A.options},k=t(O);I(k).items.push({key:O,value:N,relativeKey:k.relativeKey,options:U})}return Promise.all([...S.values()].map(A=>y(A))).then(A=>A.flat())},f={hasItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.hasItem,y,g)},getItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.getItem,y,g).then(I=>Fo(I))},getItems(u,g){return a(u,g,y=>y.driver.getItems?dt(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),g).then(S=>S.map(I=>({key:rg(y.base,I.key),value:Fo(I.value)}))):Promise.all(y.items.map(S=>dt(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Fo(I)})))))},getItemRaw(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return S.getItemRaw?dt(S.getItemRaw,y,g):dt(S.getItem,y,g).then(I=>tg(I))},async setItem(u,g,y={}){if(g===void 0)return f.removeItem(u);u=Bt(u);let{relativeKey:S,driver:I}=t(u);I.setItem&&(await dt(I.setItem,S,Uo(g),y),I.watch||n("update",u))},async setItems(u,g){await a(u,g,async y=>{if(y.driver.setItems)return dt(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:Uo(S.value),options:S.options})),g);y.driver.setItem&&await Promise.all(y.items.map(S=>dt(y.driver.setItem,S.relativeKey,Uo(S.value),S.options)))})},async setItemRaw(u,g,y={}){if(g===void 0)return f.removeItem(u,y);u=Bt(u);let{relativeKey:S,driver:I}=t(u);if(I.setItemRaw)await dt(I.setItemRaw,S,g,y);else if(I.setItem)await dt(I.setItem,S,eg(g),y);else return;I.watch||n("update",u)},async removeItem(u,g={}){typeof g=="boolean"&&(g={removeMeta:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u);S.removeItem&&(await dt(S.removeItem,y,g),(g.removeMeta||g.removeMata)&&await dt(S.removeItem,y+"$",g),S.watch||n("remove",u))},async getMeta(u,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u),I=Object.create(null);if(S.getMeta&&Object.assign(I,await dt(S.getMeta,y,g)),!g.nativeOnly){let A=await dt(S.getItem,y+"$",g).then(P=>Fo(P));A&&typeof A=="object"&&(typeof A.atime=="string"&&(A.atime=new Date(A.atime)),typeof A.mtime=="string"&&(A.mtime=new Date(A.mtime)),Object.assign(I,A))}return I},setMeta(u,g,y={}){return this.setItem(u+"$",g,y)},removeMeta(u,g={}){return this.removeItem(u+"$",g)},async getKeys(u,g={}){u=qo(u);let y=i(u,!0),S=[],I=[];for(let A of y){let P=await dt(A.driver.getKeys,A.relativeBase,g);for(let O of P){let N=A.mountpoint+Bt(O);S.some(U=>N.startsWith(U))||I.push(N)}S=[A.mountpoint,...S.filter(O=>!O.startsWith(A.mountpoint))]}return u?I.filter(A=>A.startsWith(u)&&A[A.length-1]!=="$"):I.filter(A=>A[A.length-1]!=="$")},async clear(u,g={}){u=qo(u),await Promise.all(i(u,!1).map(async y=>{if(y.driver.clear)return dt(y.driver.clear,y.relativeBase,g);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",g);return Promise.all(S.map(I=>y.driver.removeItem(I,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>ng(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,g){if(u=qo(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[u]=g,e.watching&&Promise.resolve(ig(g,n,u)).then(y=>{e.unwatch[u]=y}).catch(console.error),f},async unmount(u,g=!0){u=qo(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),g&&await ng(e.mounts[u]),e.mountpoints=e.mountpoints.filter(y=>y!==u),delete e.mounts[u])},getMount(u=""){u=Bt(u)+":";let g=t(u);return{driver:g.driver,base:g.base}},getMounts(u="",g={}){return u=Bt(u),i(u,g.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(u,g={})=>f.getKeys(u,g),get:(u,g={})=>f.getItem(u,g),set:(u,g,y={})=>f.setItem(u,g,y),has:(u,g={})=>f.hasItem(u,g),del:(u,g={})=>f.removeItem(u,g),remove:(u,g={})=>f.removeItem(u,g)};return f}function ig(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ng(r){typeof r.dispose=="function"&&await dt(r.dispose)}function qn(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function rh(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=qn(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var th;function Bo(){return th||(th=rh("keyval-store","keyval")),th}function ih(r,e=Bo()){return e("readonly",t=>qn(t.get(r)))}function og(r,e,t=Bo()){return t("readwrite",i=>(i.put(e,r),qn(i.transaction)))}function ag(r,e=Bo()){return e("readwrite",t=>(t.delete(r),qn(t.transaction)))}function cg(r=Bo()){return r("readwrite",e=>(e.clear(),qn(e.transaction)))}function k6(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},qn(r.transaction)}function fg(r=Bo()){return r("readonly",e=>{if(e.getAllKeys)return qn(e.getAllKeys());let t=[];return k6(e,i=>t.push(i.key)).then(()=>t)})}var z6=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),j6=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Qr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return j6(r)}catch{return r}}function ar(r){return typeof r=="string"?r:z6(r)||""}var K6="idb-keyval",V6=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=rh(r.dbName,r.storeName)),{name:K6,options:r,async hasItem(n){return!(typeof await ih(t(n),i)>"u")},async getItem(n){return await ih(t(n),i)??null},setItem(n,s){return og(t(n),s,i)},removeItem(n){return ag(t(n),i)},getKeys(){return fg(i)},clear(){return cg(i)}}},$6="WALLET_CONNECT_V2_INDEXED_DB",H6="keyvaluestorage",sh=class{constructor(){this.indexedDb=sg({driver:V6({dbName:$6,storeName:H6})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,ar(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},nh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},yc={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof nh<"u"&&nh.localStorage?yc.exports=nh.localStorage:typeof window<"u"&&window.localStorage?yc.exports=window.localStorage:yc.exports=new e})();function G6(r){var e;return[r[0],Qr((e=r[1])!=null?e:"")]}var oh=class{constructor(){this.localStorage=yc.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(G6)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Qr(t)}async setItem(e,t){this.localStorage.setItem(e,ar(t))}async removeItem(e){this.localStorage.removeItem(e)}},W6="wc_storage_version",ug=1,J6=async(r,e,t)=>{let i=W6,n=await e.getItem(i);if(n&&n>=ug){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let a=s.shift();if(!a)continue;let f=a.toLowerCase();if(f.includes("wc@")||f.includes("walletconnect")||f.includes("wc_")||f.includes("wallet_connect")){let u=await r.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(i,ug),t(e),Y6(r,o)},Y6=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},wc=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new oh;this.storage=e;try{let t=new sh;J6(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var Ei=Be(fh()),jo=Be(fh());var f5={level:"info"},Ko="custom_context",lh=1e3*1024,uh=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Ec=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new uh(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},Sc=class{constructor(e,t=lh){this.level=e??"error",this.levelValue=Ei.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Ec(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Ei.levels.values.error?console.error(e):t===Ei.levels.values.warn?console.warn(e):t===Ei.levels.values.debug?console.debug(e):t===Ei.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(ar({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Ec(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(ar({extraMetadata:e})),new Blob(t,{type:"application/json"})}},hh=class{constructor(e,t=lh){this.baseChunkLogger=new Sc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},dh=class{constructor(e,t=lh){this.baseChunkLogger=new Sc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},u5=Object.defineProperty,h5=Object.defineProperties,d5=Object.getOwnPropertyDescriptors,bg=Object.getOwnPropertySymbols,l5=Object.prototype.hasOwnProperty,p5=Object.prototype.propertyIsEnumerable,vg=(r,e,t)=>e in r?u5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ic=(r,e)=>{for(var t in e||(e={}))l5.call(e,t)&&vg(r,t,e[t]);if(bg)for(var t of bg(e))p5.call(e,t)&&vg(r,t,e[t]);return r},Ac=(r,e)=>h5(r,d5(e));function Vo(r){return Ac(Ic({},r),{level:r?.level||f5.level})}function g5(r,e=Ko){return r[e]||""}function m5(r,e,t=Ko){return r[t]=e,r}function Mt(r,e=Ko){let t="";return typeof r.bindings>"u"?t=g5(r,e):t=r.bindings().context||"",t}function b5(r,e,t=Ko){let i=Mt(r,t);return i.trim()?`${i}/${e}`:e}function wt(r,e,t=Ko){let i=b5(r,e,t),n=r.child({context:i});return m5(n,i,t)}function v5(r){var e,t;let i=new hh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ei.default)(Ac(Ic({},r.opts),{level:"trace",browser:Ac(Ic({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function y5(r){var e;let t=new dh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ei.default)(Ac(Ic({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function yg(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?v5(r):y5(r)}var wg=Be(Fn()),Mc=class extends _r{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var Tc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},Pc=class{constructor(e,t){this.logger=e,this.core=t}},Rc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}},Nc=class extends _r{constructor(e){super()}},Dc=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var Cc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}};var Oc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t}};var Lc=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Fc=class{constructor(e,t){this.projectId=e,this.logger=t}},Uc=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var qc=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Bc=class{constructor(e){this.client=e}};var ne=Be(_s());var ta=Be(Yg()),M1=Be($o()),T1=Be(_s());var Xg="EdDSA",Qg="JWT",Wo=".",Jo="base64url",Dh="utf8",Ch="utf8",Zg=":",e1="did",t1="key",Oh="base58btc",r1="z",i1="K36";function Yo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function jn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=Yo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var Bh={};qt(Bh,{identity:()=>yx});function px(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var C=k-O;C!==k&&B[C]===0;)C++;for(var W=f.repeat(P);C>>0,k=new Uint8Array(U);A[P];){var B=t[A.charCodeAt(P)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,P++}if(A[P]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var C=new Uint8Array(O+(U-L)),W=O;L!==U;)C[W++]=k[L++];return C}}}function I(A){var P=S(A);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var gx=px,mx=gx,n1=mx;var pR=new Uint8Array(0);var s1=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var o1=r=>new TextEncoder().encode(r),a1=r=>new TextDecoder().decode(r);var Lh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Fh=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return f1(this,e)}},Uh=class{constructor(e){this.decoders=e}or(e){return f1(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},f1=(r,e)=>new Uh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),qh=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Lh(e,t,i),this.decoder=new Fh(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ps=({name:r,prefix:e,encode:t,decode:i})=>new qh(r,e,t,i),Hi=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=n1(t,e);return Ps({prefix:r,name:e,encode:i,decode:s=>Ii(n(s))})},bx=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},vx=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<Ps({prefix:e,name:r,encode(n){return vx(n,i,t)},decode(n){return bx(n,i,t,r)}});var yx=Ps({prefix:"\0",name:"identity",encode:r=>a1(r),decode:r=>o1(r)});var kh={};qt(kh,{base2:()=>wx});var wx=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zh={};qt(zh,{base8:()=>xx});var xx=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jh={};qt(jh,{base10:()=>_x});var _x=Hi({prefix:"9",name:"base10",alphabet:"0123456789"});var Kh={};qt(Kh,{base16:()=>Ex,base16upper:()=>Sx});var Ex=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sx=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Vh={};qt(Vh,{base32:()=>Rs,base32hex:()=>Tx,base32hexpad:()=>Rx,base32hexpadupper:()=>Nx,base32hexupper:()=>Px,base32pad:()=>Ax,base32padupper:()=>Mx,base32upper:()=>Ix,base32z:()=>Dx});var Rs=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ix=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ax=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mx=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Tx=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Px=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rx=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nx=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Dx=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $h={};qt($h,{base36:()=>Cx,base36upper:()=>Ox});var Cx=Hi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ox=Hi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Hh={};qt(Hh,{base58btc:()=>ei,base58flickr:()=>Lx});var ei=Hi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lx=Hi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gh={};qt(Gh,{base64:()=>Fx,base64pad:()=>Ux,base64url:()=>qx,base64urlpad:()=>Bx});var Fx=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ux=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qx=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bx=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Wh={};qt(Wh,{base256emoji:()=>Vx});var u1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),kx=u1.reduce((r,e,t)=>(r[t]=e,r),[]),zx=u1.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function jx(r){return r.reduce((e,t)=>(e+=kx[t],e),"")}function Kx(r){let e=[];for(let t of r){let i=zx[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Vx=Ps({prefix:"\u{1F680}",name:"base256emoji",encode:jx,decode:Kx});var Qh={};qt(Qh,{sha256:()=>f4,sha512:()=>u4});var $x=l1,h1=128,Hx=127,Gx=~Hx,Wx=Math.pow(2,31);function l1(r,e,t){e=e||[],t=t||0;for(var i=t;r>=Wx;)e[t++]=r&255|h1,r/=128;for(;r&Gx;)e[t++]=r&255|h1,r>>>=7;return e[t]=r|0,l1.bytes=t-i+1,e}var Jx=Jh,Yx=128,d1=127;function Jh(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw Jh.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&d1)<=Yx);return Jh.bytes=s-i,t}var Xx=Math.pow(2,7),Qx=Math.pow(2,14),Zx=Math.pow(2,21),e4=Math.pow(2,28),t4=Math.pow(2,35),r4=Math.pow(2,42),i4=Math.pow(2,49),n4=Math.pow(2,56),s4=Math.pow(2,63),o4=function(r){return r[Xo.decode(r,e),Xo.decode.bytes],Ns=(r,e,t=0)=>(Xo.encode(r,e,t),e),Ds=r=>Xo.encodingLength(r);var Kn=(r,e)=>{let t=e.byteLength,i=Ds(r),n=i+Ds(t),s=new Uint8Array(n+t);return Ns(r,s,0),Ns(t,s,i),s.set(e,n),new Cs(r,t,e,s)},p1=r=>{let e=Ii(r),[t,i]=Qo(e),[n,s]=Qo(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new Cs(t,n,o,e)},g1=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&s1(r.bytes,e.bytes),Cs=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var Xh=({name:r,code:e,encode:t})=>new Yh(r,e,t),Yh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Kn(this.code,t):t.then(i=>Kn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var b1=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),f4=Xh({name:"sha2-256",code:18,encode:b1("SHA-256")}),u4=Xh({name:"sha2-512",code:19,encode:b1("SHA-512")});var Zh={};qt(Zh,{identity:()=>l4});var v1=0,h4="identity",y1=Ii,d4=r=>Kn(v1,y1(r)),l4={code:v1,name:h4,encode:y1,digest:d4};var LR=new TextEncoder,FR=new TextDecoder;var Wc=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Gc,byteLength:Gc,code:Hc,version:Hc,multihash:Hc,bytes:Hc,_baseCache:Gc,asCID:Gc})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==ea)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==y4)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=Kn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&g1(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return b4(t,n,e||ei.encoder);default:return v4(t,n,e||Rs.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return x4(/^0\.0/,_4),!!(e&&(e[x1]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||w1(t,i,n.bytes))}else if(e!=null&&e[x1]===!0){let{version:t,multihash:i,code:n}=e,s=p1(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==ea)throw new Error(`Version 0 CID must use dag-pb (code: ${ea}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=w1(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ea,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=Ii(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new Cs(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=Qo(e.subarray(t));return t+=S,y},n=i(),s=ea;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,a=i(),f=i(),u=t+f,g=u-o;return{version:n,codec:s,multihashCode:a,digestSize:f,multihashSize:g,size:u}}static parse(e,t){let[i,n]=m4(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},m4=(r,e)=>{switch(r[0]){case"Q":{let t=e||ei;return[ei.prefix,t.decode(`${ei.prefix}${r}`)]}case ei.prefix:{let t=e||ei;return[ei.prefix,t.decode(r)]}case Rs.prefix:{let t=e||Rs;return[Rs.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},b4=(r,e,t)=>{let{prefix:i}=t;if(i!==ei.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},v4=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},ea=112,y4=18,w1=(r,e,t)=>{let i=Ds(r),n=i+Ds(e),s=new Uint8Array(n+t.byteLength);return Ns(r,s,0),Ns(e,s,i),s.set(t,n),s},x1=Symbol.for("@ipld/js-cid/CID"),Hc={writable:!1,configurable:!1,enumerable:!0},Gc={writable:!1,enumerable:!1,configurable:!1},w4="0.0.0-dev",x4=(r,e)=>{if(r.test(w4))console.warn(e);else throw new Error(e)},_4=`CID.isCID(v) is deprecated and will be removed in the next major release. +`);let o=SM(e,t,n),a=Fu.getSymbolSize(e),f=new lM(a);return yM(f,e),wM(f),xM(f,e),np(f,t,0),e>=7&&_M(f,e),EM(f,o),isNaN(i)&&(i=sp.getBestMask(f,np.bind(null,f,t))),sp.applyMask(i,f),np(f,t,i),{modules:f,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}T3.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");let i=rp.M,n,s;return typeof t<"u"&&(i=rp.from(t.errorCorrectionLevel,rp.M),n=Lu.from(t.version),s=sp.from(t.maskPattern),t.toSJISFunc&&Fu.setToSJISFunction(t.toSJISFunc)),AM(e,n,i,s)}});var ap=J(ms=>{function R3(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let e=r.slice().replace("#","").split("");if(e.length<3||e.length===5||e.length>8)throw new Error("Invalid hex color: "+r);(e.length===3||e.length===4)&&(e=Array.prototype.concat.apply([],e.map(function(i){return[i,i]}))),e.length===6&&e.push("F","F");let t=parseInt(e.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+e.slice(0,6).join("")}}ms.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=typeof e.margin>"u"||e.margin===null||e.margin<0?4:e.margin,i=e.width&&e.width>=21?e.width:void 0,n=e.scale||4;return{width:i,scale:i?4:n,margin:t,color:{dark:R3(e.color.dark||"#000000ff"),light:R3(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}};ms.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale};ms.getImageWidth=function(e,t){let i=ms.getScale(e,t);return Math.floor((e+t.margin*2)*i)};ms.qrToImageData=function(e,t,i){let n=t.modules.size,s=t.modules.data,o=ms.getScale(n,i),a=Math.floor((n+i.margin*2)*o),f=i.margin*o,u=[i.color.light,i.color.dark];for(let g=0;g=f&&y>=f&&g{var cp=ap();function TM(r,e,t){r.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=t,e.width=t,e.style.height=t+"px",e.style.width=t+"px"}function MM(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}Uu.render=function(e,t,i){let n=i,s=t;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),t||(s=MM()),n=cp.getOptions(n);let o=cp.getImageWidth(e.modules.size,n),a=s.getContext("2d"),f=a.createImageData(o,o);return cp.qrToImageData(f.data,e,n),TM(a,s,o),a.putImageData(f,0,0),s};Uu.renderToDataURL=function(e,t,i){let n=i;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),n||(n={});let s=Uu.render(e,t,n),o=n.type||"image/png",a=n.rendererOpts||{};return s.toDataURL(o,a.quality)}});var D3=J(C3=>{var RM=ap();function N3(r,e){let t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function fp(r,e,t){let i=r+e;return typeof t<"u"&&(i+=" "+t),i}function PM(r,e,t){let i="",n=0,s=!1,o=0;for(let a=0;a0&&f>0&&r[a-1]||(i+=s?fp("M",f+t,.5+u+t):fp("m",n,0),n=0,s=!1),f+1':"",u="',g='viewBox="0 0 '+a+" "+a+'"',S=''+f+u+` +`;return typeof i=="function"&&i(null,S),S}});var L3=J(Za=>{var NM=Uw(),up=M3(),O3=P3(),CM=D3();function hp(r,e,t,i,n){let s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!NM())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(f,u){try{let g=up.create(t,i);f(r(g,e,i))}catch(g){u(g)}})}try{let f=up.create(t,i);n(null,r(f,e,i))}catch(f){n(f)}}Za.create=up.create;Za.toCanvas=hp.bind(null,O3.render);Za.toDataURL=hp.bind(null,O3.renderToDataURL);Za.toString=hp.bind(null,function(r,e,t){return CM.render(r,t)})});var vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mp=new Uint8Array(256);for(let r=0;r/^[0-9a-fA-F]{64}$/.test(r),Vi=r=>t6.encode(r),$i=r=>r6.decode(r),Gt=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;tArray.from(r).map(e=>e.toString(16).padStart(2,"0")).join(""),rc=r=>ar(Vi(r)),qn=r=>{r=r.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;r.endsWith("==")?e=2:r.endsWith("=")&&(e=1);let t=Math.floor(r.length*6/8-e),i=new Uint8Array(t),n=0,s=0,o=0;for(let a=0;a=8&&(s-=8,i[o++]=n>>s&255)}return i},i6=r=>{let e="",t=r.length;for(let i=0;i>18&63,u=a>>12&63,g=a>>6&63,y=a&63;e+=vs.charAt(f),e+=vs.charAt(u),e+=i+1$i(qn(r)),Hi=r=>{let e=typeof r=="string"?Vi(r):r;return i6(e)};function n6(r){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,i;for(;(i=t.exec(r))!==null;)i[1]!==void 0?e.push(i[1]):i[2]!==void 0&&(i[2]===""?e.push(""):/^\d+$/.test(i[2])?e.push(Number(i[2])):e.push(i[2]));return e}function s6(r,e,t){let i=r;for(let n=0;n{Hu([...r,""],i,t)});else for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&Hu([...r,i],e[i],t);else{let i=r.map((n,s)=>s===0?encodeURIComponent(String(n)):n===""?"[]":`[${encodeURIComponent(String(n))}]`).join("");t.push(`${i}=${encodeURIComponent(e)}`)}}function Gu(r){let e=new URLSearchParams(r),t={};for(let[i,n]of e.entries()){let s=n6(i);s6(t,s,n)}return t}function vp(r){let e=[];return Hu([],r,e),e.join("&")}var o6=()=>typeof window<"u"&&typeof window.location<"u",Do=()=>{if(o6()){let r=window.location.ancestorOrigins;return r?.[r.length-1]??"*"}return"*"},Wu=()=>{let r=window;return!!(r?.ReactNativeWebView||r?.webkit)};var Si=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";bp(e)&&(this.address=Gt(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:ar(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return ar(this.address)}};var wp=1e9,xp=0,ic=2,_p=2,Ju=64,Ep=1;var Sp="sdk-js";var Ip="hook/login",Ap="hook/logout";var Tp="hook/sign",Mp="hook/2fa",Rp="hook/sign-message",Oo="walletProviderStatus",nc="transactionsSigned",Pp=500,wr="mvx",Np=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],Cp={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var Lo=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||wp),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||ic),this.options=Number(e.options?.valueOf()||xp),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var xr=class extends Error{constructor(t,i){super(t);this.inner=void 0;this.inner=i}summary(){let t=[];t.push({name:this.name,message:this.message});let i=this.inner;for(;i;)t.push({name:i.name,message:i.message}),i=i.inner;return t}};var sc=class extends xr{constructor(){super("Async timer already running")}},oc=class extends xr{constructor(){super("Async timer aborted")}};var ys=class extends xr{constructor(){super("Expected transaction status not reached")}},Fo=class extends xr{constructor(){super("Expected transaction events not found")}};var ac=class extends xr{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var cc=class extends xr{constructor(){super("Cannot sign single transaction.")}},fc=class extends xr{constructor(){super("Account is not connected.")}},Uo=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},uc=class extends Error{constructor(){super("Cannot get signed message")}};var ws=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new sc;return this.correlationTag++,new Promise((t,i)=>{this.rejectionFunc=i;let n=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(n,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new oc),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var Yu=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Zr=class Zr{constructor(e,t={}){this.fetcher=new Yu(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||Zr.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||Zr.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||Zr.DefaultPatience}async awaitPending(e){let t=s=>s.status.isPending(),i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ys;return this.awaitConditionally(t,i,n)}async awaitCompleted(e){let t=s=>{if(s.isCompleted===void 0)throw new ac;return s.isCompleted},i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ys;return this.awaitConditionally(t,i,n)}async awaitAllEvents(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.every(u=>a.includes(u))},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new Fo;return this.awaitConditionally(i,n,s)}async awaitAnyEvent(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new Fo;return this.awaitConditionally(i,n,s)}async awaitOnCondition(e,t){let i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ys;return this.awaitConditionally(t,i,n)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==Ju)throw new xr(`Invalid transaction hash length. The length of a hex encoded hash should be ${Ju}.`);return t}async awaitConditionally(e,t,i){let n=new ws("watcher:periodic"),s=new ws("watcher:patience"),o=new ws("watcher:timeout"),a=!1,f,u=!1;for(o.start(this.timeoutMilliseconds).finally(()=>{o.stop(),a=!0});!a&&(await n.start(this.pollingIntervalMilliseconds),f=await t(),u=e(f),!(u||a)););if(u&&await s.start(this.patienceMilliseconds),o.isStopped()||o.stop(),!f||!u)throw i();return f}getAllTransactionEvents(e){let t=[...e.logs.events];for(let i of e.contractResults.items)t.push(...i.logs.events);return t}};Zr.DefaultPollingInterval=6e3,Zr.DefaultTimeout=Zr.DefaultPollingInterval*15,Zr.DefaultPatience=0,Zr.NoopOnStatusReceived=()=>{};var qo=Zr;var Wt=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ep,this.signer=e.signer||Sp}};var yt=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?Hi(e.senderUsername):void 0,receiverUsername:e.receiverUsername?Hi(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?Hi(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?ar(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?ar(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new Lo({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:Co(e.receiverUsername||""),sender:e.sender,senderUsername:Co(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?qn(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?Gt(e.signature):void 0,guardianSignature:e.guardianSignature?Gt(e.guardianSignature):void 0})}};var Gi=class Gi{constructor(){this.account={address:""};this.initialized=!1;if(Gi._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");Gi._instance=this}static getInstance(){return Gi._instance}setAddress(e){return this.account.address=e,Gi._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,i=t||"";return await this.startBgrMsgChannel("connect",i),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new cc;return t[0]}ensureConnected(){if(!this.account.address)throw new fc}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(i=>yt.transactionToPlainObject(i))});try{return t.map(n=>yt.plainObjectToTransaction(n))}catch(i){throw new Error(`Transaction canceled: ${i.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:$i(e.data)},n=(await this.startBgrMsgChannel("signMessage",t)).signature,s=Gt(n);return new Wt({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:s})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(i=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let n=s=>{s.isTrusted&&s.data.target==="erdw-contentScript"&&(s.data.type==="connectResponse"?(s.data.data&&s.data.data.address&&(this.account=s.data.data),window.removeEventListener("message",n),i(s.data.data)):(window.removeEventListener("message",n),i(s.data.data)))};window.addEventListener("message",n,!1)})}};Gi._instance=new Gi;var Bn=Gi;var hc="elvenjs_state",Dp="https://devnet-api.multiversx.com";var Wi="/dapp/init",dc="devnet",Op="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Lp=["wss://relay.walletconnect.com"],At={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var re={get(r){let e=localStorage.getItem(hc);if(!e)return{};let t=JSON.parse(e);return r?t[r]:t},set(r,e){let t=this.get();t[r]=e,localStorage.setItem(hc,JSON.stringify(t))},clear(){localStorage.removeItem(hc)}};var lc=async()=>{let r=Bn.getInstance();try{let e=await r.init(),t=re.get();return t?.address&&r.setAddress(t.address),e?r:void 0}catch{}};var zi=Be(kn());var sg=Be(kn()),Ec=Be(Ts());var _r=class{};var nh=class extends _r{constructor(e){super()}},ng=Ec.FIVE_SECONDS,zn={pulse:"heartbeat_pulse"},_c=class r extends nh{constructor(e){super(e),this.events=new sg.EventEmitter,this.interval=ng,this.interval=e?.interval||ng}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,Ec.toMiliseconds)(this.interval))}pulse(){this.events.emit(zn.pulse)}};var F6=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,U6=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,q6=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function B6(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){k6(r);return}return e}function k6(r){`${r}`}function zo(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!q6.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(F6.test(r)||U6.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,B6)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function z6(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function dt(r,...e){try{return z6(r(...e))}catch(t){return Promise.reject(t)}}function j6(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function K6(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function jo(r){if(j6(r))return String(r);if(K6(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return jo(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function og(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var sh="base64:";function ag(r){if(typeof r=="string")return r;og();let e=Buffer.from(r).toString("base64");return sh+e}function cg(r){return typeof r!="string"||!r.startsWith(sh)?r:(og(),Buffer.from(r.slice(sh.length),"base64"))}function Bt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function fg(...r){return Bt(r.join(":"))}function Ko(r){return r=Bt(r),r?r+":":""}var V6="memory",$6=()=>{let r=new Map;return{name:V6,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function dg(r={}){let e={mounts:{"":r.driver||$6()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=u=>{for(let g of e.mountpoints)if(u.startsWith(g))return{base:g,relativeKey:u.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,g)=>e.mountpoints.filter(y=>y.startsWith(u)||g&&u.startsWith(y)).map(y=>({relativeBase:u.length>y.length?u.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(u,g)=>{if(e.watching){g=Bt(g);for(let y of e.watchListeners)y(u,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(let u in e.mounts)e.unwatch[u]=await ug(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(let u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,g,y)=>{let S=new Map,I=A=>{let R=S.get(A.base);return R||(R={driver:A.driver,base:A.base,items:[]},S.set(A.base,R)),R};for(let A of u){let R=typeof A=="string",O=Bt(R?A:A.key),N=R?void 0:A.value,U=R||!A.options?g:{...g,...A.options},k=t(O);I(k).items.push({key:O,value:N,relativeKey:k.relativeKey,options:U})}return Promise.all([...S.values()].map(A=>y(A))).then(A=>A.flat())},f={hasItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.hasItem,y,g)},getItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.getItem,y,g).then(I=>zo(I))},getItems(u,g){return a(u,g,y=>y.driver.getItems?dt(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),g).then(S=>S.map(I=>({key:fg(y.base,I.key),value:zo(I.value)}))):Promise.all(y.items.map(S=>dt(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:zo(I)})))))},getItemRaw(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return S.getItemRaw?dt(S.getItemRaw,y,g):dt(S.getItem,y,g).then(I=>cg(I))},async setItem(u,g,y={}){if(g===void 0)return f.removeItem(u);u=Bt(u);let{relativeKey:S,driver:I}=t(u);I.setItem&&(await dt(I.setItem,S,jo(g),y),I.watch||n("update",u))},async setItems(u,g){await a(u,g,async y=>{if(y.driver.setItems)return dt(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:jo(S.value),options:S.options})),g);y.driver.setItem&&await Promise.all(y.items.map(S=>dt(y.driver.setItem,S.relativeKey,jo(S.value),S.options)))})},async setItemRaw(u,g,y={}){if(g===void 0)return f.removeItem(u,y);u=Bt(u);let{relativeKey:S,driver:I}=t(u);if(I.setItemRaw)await dt(I.setItemRaw,S,g,y);else if(I.setItem)await dt(I.setItem,S,ag(g),y);else return;I.watch||n("update",u)},async removeItem(u,g={}){typeof g=="boolean"&&(g={removeMeta:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u);S.removeItem&&(await dt(S.removeItem,y,g),(g.removeMeta||g.removeMata)&&await dt(S.removeItem,y+"$",g),S.watch||n("remove",u))},async getMeta(u,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u),I=Object.create(null);if(S.getMeta&&Object.assign(I,await dt(S.getMeta,y,g)),!g.nativeOnly){let A=await dt(S.getItem,y+"$",g).then(R=>zo(R));A&&typeof A=="object"&&(typeof A.atime=="string"&&(A.atime=new Date(A.atime)),typeof A.mtime=="string"&&(A.mtime=new Date(A.mtime)),Object.assign(I,A))}return I},setMeta(u,g,y={}){return this.setItem(u+"$",g,y)},removeMeta(u,g={}){return this.removeItem(u+"$",g)},async getKeys(u,g={}){u=Ko(u);let y=i(u,!0),S=[],I=[];for(let A of y){let R=await dt(A.driver.getKeys,A.relativeBase,g);for(let O of R){let N=A.mountpoint+Bt(O);S.some(U=>N.startsWith(U))||I.push(N)}S=[A.mountpoint,...S.filter(O=>!O.startsWith(A.mountpoint))]}return u?I.filter(A=>A.startsWith(u)&&A[A.length-1]!=="$"):I.filter(A=>A[A.length-1]!=="$")},async clear(u,g={}){u=Ko(u),await Promise.all(i(u,!1).map(async y=>{if(y.driver.clear)return dt(y.driver.clear,y.relativeBase,g);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",g);return Promise.all(S.map(I=>y.driver.removeItem(I,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>hg(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,g){if(u=Ko(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[u]=g,e.watching&&Promise.resolve(ug(g,n,u)).then(y=>{e.unwatch[u]=y}).catch(console.error),f},async unmount(u,g=!0){u=Ko(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),g&&await hg(e.mounts[u]),e.mountpoints=e.mountpoints.filter(y=>y!==u),delete e.mounts[u])},getMount(u=""){u=Bt(u)+":";let g=t(u);return{driver:g.driver,base:g.base}},getMounts(u="",g={}){return u=Bt(u),i(u,g.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(u,g={})=>f.getKeys(u,g),get:(u,g={})=>f.getItem(u,g),set:(u,g,y={})=>f.setItem(u,g,y),has:(u,g={})=>f.hasItem(u,g),del:(u,g={})=>f.removeItem(u,g),remove:(u,g={})=>f.removeItem(u,g)};return f}function ug(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function hg(r){typeof r.dispose=="function"&&await dt(r.dispose)}function jn(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function ah(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=jn(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var oh;function Vo(){return oh||(oh=ah("keyval-store","keyval")),oh}function ch(r,e=Vo()){return e("readonly",t=>jn(t.get(r)))}function lg(r,e,t=Vo()){return t("readwrite",i=>(i.put(e,r),jn(i.transaction)))}function pg(r,e=Vo()){return e("readwrite",t=>(t.delete(r),jn(t.transaction)))}function gg(r=Vo()){return r("readwrite",e=>(e.clear(),jn(e.transaction)))}function H6(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},jn(r.transaction)}function mg(r=Vo()){return r("readonly",e=>{if(e.getAllKeys)return jn(e.getAllKeys());let t=[];return H6(e,i=>t.push(i.key)).then(()=>t)})}var G6=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),W6=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ei(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return W6(r)}catch{return r}}function cr(r){return typeof r=="string"?r:G6(r)||""}var J6="idb-keyval",Y6=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=ah(r.dbName,r.storeName)),{name:J6,options:r,async hasItem(n){return!(typeof await ch(t(n),i)>"u")},async getItem(n){return await ch(t(n),i)??null},setItem(n,s){return lg(t(n),s,i)},removeItem(n){return pg(t(n),i)},getKeys(){return mg(i)},clear(){return gg(i)}}},X6="WALLET_CONNECT_V2_INDEXED_DB",Q6="keyvaluestorage",uh=class{constructor(){this.indexedDb=dg({driver:Y6({dbName:X6,storeName:Q6})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,cr(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},fh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Sc={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof fh<"u"&&fh.localStorage?Sc.exports=fh.localStorage:typeof window<"u"&&window.localStorage?Sc.exports=window.localStorage:Sc.exports=new e})();function Z6(r){var e;return[r[0],ei((e=r[1])!=null?e:"")]}var hh=class{constructor(){this.localStorage=Sc.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Z6)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return ei(t)}async setItem(e,t){this.localStorage.setItem(e,cr(t))}async removeItem(e){this.localStorage.removeItem(e)}},e5="wc_storage_version",bg=1,t5=async(r,e,t)=>{let i=e5,n=await e.getItem(i);if(n&&n>=bg){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let a=s.shift();if(!a)continue;let f=a.toLowerCase();if(f.includes("wc@")||f.includes("walletconnect")||f.includes("wc_")||f.includes("wallet_connect")){let u=await r.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(i,bg),t(e),r5(r,o)},r5=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},Ic=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new hh;this.storage=e;try{let t=new uh;t5(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var Ii=Be(ph()),Go=Be(ph());var g5={level:"info"},Wo="custom_context",vh=1e3*1024,gh=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Mc=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new gh(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},Rc=class{constructor(e,t=vh){this.level=e??"error",this.levelValue=Ii.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Mc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Ii.levels.values.error?console.error(e):t===Ii.levels.values.warn||t===Ii.levels.values.debug||t===Ii.levels.values.trace&&console.trace(e)}appendToLogs(e){this.logs.append(cr({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Mc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(cr({extraMetadata:e})),new Blob(t,{type:"application/json"})}},mh=class{constructor(e,t=vh){this.baseChunkLogger=new Rc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},bh=class{constructor(e,t=vh){this.baseChunkLogger=new Rc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},m5=Object.defineProperty,b5=Object.defineProperties,v5=Object.getOwnPropertyDescriptors,Sg=Object.getOwnPropertySymbols,y5=Object.prototype.hasOwnProperty,w5=Object.prototype.propertyIsEnumerable,Ig=(r,e,t)=>e in r?m5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Pc=(r,e)=>{for(var t in e||(e={}))y5.call(e,t)&&Ig(r,t,e[t]);if(Sg)for(var t of Sg(e))w5.call(e,t)&&Ig(r,t,e[t]);return r},Nc=(r,e)=>b5(r,v5(e));function Jo(r){return Nc(Pc({},r),{level:r?.level||g5.level})}function x5(r,e=Wo){return r[e]||""}function _5(r,e,t=Wo){return r[t]=e,r}function Tt(r,e=Wo){let t="";return typeof r.bindings>"u"?t=x5(r,e):t=r.bindings().context||"",t}function E5(r,e,t=Wo){let i=Tt(r,t);return i.trim()?`${i}/${e}`:e}function wt(r,e,t=Wo){let i=E5(r,e,t),n=r.child({context:i});return _5(n,i,t)}function S5(r){var e,t;let i=new mh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ii.default)(Nc(Pc({},r.opts),{level:"trace",browser:Nc(Pc({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function I5(r){var e;let t=new bh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ii.default)(Nc(Pc({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Ag(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?S5(r):I5(r)}var Tg=Be(kn()),Cc=class extends _r{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var Dc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},Oc=class{constructor(e,t){this.logger=e,this.core=t}},Lc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}},Fc=class extends _r{constructor(e){super()}},Uc=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var qc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}};var Bc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t}};var kc=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},zc=class{constructor(e,t){this.projectId=e,this.logger=t}},jc=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Kc=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Vc=class{constructor(e){this.client=e}};var ne=Be(Ts());var oa=Be(i1()),O1=Be(Yo()),L1=Be(Ts());var n1="EdDSA",s1="JWT",Zo=".",ea="base64url",Uh="utf8",qh="utf8",o1=":",a1="did",c1="key",Bh="base58btc",f1="z",u1="K36";function ta(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Hn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=ta(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var Vh={};qt(Vh,{identity:()=>I4});function w4(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var D=k-O;D!==k&&B[D]===0;)D++;for(var W=f.repeat(R);D>>0,k=new Uint8Array(U);A[R];){var B=t[A.charCodeAt(R)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,R++}if(A[R]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var D=new Uint8Array(O+(U-L)),W=O;L!==U;)D[W++]=k[L++];return D}}}function I(A){var R=S(A);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var x4=w4,_4=x4,h1=_4;var TP=new Uint8Array(0);var d1=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var l1=r=>new TextEncoder().encode(r),p1=r=>new TextDecoder().decode(r);var kh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},zh=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return m1(this,e)}},jh=class{constructor(e){this.decoders=e}or(e){return m1(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},m1=(r,e)=>new jh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Kh=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new kh(e,t,i),this.decoder=new zh(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Os=({name:r,prefix:e,encode:t,decode:i})=>new Kh(r,e,t,i),Yi=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=h1(t,e);return Os({prefix:r,name:e,encode:i,decode:s=>Ti(n(s))})},E4=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},S4=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<Os({prefix:e,name:r,encode(n){return S4(n,i,t)},decode(n){return E4(n,i,t,r)}});var I4=Os({prefix:"\0",name:"identity",encode:r=>p1(r),decode:r=>l1(r)});var $h={};qt($h,{base2:()=>A4});var A4=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Hh={};qt(Hh,{base8:()=>T4});var T4=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gh={};qt(Gh,{base10:()=>M4});var M4=Yi({prefix:"9",name:"base10",alphabet:"0123456789"});var Wh={};qt(Wh,{base16:()=>R4,base16upper:()=>P4});var R4=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),P4=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Jh={};qt(Jh,{base32:()=>Ls,base32hex:()=>O4,base32hexpad:()=>F4,base32hexpadupper:()=>U4,base32hexupper:()=>L4,base32pad:()=>C4,base32padupper:()=>D4,base32upper:()=>N4,base32z:()=>q4});var Ls=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),N4=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),C4=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),D4=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),O4=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),L4=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),F4=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),U4=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),q4=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yh={};qt(Yh,{base36:()=>B4,base36upper:()=>k4});var B4=Yi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),k4=Yi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xh={};qt(Xh,{base58btc:()=>ri,base58flickr:()=>z4});var ri=Yi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),z4=Yi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qh={};qt(Qh,{base64:()=>j4,base64pad:()=>K4,base64url:()=>V4,base64urlpad:()=>$4});var j4=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),K4=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V4=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$4=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zh={};qt(Zh,{base256emoji:()=>Y4});var b1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),H4=b1.reduce((r,e,t)=>(r[t]=e,r),[]),G4=b1.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function W4(r){return r.reduce((e,t)=>(e+=H4[t],e),"")}function J4(r){let e=[];for(let t of r){let i=G4[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Y4=Os({prefix:"\u{1F680}",name:"base256emoji",encode:W4,decode:J4});var id={};qt(id,{sha256:()=>gx,sha512:()=>mx});var X4=w1,v1=128,Q4=127,Z4=~Q4,ex=Math.pow(2,31);function w1(r,e,t){e=e||[],t=t||0;for(var i=t;r>=ex;)e[t++]=r&255|v1,r/=128;for(;r&Z4;)e[t++]=r&255|v1,r>>>=7;return e[t]=r|0,w1.bytes=t-i+1,e}var tx=ed,rx=128,y1=127;function ed(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw ed.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&y1)<=rx);return ed.bytes=s-i,t}var ix=Math.pow(2,7),nx=Math.pow(2,14),sx=Math.pow(2,21),ox=Math.pow(2,28),ax=Math.pow(2,35),cx=Math.pow(2,42),fx=Math.pow(2,49),ux=Math.pow(2,56),hx=Math.pow(2,63),dx=function(r){return r[ra.decode(r,e),ra.decode.bytes],Fs=(r,e,t=0)=>(ra.encode(r,e,t),e),Us=r=>ra.encodingLength(r);var Gn=(r,e)=>{let t=e.byteLength,i=Us(r),n=i+Us(t),s=new Uint8Array(n+t);return Fs(r,s,0),Fs(t,s,i),s.set(e,n),new qs(r,t,e,s)},x1=r=>{let e=Ti(r),[t,i]=ia(e),[n,s]=ia(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new qs(t,n,o,e)},_1=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&d1(r.bytes,e.bytes),qs=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var rd=({name:r,code:e,encode:t})=>new td(r,e,t),td=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Gn(this.code,t):t.then(i=>Gn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var S1=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),gx=rd({name:"sha2-256",code:18,encode:S1("SHA-256")}),mx=rd({name:"sha2-512",code:19,encode:S1("SHA-512")});var nd={};qt(nd,{identity:()=>yx});var I1=0,bx="identity",A1=Ti,vx=r=>Gn(I1,A1(r)),yx={code:I1,name:bx,encode:A1,digest:vx};var WP=new TextEncoder,JP=new TextDecoder;var Zc=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Qc,byteLength:Qc,code:Xc,version:Xc,multihash:Xc,bytes:Xc,_baseCache:Qc,asCID:Qc})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==sa)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ix)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=Gn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&_1(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return Ex(t,n,e||ri.encoder);default:return Sx(t,n,e||Ls.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Tx(/^0\.0/,Mx),!!(e&&(e[M1]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||T1(t,i,n.bytes))}else if(e!=null&&e[M1]===!0){let{version:t,multihash:i,code:n}=e,s=x1(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==sa)throw new Error(`Version 0 CID must use dag-pb (code: ${sa}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=T1(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,sa,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=Ti(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new qs(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=ia(e.subarray(t));return t+=S,y},n=i(),s=sa;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,a=i(),f=i(),u=t+f,g=u-o;return{version:n,codec:s,multihashCode:a,digestSize:f,multihashSize:g,size:u}}static parse(e,t){let[i,n]=_x(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},_x=(r,e)=>{switch(r[0]){case"Q":{let t=e||ri;return[ri.prefix,t.decode(`${ri.prefix}${r}`)]}case ri.prefix:{let t=e||ri;return[ri.prefix,t.decode(r)]}case Ls.prefix:{let t=e||Ls;return[Ls.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Ex=(r,e,t)=>{let{prefix:i}=t;if(i!==ri.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},Sx=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},sa=112,Ix=18,T1=(r,e,t)=>{let i=Us(r),n=i+Us(e),s=new Uint8Array(n+t.byteLength);return Fs(r,s,0),Fs(e,s,i),s.set(t,n),s},M1=Symbol.for("@ipld/js-cid/CID"),Xc={writable:!1,configurable:!1,enumerable:!0},Qc={writable:!1,enumerable:!1,configurable:!1},Ax="0.0.0-dev",Tx=(r,e)=>{if(!r.test(Ax))throw new Error(e)},Mx=`CID.isCID(v) is deprecated and will be removed in the next major release. Following code pattern: if (CID.isCID(value)) { @@ -27,16 +27,18 @@ if (cid) { // Make sure to use cid instead of value doSomethingWithCID(cid) } -`;var ed={...Bh,...kh,...zh,...jh,...Kh,...Vh,...$h,...Hh,...Gh,...Wh},VR={...Qh,...Zh};function E1(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var _1=E1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),td=E1("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Yo(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new D4:typeof navigator<"u"?C1(navigator.userAgent):q4()}function F4(r){return r!==""&&L4.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function C1(r){var e=F4(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new N4;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var am=o8(),od;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(od||(od={}));var Er;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Er||(Er={}));var cm="0123456789abcdef",lt=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();tf[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(om>tf[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(sm)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(f=>{let u=i[f];try{if(u instanceof Uint8Array){let g="";for(let y=0;y>4],g+=cm[u[y]&15];n.push(f+"=Uint8Array(0x"+g+")")}else n.push(f+"="+JSON.stringify(u))}catch{n.push(f+"="+JSON.stringify(i[f].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case Er.NUMERIC_FAULT:{o="NUMERIC_FAULT";let f=e;switch(f){case"overflow":case"underflow":case"division-by-zero":o+="-"+f;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Er.CALL_EXCEPTION:case Er.INSUFFICIENT_FUNDS:case Er.MISSING_NEW:case Er.NONCE_EXPIRED:case Er.REPLACEMENT_UNDERPRICED:case Er.TRANSACTION_REPLACED:case Er.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let a=new Error(e);return a.reason=s,a.code=t,Object.keys(i).forEach(function(f){a[f]=i[f]}),a}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),am&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:am})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return sd||(sd=new r(im)),sd}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),nm){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}sm=!!e,nm=!!t}static setLogLevel(e){let t=tf[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}om=t}static from(e){return new r(e)}};lt.errors=Er;lt.levels=od;var fm="bytes/5.7.0";var ft=new lt(fm);function hm(r){return!!r.toHexString}function Fs(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return Fs(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function dm(r){return Sr(r)&&!(r.length%2)||cd(r)}function um(r){return typeof r=="number"&&r==r&&r%1===0}function cd(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!um(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Qe(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),Fs(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),hm(r)&&(r=r.toHexString()),Sr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":ft.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nQe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),Fs(i)}function a8(r,e){r=Qe(r),r.length>e&&ft.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),Fs(t)}function Sr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var ad="0123456789abcdef";function Pt(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=ad[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),hm(r))return r.toHexString();if(Sr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":ft.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(cd(r)){let t="0x";for(let i=0;i>4]+ad[n&15]}return t}return ft.throwArgumentError("invalid hexlify value","value",r)}function rf(r){if(typeof r!="string")r=Pt(r);else if(!Sr(r)||r.length%2)return null;return(r.length-2)/2}function nf(r,e,t){return typeof r!="string"?r=Pt(r):(!Sr(r)||r.length%2)&&ft.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Gi(r,e){for(typeof r!="string"?r=Pt(r):Sr(r)||ft.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&ft.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function sf(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(dm(r)){let t=Qe(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Pt(t.slice(0,32)),e.s=Pt(t.slice(32,64))):t.length===65?(e.r=Pt(t.slice(0,32)),e.s=Pt(t.slice(32,64)),e.v=t[64]):ft.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:ft.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Pt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=a8(Qe(e._vs),32);e._vs=Pt(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&ft.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=Pt(n);e.s==null?e.s=o:e.s!==o&&ft.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?ft.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&ft.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!Sr(e.r)?ft.throwArgumentError("signature missing or invalid r","signature",r):e.r=Gi(e.r,32),e.s==null||!Sr(e.s)?ft.throwArgumentError("signature missing or invalid s","signature",r):e.s=Gi(e.s,32);let t=Qe(e.s);t[0]>=128&&ft.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=Pt(t);e._vs&&(Sr(e._vs)||ft.throwArgumentError("signature invalid _vs","signature",r),e._vs=Gi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&ft.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function Us(r){return"0x"+lm.default.keccak_256(Qe(r))}var mm=Be(dd());var gm="bignumber/5.7.0";var c8=mm.default.BN,UN=new lt(gm);function ld(r){return new c8(r,36).toString(16)}var bm="strings/5.7.0";var vm=new lt(bm),ra;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(ra||(ra={}));var $n;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})($n||($n={}));function u8(r,e,t,i,n){return vm.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function ym(r,e,t,i,n){if(r===$n.BAD_PREFIX||r===$n.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===$n.OVERRUN?t.length-e-1:0}function h8(r,e,t,i,n){return r===$n.OVERLONG?(i.push(n),0):(i.push(65533),ym(r,e,t,i,n))}var d8=Object.freeze({error:u8,ignore:ym,replace:h8});function ia(r,e=ra.current){e!=ra.current&&(vm.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return Qe(t)}var wm=`Ethereum Signed Message: -`;function of(r){return typeof r=="string"&&(r=ia(r)),Us(fd([ia(wm),ia(String(r.length)),r]))}var xm="address/5.7.0";var na=new lt(xm);function _m(r){Sr(r,20)||na.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=Qe(Us(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var p8=9007199254740991;function g8(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var pd={};for(let r=0;r<10;r++)pd[String(r)]=String(r);for(let r=0;r<26;r++)pd[String.fromCharCode(65+r)]=String(10+r);var Em=Math.floor(g8(p8));function m8(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>pd[i]).join("");for(;e.length>=Em;){let i=e.substring(0,Em);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function Sm(r){let e=null;if(typeof r!="string"&&na.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=_m(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&na.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==m8(r)&&na.throwArgumentError("bad icap checksum","address",r),e=ld(r.substring(4));e.length<40;)e="0"+e;e=_m("0x"+e)}else na.throwArgumentError("invalid address","address",r);return e}var Im="properties/5.7.0";var dD=new lt(Im);function qs(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Le=Be(dd()),ai=Be(ca());function $s(r,e,t){return t={path:e,exports:{},require:function(i,n){return B_(i,n??t.path)}},r(t,t.exports),t.exports}function B_(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Md=cb;function cb(r,e){if(!r)throw new Error(e||"Assertion failed")}cb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Tr=$s(function(r,e){"use strict";var t=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var f=[];if(typeof o!="string"){for(var u=0;u>8,S=g&255;y?f.push(y,S):f.push(S)}return f}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var a="",f=0;f(S>>1)-1?P=(S>>1)-O:P=O,I.isubn(P)):P=0,y[A]=P,I.iushrn(1)}return y}t.getNAF=i;function n(f,u){var g=[[],[]];f=f.clone(),u=u.clone();for(var y=0,S=0,I;f.cmpn(-y)>0||u.cmpn(-S)>0;){var A=f.andln(3)+y&3,P=u.andln(3)+S&3;A===3&&(A=-1),P===3&&(P=-1);var O;A&1?(I=f.andln(7)+y&7,(I===3||I===5)&&P===2?O=-A:O=A):O=0,g[0].push(O);var N;P&1?(I=u.andln(7)+S&7,(I===3||I===5)&&A===2?N=-P:N=P):N=0,g[1].push(N),2*y===O+1&&(y=1-y),2*S===N+1&&(S=1-S),f.iushrn(1),u.iushrn(1)}return g}t.getJSF=n;function s(f,u,g){var y="_"+u;f.prototype[u]=function(){return this[y]!==void 0?this[y]:this[y]=g.call(this)}}t.cachedProperty=s;function o(f){return typeof f=="string"?t.toArray(f,"hex"):f}t.parseBytes=o;function a(f){return new Le.default(f,"hex","le")}t.intFromLE=a}),hf=Jt.getNAF,k_=Jt.getJSF,df=Jt.assert;function Xi(r,e){this.type=r,this.p=new Le.default(e.p,16),this.red=e.prime?Le.default.red(e.prime):Le.default.mont(this.p),this.zero=new Le.default(0).toRed(this.red),this.one=new Le.default(1).toRed(this.red),this.two=new Le.default(2).toRed(this.red),this.n=e.n&&new Le.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Gn=Xi;Xi.prototype.point=function(){throw new Error("Not implemented")};Xi.prototype.validate=function(){throw new Error("Not implemented")};Xi.prototype._fixedNafMul=function(e,t){df(e.precomputed);var i=e._getDoubles(),n=hf(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];df(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};Xi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,P=g;if(o[A]!==1||o[P]!==1){f[A]=hf(i[A],o[A],this._bitLength),f[P]=hf(i[P],o[P],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[P].length,u);continue}var O=[t[A],null,null,t[P]];t[A].y.cmp(t[P].y)===0?(O[1]=t[A].add(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg())):t[A].y.cmp(t[P].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].add(t[P].neg())):(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=k_(i[A],i[P]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[P]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var C=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};ur.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};hr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};hr.prototype.pointFromX=function(e,t){e=new Le.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};hr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};hr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};pt.prototype.isInfinity=function(){return this.inf};pt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};pt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};pt.prototype.getX=function(){return this.x.fromRed()};pt.prototype.getY=function(){return this.y.fromRed()};pt.prototype.mul=function(e){return e=new Le.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};pt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};pt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};pt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};pt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};pt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function _t(r,e,t,i){Gn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Le.default(0)):(this.x=new Le.default(e,16),this.y=new Le.default(t,16),this.z=new Le.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Td(_t,Gn.BasePoint);hr.prototype.jpoint=function(e,t,i){return new _t(this,e,t,i)};_t.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};_t.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};_t.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,P)};_t.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};_t.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};_t.prototype.inspect=function(){return this.isInfinity()?"":""};_t.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ff=$s(function(r,e){"use strict";var t=e;t.base=Gn,t.short=j_,t.mont=null,t.edwards=null}),uf=$s(function(r,e){"use strict";var t=e,i=Jt.assert;function n(a){a.type==="short"?this.curve=new ff.short(a):a.type==="edwards"?this.curve=new ff.edwards(a):this.curve=new ff.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(a,f){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var u=new n(f);return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,value:u}),u}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:ai.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:ai.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:ai.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:ai.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:ai.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ai.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ai.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:ai.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Yi(r){if(!(this instanceof Yi))return new Yi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Tr.toArray(r.entropy,r.entropyEnc||"hex"),t=Tr.toArray(r.nonce,r.nonceEnc||"hex"),i=Tr.toArray(r.pers,r.persEnc||"hex");Md(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var fb=Yi;Yi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Yi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Tr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var K_=Jt.assert;function lf(r,e){if(r instanceof lf)return r;this._importDER(r,e)||(K_(r.r&&r.s,"Signature without r or s"),this.r=new Le.default(r.r,16),this.s=new Le.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var pf=lf;function V_(){this.place=0}function Sd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function ab(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}lf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=ab(t),i=ab(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Id(n,t.length),n=n.concat(t),n.push(2),Id(n,i.length);var s=n.concat(i),o=[48];return Id(o,s.length),o=o.concat(s),Jt.encode(o,e)};var $_=function(){throw new Error("unsupported")},ub=Jt.assert;function fr(r){if(!(this instanceof fr))return new fr(r);typeof r=="string"&&(ub(Object.prototype.hasOwnProperty.call(uf,r),"Unknown curve "+r),r=uf[r]),r instanceof uf.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var H_=fr;fr.prototype.keyPair=function(e){return new Pd(this,e)};fr.prototype.keyFromPrivate=function(e,t){return Pd.fromPrivate(this,e,t)};fr.prototype.keyFromPublic=function(e,t){return Pd.fromPublic(this,e,t)};fr.prototype.genKeyPair=function(e){e||(e={});for(var t=new fb({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||$_(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Le.default(2));;){var s=new Le.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};fr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};fr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Le.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new fb({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Le.default(1)),g=0;;g++){var y=n.k?n.k(g):new Le.default(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var P=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(P=P.umod(this.n),P.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),O^=1),new pf({r:A,s:P,recoveryParam:O})}}}}}};fr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Le.default(e,16)),i=this.keyFromPublic(i,n),t=new pf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};fr.prototype.recoverPubKey=function(r,e,t,i){ub((3&t)===t,"The recovery param is more than two bits"),e=new pf(e,i);var n=this.n,s=new Le.default(r),o=e.r,a=e.s,f=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};fr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new pf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var G_=$s(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=Jt,t.rand=function(){throw new Error("unsupported")},t.curve=ff,t.curves=uf,t.ec=H_,t.eddsa=null}),hb=G_.ec;var db="signing-key/5.7.0";var Nd=new lt(db),Rd=null;function ci(){return Rd||(Rd=new hb("secp256k1")),Rd}var Dd=class{constructor(e){qs(this,"curve","secp256k1"),qs(this,"privateKey",Pt(e)),rf(this.privateKey)!==32&&Nd.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=ci().keyFromPrivate(Qe(this.privateKey));qs(this,"publicKey","0x"+t.getPublic(!1,"hex")),qs(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),qs(this,"_isSigningKey",!0)}_addPoint(e){let t=ci().keyFromPublic(Qe(this.publicKey)),i=ci().keyFromPublic(Qe(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=ci().keyFromPrivate(Qe(this.privateKey)),i=Qe(e);i.length!==32&&Nd.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return sf({recoveryParam:n.recoveryParam,r:Gi("0x"+n.r.toString(16),32),s:Gi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=ci().keyFromPrivate(Qe(this.privateKey)),i=ci().keyFromPublic(Qe(Cd(e)));return Gi("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function lb(r,e){let t=sf(e),i={r:Qe(t.r),s:Qe(t.s)};return"0x"+ci().recoverPubKey(Qe(r),i,t.recoveryParam).encode("hex",!1)}function Cd(r,e){let t=Qe(r);if(t.length===32){let i=new Dd(t);return e?"0x"+ci().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Pt(t):"0x"+ci().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+ci().keyFromPublic(t).getPublic(!0,"hex"):Pt(t)}return Nd.throwArgumentError("invalid public or private key","key","[REDACTED]")}var pb="transactions/5.7.0";var HD=new lt(pb),gb;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(gb||(gb={}));function W_(r){let e=Cd(r);return Sm(nf(Us(nf(e,1)),12))}function mb(r,e){return W_(lb(Qe(r),e))}var nl=Be(Sb()),Kv=Be(Rb()),va=Be($o()),Zs=Be(Db()),Uf=Be(Fb());var Vv=Be(Pv());var Rv={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var XE=":";function ya(r){let[e,t]=r.split(XE);return{namespace:e,reference:t}}function $v(r,e){return r.includes(":")?[r]:e.chains||[]}var QE=Object.defineProperty,Nv=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,e9=Object.prototype.propertyIsEnumerable,Dv=(r,e,t)=>e in r?QE(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cv=(r,e)=>{for(var t in e||(e={}))ZE.call(e,t)&&Dv(r,t,e[t]);if(Nv)for(var t of Nv(e))e9.call(e,t)&&Dv(r,t,e[t]);return r},t9="ReactNative",Vt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var r9="js";function wa(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ts(){return!(0,Li.getDocument)()&&!!(0,Li.getNavigator)()&&navigator.product===t9}function eo(){return!wa()&&!!(0,Li.getNavigator)()&&!!(0,Li.getDocument)()}function xa(){return ts()?Vt.reactNative:wa()?Vt.node:eo()?Vt.browser:Vt.unknown}function Hv(){var r;try{return ts()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function i9(r,e){let t=Qs.parse(r);return t=Cv(Cv({},t),e),r=Qs.stringify(t),r}function to(){return(0,jv.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function n9(){if(xa()===Vt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){let{OS:t,Version:i}=global.Platform;return[t,i].join("-")}let r=O1();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function s9(){var r;let e=xa();return e===Vt.browser?[e,((r=(0,Li.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function sl(r,e,t){let i=n9(),n=s9();return[[r,e].join("-"),[r9,t].join("-"),i,n].join("/")}function Gv({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a}){let f=t.split("?"),u=sl(r,e,i),g={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},y=i9(f[1]||"",g);return f[0]+"?"+y}function Zn(r,e){return r.filter(t=>e.includes(t)).length===r.length}function ol(r){return Object.fromEntries(r.entries())}function al(r){return new Map(Object.entries(r))}function Fi(r=Oi.FIVE_MINUTES,e){let t=(0,Oi.toMiliseconds)(r||Oi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,a)=>{s=setTimeout(()=>{a(new Error(e))},t),i=o,n=a})}}function rs(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Wv(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Jv(r){return Wv("topic",r)}function Yv(r){return Wv("id",r)}function qf(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ut(r,e){return(0,Oi.fromMiliseconds)((e||Date.now())+(0,Oi.toMiliseconds)(r))}function li(r){return Date.now()>=(0,Oi.toMiliseconds)(r)}function Fe(r,e){return`${r}${e?`:${e}`:""}`}function o9(r=[],e=[]){return[...new Set([...r,...e])]}async function Xv({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=a9(s,r,e),a=xa();if(a===Vt.browser){if(!((i=(0,Li.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,c9()?"_blank":"_self","noreferrer noopener")}else a===Vt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function a9(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${f9(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Qv(r,e){let t="";try{if(eo()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function cl(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function fl(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function _a(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function c9(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function f9(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Zv(r){return Buffer.from(r,"base64").toString("utf-8")}var u9="https://rpc.walletconnect.org/v1";async function h9(r,e,t,i,n,s){switch(t.t){case"eip191":return d9(r,e,t.s);case"eip1271":return await l9(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function d9(r,e,t){return mb(of(e),t).toLowerCase()===r.toLowerCase()}async function l9(r,e,t,i,n,s){let o=ya(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let a="0x1626ba7e",f="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",g=t.substring(2),y=of(e).substring(2),S=a+y+f+u+g,I=await fetch(`${s||u9}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:p9(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:A}=await I.json();return A?A.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function p9(){return Date.now()+Math.floor(Math.random()*1e3)}var g9=Object.defineProperty,m9=Object.defineProperties,b9=Object.getOwnPropertyDescriptors,Ov=Object.getOwnPropertySymbols,v9=Object.prototype.hasOwnProperty,y9=Object.prototype.propertyIsEnumerable,Lv=(r,e,t)=>e in r?g9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,w9=(r,e)=>{for(var t in e||(e={}))v9.call(e,t)&&Lv(r,t,e[t]);if(Ov)for(var t of Ov(e))y9.call(e,t)&&Lv(r,t,e[t]);return r},x9=(r,e)=>m9(r,b9(e)),_9="did:pkh:",ul=r=>r?.split(":"),E9=r=>{let e=r&&ul(r);if(e)return r.includes(_9)?e[3]:e[1]},Bf=r=>{let e=r&&ul(r);if(e)return e[2]+":"+e[3]},Ea=r=>{let e=r&&ul(r);if(e)return e.pop()};async function hl(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=dl(n,n.iss),o=Ea(n.iss);return await h9(o,s,i,Bf(n.iss),t)}var dl=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ea(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,a=`Chain ID: ${E9(e)}`,f=`Nonce: ${r.nonce}`,u=`Issued At: ${r.iat}`,g=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(P=>` -- ${P}`).join("")}`:void 0,A=Sa(r.resources);if(A){let P=ba(A);n=R9(n,P)}return[t,i,"",n,"",s,o,a,f,u,g,y,S,I].filter(P=>P!=null).join(` -`)};function S9(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function I9(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function es(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function A9(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:M9(e,t,i)}}}function M9(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function ey(r){return es(r),`urn:recap:${S9(r).replace(/=/g,"")}`}function ba(r){let e=I9(r.replace("urn:recap:",""));return es(e),e}function ty(r,e,t){let i=A9(r,e,t);return ey(i)}function T9(r){return r&&r.includes("urn:recap:")}function ry(r,e){let t=ba(r),i=ba(e),n=P9(t,i);return ey(n)}function P9(r,e){es(r),es(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,f)=>a.localeCompare(f)).forEach(a=>{var f,u;i.att[n]=x9(w9({},i.att[n]),{[a]:((f=r.att[n])==null?void 0:f[a])||((u=e.att[n])==null?void 0:u[a])})})}),i}function R9(r="",e){es(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(a=>{let f=Object.keys(e.att[a]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));f.sort((y,S)=>y.action.localeCompare(S.action));let u={};f.forEach(y=>{u[y.ability]||(u[y.ability]=[]),u[y.ability].push(y.action)});let g=Object.keys(u).map(y=>(n++,`(${n}) '${y}': '${u[y].join("', '")}' for '${a}'.`));i.push(g.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function ll(r){var e;let t=ba(r);es(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function pl(r){let e=ba(r);es(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Sa(r){if(!r)return;let e=r?.[r.length-1];return T9(e)?e:void 0}var iy="base10",Ct="base16",pi="base64pad",ro="base64url",Ia="utf8",ny=0,Rr=1,io=2,N9=0,Fv=1,ma=12,gl=32;function sy(){let r=Uf.generateKeyPair();return{privateKey:rt(r.secretKey,Ct),publicKey:rt(r.publicKey,Ct)}}function kf(){let r=(0,va.randomBytes)(gl);return rt(r,Ct)}function oy(r,e){let t=Uf.sharedKey(at(r,Ct),at(e,Ct),!0),i=new Kv.HKDF(Zs.SHA256,t).expand(gl);return rt(i,Ct)}function no(r){let e=(0,Zs.hash)(at(r,Ct));return rt(e,Ct)}function Nr(r){let e=(0,Zs.hash)(at(r,Ia));return rt(e,Ct)}function ay(r){return at(`${r}`,iy)}function sn(r){return Number(rt(r,iy))}function cy(r){let e=ay(typeof r.type<"u"?r.type:ny);if(sn(e)===Rr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?at(r.senderPublicKey,Ct):void 0,i=typeof r.iv<"u"?at(r.iv,Ct):(0,va.randomBytes)(ma),n=new nl.ChaCha20Poly1305(at(r.symKey,Ct)).seal(i,at(r.message,Ia));return dy({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function fy(r,e){let t=ay(io),i=(0,va.randomBytes)(ma),n=at(r,Ia);return dy({type:t,sealed:n,iv:i,encoding:e})}function uy(r){let e=new nl.ChaCha20Poly1305(at(r.symKey,Ct)),{sealed:t,iv:i}=so({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return rt(n,Ia)}function hy(r,e){let{sealed:t}=so({encoded:r,encoding:e});return rt(t,Ia)}function dy(r){let{encoding:e=pi}=r;if(sn(r.type)===io)return rt(jn([r.type,r.sealed]),e);if(sn(r.type)===Rr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return rt(jn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return rt(jn([r.type,r.iv,r.sealed]),e)}function so(r){let{encoded:e,encoding:t=pi}=r,i=at(e,t),n=i.slice(N9,Fv),s=Fv;if(sn(n)===Rr){let u=s+gl,g=u+ma,y=i.slice(s,u),S=i.slice(u,g),I=i.slice(g);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(sn(n)===io){let u=i.slice(s),g=(0,va.randomBytes)(ma);return{type:n,sealed:u,iv:g}}let o=s+ma,a=i.slice(s,o),f=i.slice(o);return{type:n,sealed:f,iv:a}}function ly(r,e){let t=so({encoded:r,encoding:e?.encoding});return ml({type:sn(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?rt(t.senderPublicKey,Ct):void 0,receiverPublicKey:e?.receiverPublicKey})}function ml(r){let e=r?.type||ny;if(e===Rr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function bl(r){return r.type===Rr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function vl(r){return r.type===io}function D9(r){return new Vv.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function C9(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function O9(r){return Buffer.from(C9(r),"base64")}function py(r,e){let[t,i,n]=r.split("."),s=O9(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),f=`${t}.${i}`,u=new Zs.SHA256().update(Buffer.from(f)).digest(),g=D9(e),y=Buffer.from(u).toString("hex");if(!g.verify(y,{r:o,s:a}))throw new Error("Invalid signature");return Os(r).payload}var L9="irn";function zf(r){return r?.relay||{protocol:L9}}function oo(r){let e=Rv[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var F9=Object.defineProperty,U9=Object.defineProperties,q9=Object.getOwnPropertyDescriptors,Uv=Object.getOwnPropertySymbols,B9=Object.prototype.hasOwnProperty,k9=Object.prototype.propertyIsEnumerable,qv=(r,e,t)=>e in r?F9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bv=(r,e)=>{for(var t in e||(e={}))B9.call(e,t)&&qv(r,t,e[t]);if(Uv)for(var t of Uv(e))k9.call(e,t)&&qv(r,t,e[t]);return r},z9=(r,e)=>U9(r,q9(e));function j9(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function yl(r){if(!r.includes("wc:")){let f=Zv(r);f!=null&&f.includes("wc:")&&(r=f)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=Qs.parse(s),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:K9(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:j9(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function K9(r){return r.startsWith("//")?r.substring(2):r}function V9(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function wl(r){return`${r.protocol}:${r.topic}@${r.version}?`+Qs.stringify(Bv(z9(Bv({symKey:r.symKey},V9(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Aa(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function ao(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function $9(r){let e=[];return Object.values(r).forEach(t=>{e.push(...ao(t.accounts))}),e}function H9(r,e){let t=[];return Object.values(r).forEach(i=>{ao(i.accounts).includes(e)&&t.push(...i.methods)}),t}function G9(r,e){let t=[];return Object.values(r).forEach(i=>{ao(i.accounts).includes(e)&&t.push(...i.events)}),t}function W9(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function xl(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=W9(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=o9(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var J9={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Y9={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Q(r,e){let{message:t,code:i}=Y9[r];return{message:e?`${t} ${e}`:t,code:i}}function ke(r,e){let{message:t,code:i}=J9[r];return{message:e?`${t} ${e}`:t,code:i}}function an(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function Ma(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function St(r){return typeof r>"u"}function et(r,e){return e&&St(r)?!0:typeof r=="string"&&!!r.trim().length}function _l(r,e){return e&&St(r)?!0:typeof r=="number"&&!isNaN(r)}function gy(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return Zn(n,i)?(i.forEach(o=>{let{accounts:a,methods:f,events:u}=r.namespaces[o],g=ao(a),y=t[o];(!Zn($v(o,y),g)||!Zn(y.methods,f)||!Zn(y.events,u))&&(s=!1)}),s):!1}function Ff(r){return et(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function X9(r){if(et(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&Ff(t)}}return!1}function my(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(et(r,!1)){if(e(r))return!0;let t=Zv(r);return e(t)}}catch{}return!1}function by(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function vy(r){return r?.topic}function yy(r,e){let t=null;return et(r?.publicKey,!1)||(t=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function kv(r){let e=!0;return an(r)?r.length&&(e=r.every(t=>et(t,!1))):e=!1,e}function Q9(r,e,t){let i=null;return an(e)&&e.length?e.forEach(n=>{i||Ff(n)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Ff(r)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Z9(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=Q9(n,$v(n,s),`${e} ${t}`);o&&(i=o)}),i}function e7(r,e){let t=null;return an(r)?r.forEach(i=>{t||X9(i)||(t=ke("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=ke("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function t7(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=e7(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function r7(r,e){let t=null;return kv(r?.methods)?kv(r?.events)||(t=ke("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=ke("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function wy(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=r7(i,`${e}, namespace`);n&&(t=n)}),t}function xy(r,e,t){let i=null;if(r&&Ma(r)){let n=wy(r,e);n&&(i=n);let s=Z9(r,e,t);s&&(i=s)}else i=Q("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function jf(r,e){let t=null;if(r&&Ma(r)){let i=wy(r,e);i&&(t=i);let n=t7(r,e);n&&(t=n)}else t=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function El(r){return et(r.protocol,!0)}function _y(r,e){let t=!1;return e&&!r?t=!0:r&&an(r)&&r.length&&r.forEach(i=>{t=El(i)}),t}function Ey(r){return typeof r=="number"}function Ot(r){return typeof r<"u"&&typeof r!==null}function Sy(r){return!(!r||typeof r!="object"||!r.code||!_l(r.code,!1)||!r.message||!et(r.message,!1))}function Iy(r){return!(St(r)||!et(r.method,!1))}function Ay(r){return!(St(r)||St(r.result)&&St(r.error)||!_l(r.id,!1)||!et(r.jsonrpc,!1))}function My(r){return!(St(r)||!et(r.name,!1))}function Sl(r,e){return!(!Ff(e)||!$9(r).includes(e))}function Ty(r,e,t){return et(t,!1)?H9(r,e).includes(t):!1}function Py(r,e,t){return et(t,!1)?G9(r,e).includes(t):!1}function Il(r,e,t){let i=null,n=i7(r),s=n7(e),o=Object.keys(n),a=Object.keys(s),f=zv(Object.keys(r)),u=zv(Object.keys(e)),g=f.filter(y=>!u.includes(y));return g.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. +`;var sd={...Vh,...$h,...Hh,...Gh,...Wh,...Jh,...Yh,...Xh,...Qh,...Zh},iN={...id,...nd};function P1(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var R1=P1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),od=P1("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=ta(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new qx:typeof navigator<"u"?k1(navigator.userAgent):Vx()}function jx(r){return r!==""&&zx.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function k1(r){var e=jx(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Ux;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var pm=d8(),hd;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(hd||(hd={}));var Er;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Er||(Er={}));var gm="0123456789abcdef",lt=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();af[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(lm>af[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(dm)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(f=>{let u=i[f];try{if(u instanceof Uint8Array){let g="";for(let y=0;y>4],g+=gm[u[y]&15];n.push(f+"=Uint8Array(0x"+g+")")}else n.push(f+"="+JSON.stringify(u))}catch{n.push(f+"="+JSON.stringify(i[f].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case Er.NUMERIC_FAULT:{o="NUMERIC_FAULT";let f=e;switch(f){case"overflow":case"underflow":case"division-by-zero":o+="-"+f;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Er.CALL_EXCEPTION:case Er.INSUFFICIENT_FUNDS:case Er.MISSING_NEW:case Er.NONCE_EXPIRED:case Er.REPLACEMENT_UNDERPRICED:case Er.TRANSACTION_REPLACED:case Er.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let a=new Error(e);return a.reason=s,a.code=t,Object.keys(i).forEach(function(f){a[f]=i[f]}),a}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),pm&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:pm})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return ud||(ud=new r(um)),ud}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),hm){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}dm=!!e,hm=!!t}static setLogLevel(e){let t=af[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}lm=t}static from(e){return new r(e)}};lt.errors=Er;lt.levels=hd;var mm="bytes/5.7.0";var ft=new lt(mm);function vm(r){return!!r.toHexString}function zs(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return zs(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function ym(r){return Sr(r)&&!(r.length%2)||ld(r)}function bm(r){return typeof r=="number"&&r==r&&r%1===0}function ld(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!bm(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Qe(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),zs(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),vm(r)&&(r=r.toHexString()),Sr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":ft.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nQe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),zs(i)}function l8(r,e){r=Qe(r),r.length>e&&ft.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),zs(t)}function Sr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var dd="0123456789abcdef";function Rt(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=dd[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),vm(r))return r.toHexString();if(Sr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":ft.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(ld(r)){let t="0x";for(let i=0;i>4]+dd[n&15]}return t}return ft.throwArgumentError("invalid hexlify value","value",r)}function cf(r){if(typeof r!="string")r=Rt(r);else if(!Sr(r)||r.length%2)return null;return(r.length-2)/2}function ff(r,e,t){return typeof r!="string"?r=Rt(r):(!Sr(r)||r.length%2)&&ft.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Xi(r,e){for(typeof r!="string"?r=Rt(r):Sr(r)||ft.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&ft.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function uf(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(ym(r)){let t=Qe(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Rt(t.slice(0,32)),e.s=Rt(t.slice(32,64))):t.length===65?(e.r=Rt(t.slice(0,32)),e.s=Rt(t.slice(32,64)),e.v=t[64]):ft.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:ft.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Rt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=l8(Qe(e._vs),32);e._vs=Rt(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&ft.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=Rt(n);e.s==null?e.s=o:e.s!==o&&ft.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?ft.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&ft.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!Sr(e.r)?ft.throwArgumentError("signature missing or invalid r","signature",r):e.r=Xi(e.r,32),e.s==null||!Sr(e.s)?ft.throwArgumentError("signature missing or invalid s","signature",r):e.s=Xi(e.s,32);let t=Qe(e.s);t[0]>=128&&ft.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=Rt(t);e._vs&&(Sr(e._vs)||ft.throwArgumentError("signature invalid _vs","signature",r),e._vs=Xi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&ft.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function js(r){return"0x"+wm.default.keccak_256(Qe(r))}var Em=Be(bd());var _m="bignumber/5.7.0";var p8=Em.default.BN,YN=new lt(_m);function vd(r){return new p8(r,36).toString(16)}var Sm="strings/5.7.0";var Im=new lt(Sm),aa;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(aa||(aa={}));var Jn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(Jn||(Jn={}));function m8(r,e,t,i,n){return Im.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function Am(r,e,t,i,n){if(r===Jn.BAD_PREFIX||r===Jn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===Jn.OVERRUN?t.length-e-1:0}function b8(r,e,t,i,n){return r===Jn.OVERLONG?(i.push(n),0):(i.push(65533),Am(r,e,t,i,n))}var v8=Object.freeze({error:m8,ignore:Am,replace:b8});function ca(r,e=aa.current){e!=aa.current&&(Im.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return Qe(t)}var Tm=`Ethereum Signed Message: +`;function hf(r){return typeof r=="string"&&(r=ca(r)),js(pd([ca(Tm),ca(String(r.length)),r]))}var Mm="address/5.7.0";var fa=new lt(Mm);function Rm(r){Sr(r,20)||fa.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=Qe(js(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var w8=9007199254740991;function x8(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var yd={};for(let r=0;r<10;r++)yd[String(r)]=String(r);for(let r=0;r<26;r++)yd[String.fromCharCode(65+r)]=String(10+r);var Pm=Math.floor(x8(w8));function _8(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>yd[i]).join("");for(;e.length>=Pm;){let i=e.substring(0,Pm);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function Nm(r){let e=null;if(typeof r!="string"&&fa.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=Rm(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&fa.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==_8(r)&&fa.throwArgumentError("bad icap checksum","address",r),e=vd(r.substring(4));e.length<40;)e="0"+e;e=Rm("0x"+e)}else fa.throwArgumentError("invalid address","address",r);return e}var Cm="properties/5.7.0";var IC=new lt(Cm);function Ks(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Le=Be(bd()),fi=Be(la());function Ys(r,e,t){return t={path:e,exports:{},require:function(i,n){return $_(i,n??t.path)}},r(t,t.exports),t.exports}function $_(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Cd=gb;function gb(r,e){if(!r)throw new Error(e||"Assertion failed")}gb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Mr=Ys(function(r,e){"use strict";var t=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var f=[];if(typeof o!="string"){for(var u=0;u>8,S=g&255;y?f.push(y,S):f.push(S)}return f}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var a="",f=0;f(S>>1)-1?R=(S>>1)-O:R=O,I.isubn(R)):R=0,y[A]=R,I.iushrn(1)}return y}t.getNAF=i;function n(f,u){var g=[[],[]];f=f.clone(),u=u.clone();for(var y=0,S=0,I;f.cmpn(-y)>0||u.cmpn(-S)>0;){var A=f.andln(3)+y&3,R=u.andln(3)+S&3;A===3&&(A=-1),R===3&&(R=-1);var O;A&1?(I=f.andln(7)+y&7,(I===3||I===5)&&R===2?O=-A:O=A):O=0,g[0].push(O);var N;R&1?(I=u.andln(7)+S&7,(I===3||I===5)&&A===2?N=-R:N=R):N=0,g[1].push(N),2*y===O+1&&(y=1-y),2*S===N+1&&(S=1-S),f.iushrn(1),u.iushrn(1)}return g}t.getJSF=n;function s(f,u,g){var y="_"+u;f.prototype[u]=function(){return this[y]!==void 0?this[y]:this[y]=g.call(this)}}t.cachedProperty=s;function o(f){return typeof f=="string"?t.toArray(f,"hex"):f}t.parseBytes=o;function a(f){return new Le.default(f,"hex","le")}t.intFromLE=a}),mf=Yt.getNAF,H_=Yt.getJSF,bf=Yt.assert;function tn(r,e){this.type=r,this.p=new Le.default(e.p,16),this.red=e.prime?Le.default.red(e.prime):Le.default.mont(this.p),this.zero=new Le.default(0).toRed(this.red),this.one=new Le.default(1).toRed(this.red),this.two=new Le.default(2).toRed(this.red),this.n=e.n&&new Le.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Xn=tn;tn.prototype.point=function(){throw new Error("Not implemented")};tn.prototype.validate=function(){throw new Error("Not implemented")};tn.prototype._fixedNafMul=function(e,t){bf(e.precomputed);var i=e._getDoubles(),n=mf(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];bf(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};tn.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,R=g;if(o[A]!==1||o[R]!==1){f[A]=mf(i[A],o[A],this._bitLength),f[R]=mf(i[R],o[R],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[R].length,u);continue}var O=[t[A],null,null,t[R]];t[A].y.cmp(t[R].y)===0?(O[1]=t[A].add(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg())):t[A].y.cmp(t[R].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].add(t[R].neg())):(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=H_(i[A],i[R]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[R]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var D=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};hr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};dr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};dr.prototype.pointFromX=function(e,t){e=new Le.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};dr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};dr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};pt.prototype.isInfinity=function(){return this.inf};pt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};pt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};pt.prototype.getX=function(){return this.x.fromRed()};pt.prototype.getY=function(){return this.y.fromRed()};pt.prototype.mul=function(e){return e=new Le.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};pt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};pt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};pt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};pt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};pt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function _t(r,e,t,i){Xn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Le.default(0)):(this.x=new Le.default(e,16),this.y=new Le.default(t,16),this.z=new Le.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Dd(_t,Xn.BasePoint);dr.prototype.jpoint=function(e,t,i){return new _t(this,e,t,i)};_t.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};_t.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};_t.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),R=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,R)};_t.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};_t.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};_t.prototype.inspect=function(){return this.isInfinity()?"":""};_t.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var pf=Ys(function(r,e){"use strict";var t=e;t.base=Xn,t.short=W_,t.mont=null,t.edwards=null}),gf=Ys(function(r,e){"use strict";var t=e,i=Yt.assert;function n(a){a.type==="short"?this.curve=new pf.short(a):a.type==="edwards"?this.curve=new pf.edwards(a):this.curve=new pf.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(a,f){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var u=new n(f);return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,value:u}),u}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:fi.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:fi.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:fi.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:fi.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:fi.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:fi.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:fi.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:fi.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function en(r){if(!(this instanceof en))return new en(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Mr.toArray(r.entropy,r.entropyEnc||"hex"),t=Mr.toArray(r.nonce,r.nonceEnc||"hex"),i=Mr.toArray(r.pers,r.persEnc||"hex");Cd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var mb=en;en.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};en.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Mr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var J_=Yt.assert;function vf(r,e){if(r instanceof vf)return r;this._importDER(r,e)||(J_(r.r&&r.s,"Signature without r or s"),this.r=new Le.default(r.r,16),this.s=new Le.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var yf=vf;function Y_(){this.place=0}function Rd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function pb(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}vf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=pb(t),i=pb(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Pd(n,t.length),n=n.concat(t),n.push(2),Pd(n,i.length);var s=n.concat(i),o=[48];return Pd(o,s.length),o=o.concat(s),Yt.encode(o,e)};var X_=function(){throw new Error("unsupported")},bb=Yt.assert;function ur(r){if(!(this instanceof ur))return new ur(r);typeof r=="string"&&(bb(Object.prototype.hasOwnProperty.call(gf,r),"Unknown curve "+r),r=gf[r]),r instanceof gf.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var Q_=ur;ur.prototype.keyPair=function(e){return new Od(this,e)};ur.prototype.keyFromPrivate=function(e,t){return Od.fromPrivate(this,e,t)};ur.prototype.keyFromPublic=function(e,t){return Od.fromPublic(this,e,t)};ur.prototype.genKeyPair=function(e){e||(e={});for(var t=new mb({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||X_(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Le.default(2));;){var s=new Le.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};ur.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};ur.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Le.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new mb({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Le.default(1)),g=0;;g++){var y=n.k?n.k(g):new Le.default(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var R=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(R=R.umod(this.n),R.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),O^=1),new yf({r:A,s:R,recoveryParam:O})}}}}}};ur.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Le.default(e,16)),i=this.keyFromPublic(i,n),t=new yf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};ur.prototype.recoverPubKey=function(r,e,t,i){bb((3&t)===t,"The recovery param is more than two bits"),e=new yf(e,i);var n=this.n,s=new Le.default(r),o=e.r,a=e.s,f=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};ur.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new yf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var Z_=Ys(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=Yt,t.rand=function(){throw new Error("unsupported")},t.curve=pf,t.curves=gf,t.ec=Q_,t.eddsa=null}),vb=Z_.ec;var yb="signing-key/5.7.0";var Fd=new lt(yb),Ld=null;function ui(){return Ld||(Ld=new vb("secp256k1")),Ld}var Ud=class{constructor(e){Ks(this,"curve","secp256k1"),Ks(this,"privateKey",Rt(e)),cf(this.privateKey)!==32&&Fd.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=ui().keyFromPrivate(Qe(this.privateKey));Ks(this,"publicKey","0x"+t.getPublic(!1,"hex")),Ks(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Ks(this,"_isSigningKey",!0)}_addPoint(e){let t=ui().keyFromPublic(Qe(this.publicKey)),i=ui().keyFromPublic(Qe(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=ui().keyFromPrivate(Qe(this.privateKey)),i=Qe(e);i.length!==32&&Fd.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return uf({recoveryParam:n.recoveryParam,r:Xi("0x"+n.r.toString(16),32),s:Xi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=ui().keyFromPrivate(Qe(this.privateKey)),i=ui().keyFromPublic(Qe(qd(e)));return Xi("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function wb(r,e){let t=uf(e),i={r:Qe(t.r),s:Qe(t.s)};return"0x"+ui().recoverPubKey(Qe(r),i,t.recoveryParam).encode("hex",!1)}function qd(r,e){let t=Qe(r);if(t.length===32){let i=new Ud(t);return e?"0x"+ui().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Rt(t):"0x"+ui().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+ui().keyFromPublic(t).getPublic(!0,"hex"):Rt(t)}return Fd.throwArgumentError("invalid public or private key","key","[REDACTED]")}var xb="transactions/5.7.0";var sD=new lt(xb),_b;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(_b||(_b={}));function eE(r){let e=qd(r);return Nm(ff(js(ff(e,1)),12))}function Eb(r,e){return eE(wb(Qe(r),e))}var fl=Be(Nb()),Yv=Be(Ub()),Ea=Be(Yo()),no=Be(Bb()),jf=Be(Kb());var Xv=Be(Fv());var Uv={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var i7=":";function Sa(r){let[e,t]=r.split(i7);return{namespace:e,reference:t}}function Qv(r,e){return r.includes(":")?[r]:e.chains||[]}var n7=Object.defineProperty,qv=Object.getOwnPropertySymbols,s7=Object.prototype.hasOwnProperty,o7=Object.prototype.propertyIsEnumerable,Bv=(r,e,t)=>e in r?n7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,kv=(r,e)=>{for(var t in e||(e={}))s7.call(e,t)&&Bv(r,t,e[t]);if(qv)for(var t of qv(e))o7.call(e,t)&&Bv(r,t,e[t]);return r},a7="ReactNative",Vt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var c7="js";function Ia(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ss(){return!(0,Ui.getDocument)()&&!!(0,Ui.getNavigator)()&&navigator.product===a7}function so(){return!Ia()&&!!(0,Ui.getNavigator)()&&!!(0,Ui.getDocument)()}function Aa(){return ss()?Vt.reactNative:Ia()?Vt.node:so()?Vt.browser:Vt.unknown}function Zv(){var r;try{return ss()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function f7(r,e){let t=io.parse(r);return t=kv(kv({},t),e),r=io.stringify(t),r}function oo(){return(0,Jv.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function u7(){if(Aa()===Vt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){let{OS:t,Version:i}=global.Platform;return[t,i].join("-")}let r=z1();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function h7(){var r;let e=Aa();return e===Vt.browser?[e,((r=(0,Ui.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function ul(r,e,t){let i=u7(),n=h7();return[[r,e].join("-"),[c7,t].join("-"),i,n].join("/")}function ey({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a}){let f=t.split("?"),u=ul(r,e,i),g={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},y=f7(f[1]||"",g);return f[0]+"?"+y}function is(r,e){return r.filter(t=>e.includes(t)).length===r.length}function hl(r){return Object.fromEntries(r.entries())}function dl(r){return new Map(Object.entries(r))}function qi(r=Fi.FIVE_MINUTES,e){let t=(0,Fi.toMiliseconds)(r||Fi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,a)=>{s=setTimeout(()=>{a(new Error(e))},t),i=o,n=a})}}function os(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function ty(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function ry(r){return ty("topic",r)}function iy(r){return ty("id",r)}function Kf(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ut(r,e){return(0,Fi.fromMiliseconds)((e||Date.now())+(0,Fi.toMiliseconds)(r))}function gi(r){return Date.now()>=(0,Fi.toMiliseconds)(r)}function Fe(r,e){return`${r}${e?`:${e}`:""}`}function d7(r=[],e=[]){return[...new Set([...r,...e])]}async function ny({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=l7(s,r,e),a=Aa();if(a===Vt.browser){if(!((i=(0,Ui.getDocument)())!=null&&i.hasFocus()))return;o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,p7()?"_blank":"_self","noreferrer noopener")}else a===Vt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function l7(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${g7(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function sy(r,e){let t="";try{if(so()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function ll(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function pl(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Ta(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function p7(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function g7(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function oy(r){return Buffer.from(r,"base64").toString("utf-8")}var m7="https://rpc.walletconnect.org/v1";async function b7(r,e,t,i,n,s){switch(t.t){case"eip191":return v7(r,e,t.s);case"eip1271":return await y7(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function v7(r,e,t){return Eb(hf(e),t).toLowerCase()===r.toLowerCase()}async function y7(r,e,t,i,n,s){let o=Sa(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let a="0x1626ba7e",f="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",g=t.substring(2),y=hf(e).substring(2),S=a+y+f+u+g,I=await fetch(`${s||m7}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:w7(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:A}=await I.json();return A?A.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function w7(){return Date.now()+Math.floor(Math.random()*1e3)}var x7=Object.defineProperty,_7=Object.defineProperties,E7=Object.getOwnPropertyDescriptors,zv=Object.getOwnPropertySymbols,S7=Object.prototype.hasOwnProperty,I7=Object.prototype.propertyIsEnumerable,jv=(r,e,t)=>e in r?x7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,A7=(r,e)=>{for(var t in e||(e={}))S7.call(e,t)&&jv(r,t,e[t]);if(zv)for(var t of zv(e))I7.call(e,t)&&jv(r,t,e[t]);return r},T7=(r,e)=>_7(r,E7(e)),M7="did:pkh:",gl=r=>r?.split(":"),R7=r=>{let e=r&&gl(r);if(e)return r.includes(M7)?e[3]:e[1]},Vf=r=>{let e=r&&gl(r);if(e)return e[2]+":"+e[3]},Ma=r=>{let e=r&&gl(r);if(e)return e.pop()};async function ml(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=bl(n,n.iss),o=Ma(n.iss);return await b7(o,s,i,Vf(n.iss),t)}var bl=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ma(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,a=`Chain ID: ${R7(e)}`,f=`Nonce: ${r.nonce}`,u=`Issued At: ${r.iat}`,g=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(R=>` +- ${R}`).join("")}`:void 0,A=Ra(r.resources);if(A){let R=_a(A);n=F7(n,R)}return[t,i,"",n,"",s,o,a,f,u,g,y,S,I].filter(R=>R!=null).join(` +`)};function P7(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function N7(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function ns(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function C7(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:D7(e,t,i)}}}function D7(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function ay(r){return ns(r),`urn:recap:${P7(r).replace(/=/g,"")}`}function _a(r){let e=N7(r.replace("urn:recap:",""));return ns(e),e}function cy(r,e,t){let i=C7(r,e,t);return ay(i)}function O7(r){return r&&r.includes("urn:recap:")}function fy(r,e){let t=_a(r),i=_a(e),n=L7(t,i);return ay(n)}function L7(r,e){ns(r),ns(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,f)=>a.localeCompare(f)).forEach(a=>{var f,u;i.att[n]=T7(A7({},i.att[n]),{[a]:((f=r.att[n])==null?void 0:f[a])||((u=e.att[n])==null?void 0:u[a])})})}),i}function F7(r="",e){ns(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(a=>{let f=Object.keys(e.att[a]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));f.sort((y,S)=>y.action.localeCompare(S.action));let u={};f.forEach(y=>{u[y.ability]||(u[y.ability]=[]),u[y.ability].push(y.action)});let g=Object.keys(u).map(y=>(n++,`(${n}) '${y}': '${u[y].join("', '")}' for '${a}'.`));i.push(g.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function vl(r){var e;let t=_a(r);ns(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function yl(r){let e=_a(r);ns(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Ra(r){if(!r)return;let e=r?.[r.length-1];return O7(e)?e:void 0}var uy="base10",Dt="base16",mi="base64pad",ao="base64url",Pa="utf8",hy=0,Pr=1,co=2,U7=0,Kv=1,xa=12,wl=32;function dy(){let r=jf.generateKeyPair();return{privateKey:rt(r.secretKey,Dt),publicKey:rt(r.publicKey,Dt)}}function $f(){let r=(0,Ea.randomBytes)(wl);return rt(r,Dt)}function ly(r,e){let t=jf.sharedKey(at(r,Dt),at(e,Dt),!0),i=new Yv.HKDF(no.SHA256,t).expand(wl);return rt(i,Dt)}function fo(r){let e=(0,no.hash)(at(r,Dt));return rt(e,Dt)}function Nr(r){let e=(0,no.hash)(at(r,Pa));return rt(e,Dt)}function py(r){return at(`${r}`,uy)}function fn(r){return Number(rt(r,uy))}function gy(r){let e=py(typeof r.type<"u"?r.type:hy);if(fn(e)===Pr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?at(r.senderPublicKey,Dt):void 0,i=typeof r.iv<"u"?at(r.iv,Dt):(0,Ea.randomBytes)(xa),n=new fl.ChaCha20Poly1305(at(r.symKey,Dt)).seal(i,at(r.message,Pa));return yy({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function my(r,e){let t=py(co),i=(0,Ea.randomBytes)(xa),n=at(r,Pa);return yy({type:t,sealed:n,iv:i,encoding:e})}function by(r){let e=new fl.ChaCha20Poly1305(at(r.symKey,Dt)),{sealed:t,iv:i}=uo({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return rt(n,Pa)}function vy(r,e){let{sealed:t}=uo({encoded:r,encoding:e});return rt(t,Pa)}function yy(r){let{encoding:e=mi}=r;if(fn(r.type)===co)return rt(Hn([r.type,r.sealed]),e);if(fn(r.type)===Pr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return rt(Hn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return rt(Hn([r.type,r.iv,r.sealed]),e)}function uo(r){let{encoded:e,encoding:t=mi}=r,i=at(e,t),n=i.slice(U7,Kv),s=Kv;if(fn(n)===Pr){let u=s+wl,g=u+xa,y=i.slice(s,u),S=i.slice(u,g),I=i.slice(g);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(fn(n)===co){let u=i.slice(s),g=(0,Ea.randomBytes)(xa);return{type:n,sealed:u,iv:g}}let o=s+xa,a=i.slice(s,o),f=i.slice(o);return{type:n,sealed:f,iv:a}}function wy(r,e){let t=uo({encoded:r,encoding:e?.encoding});return xl({type:fn(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?rt(t.senderPublicKey,Dt):void 0,receiverPublicKey:e?.receiverPublicKey})}function xl(r){let e=r?.type||hy;if(e===Pr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function _l(r){return r.type===Pr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function El(r){return r.type===co}function q7(r){return new Xv.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function B7(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function k7(r){return Buffer.from(B7(r),"base64")}function xy(r,e){let[t,i,n]=r.split("."),s=k7(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),f=`${t}.${i}`,u=new no.SHA256().update(Buffer.from(f)).digest(),g=q7(e),y=Buffer.from(u).toString("hex");if(!g.verify(y,{r:o,s:a}))throw new Error("Invalid signature");return Bs(r).payload}var z7="irn";function Hf(r){return r?.relay||{protocol:z7}}function ho(r){let e=Uv[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var j7=Object.defineProperty,K7=Object.defineProperties,V7=Object.getOwnPropertyDescriptors,Vv=Object.getOwnPropertySymbols,$7=Object.prototype.hasOwnProperty,H7=Object.prototype.propertyIsEnumerable,$v=(r,e,t)=>e in r?j7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Hv=(r,e)=>{for(var t in e||(e={}))$7.call(e,t)&&$v(r,t,e[t]);if(Vv)for(var t of Vv(e))H7.call(e,t)&&$v(r,t,e[t]);return r},G7=(r,e)=>K7(r,V7(e));function W7(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Sl(r){if(!r.includes("wc:")){let f=oy(r);f!=null&&f.includes("wc:")&&(r=f)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=io.parse(s),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:J7(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:W7(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function J7(r){return r.startsWith("//")?r.substring(2):r}function Y7(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function Il(r){return`${r.protocol}:${r.topic}@${r.version}?`+io.stringify(Hv(G7(Hv({symKey:r.symKey},Y7(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Na(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function lo(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function X7(r){let e=[];return Object.values(r).forEach(t=>{e.push(...lo(t.accounts))}),e}function Q7(r,e){let t=[];return Object.values(r).forEach(i=>{lo(i.accounts).includes(e)&&t.push(...i.methods)}),t}function Z7(r,e){let t=[];return Object.values(r).forEach(i=>{lo(i.accounts).includes(e)&&t.push(...i.events)}),t}function e9(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Al(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=e9(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=d7(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var t9={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},r9={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Q(r,e){let{message:t,code:i}=r9[r];return{message:e?`${t} ${e}`:t,code:i}}function ke(r,e){let{message:t,code:i}=t9[r];return{message:e?`${t} ${e}`:t,code:i}}function hn(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function Ca(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function St(r){return typeof r>"u"}function et(r,e){return e&&St(r)?!0:typeof r=="string"&&!!r.trim().length}function Tl(r,e){return e&&St(r)?!0:typeof r=="number"&&!isNaN(r)}function _y(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return is(n,i)?(i.forEach(o=>{let{accounts:a,methods:f,events:u}=r.namespaces[o],g=lo(a),y=t[o];(!is(Qv(o,y),g)||!is(y.methods,f)||!is(y.events,u))&&(s=!1)}),s):!1}function zf(r){return et(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function i9(r){if(et(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&zf(t)}}return!1}function Ey(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(et(r,!1)){if(e(r))return!0;let t=oy(r);return e(t)}}catch{}return!1}function Sy(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function Iy(r){return r?.topic}function Ay(r,e){let t=null;return et(r?.publicKey,!1)||(t=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function Gv(r){let e=!0;return hn(r)?r.length&&(e=r.every(t=>et(t,!1))):e=!1,e}function n9(r,e,t){let i=null;return hn(e)&&e.length?e.forEach(n=>{i||zf(n)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):zf(r)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function s9(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=n9(n,Qv(n,s),`${e} ${t}`);o&&(i=o)}),i}function o9(r,e){let t=null;return hn(r)?r.forEach(i=>{t||i9(i)||(t=ke("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=ke("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function a9(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=o9(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function c9(r,e){let t=null;return Gv(r?.methods)?Gv(r?.events)||(t=ke("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=ke("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Ty(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=c9(i,`${e}, namespace`);n&&(t=n)}),t}function My(r,e,t){let i=null;if(r&&Ca(r)){let n=Ty(r,e);n&&(i=n);let s=s9(r,e,t);s&&(i=s)}else i=Q("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Gf(r,e){let t=null;if(r&&Ca(r)){let i=Ty(r,e);i&&(t=i);let n=a9(r,e);n&&(t=n)}else t=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ml(r){return et(r.protocol,!0)}function Ry(r,e){let t=!1;return e&&!r?t=!0:r&&hn(r)&&r.length&&r.forEach(i=>{t=Ml(i)}),t}function Py(r){return typeof r=="number"}function Ot(r){return typeof r<"u"&&typeof r!==null}function Ny(r){return!(!r||typeof r!="object"||!r.code||!Tl(r.code,!1)||!r.message||!et(r.message,!1))}function Cy(r){return!(St(r)||!et(r.method,!1))}function Dy(r){return!(St(r)||St(r.result)&&St(r.error)||!Tl(r.id,!1)||!et(r.jsonrpc,!1))}function Oy(r){return!(St(r)||!et(r.name,!1))}function Rl(r,e){return!(!zf(e)||!X7(r).includes(e))}function Ly(r,e,t){return et(t,!1)?Q7(r,e).includes(t):!1}function Fy(r,e,t){return et(t,!1)?Z7(r,e).includes(t):!1}function Pl(r,e,t){let i=null,n=f9(r),s=u9(e),o=Object.keys(n),a=Object.keys(s),f=Wv(Object.keys(r)),u=Wv(Object.keys(e)),g=f.filter(y=>!u.includes(y));return g.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. Required: ${g.toString()} - Received: ${Object.keys(e).toString()}`)),Zn(o,a)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. + Received: ${Object.keys(e).toString()}`)),is(o,a)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. Required: ${o.toString()} - Approved: ${a.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=ao(e[y].accounts);S.includes(y)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} + Approved: ${a.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=lo(e[y].accounts);S.includes(y)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} Required: ${y} - Approved: ${S.toString()}`))}),o.forEach(y=>{i||(Zn(n[y].methods,s[y].methods)?Zn(n[y].events,s[y].events)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function i7(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function zv(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function n7(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:ao(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Ry(r,e){return _l(r,!1)&&r<=e.max&&r>=e.min}function Al(){let r=xa();return new Promise(e=>{switch(r){case Vt.browser:e(s7());break;case Vt.reactNative:e(o7());break;case Vt.node:e(a7());break;default:e(!0)}})}function s7(){return eo()&&navigator?.onLine}async function o7(){return ts()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function a7(){return!0}function Ny(r){switch(xa()){case Vt.browser:c7(r);break;case Vt.reactNative:f7(r);break;case Vt.node:break}}function c7(r){!ts()&&eo()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function f7(r){ts()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>r(e?.isConnected))}var il={},on=class{static get(e){return il[e]}static set(e,t){il[e]=t}static delete(e){delete il[e]}};var Gy=Be(Fn());var Ft={};qt(Ft,{DEFAULT_ERROR:()=>Pa,IBaseJsonRpcProvider:()=>Xf,IEvents:()=>Ra,IJsonRpcConnection:()=>Nl,IJsonRpcProvider:()=>Na,INTERNAL_ERROR:()=>Kf,INVALID_PARAMS:()=>Ly,INVALID_REQUEST:()=>Cy,METHOD_NOT_FOUND:()=>Oy,PARSE_ERROR:()=>Dy,RESERVED_ERROR_CODES:()=>Ml,SERVER_ERROR:()=>Ta,SERVER_ERROR_CODE_RANGE:()=>Vf,STANDARD_ERROR_MAP:()=>cn,formatErrorMessage:()=>$y,formatJsonRpcError:()=>is,formatJsonRpcRequest:()=>Cr,formatJsonRpcResult:()=>co,getBigIntRpcId:()=>Dr,getError:()=>Hf,getErrorByCode:()=>Gf,isHttpUrl:()=>w7,isJsonRpcError:()=>Lt,isJsonRpcPayload:()=>Cl,isJsonRpcRequest:()=>fo,isJsonRpcResponse:()=>hn,isJsonRpcResult:()=>Xt,isJsonRpcValidationInvalid:()=>x7,isLocalhostUrl:()=>Dl,isNodeJs:()=>Vy,isReservedErrorCode:()=>$f,isServerErrorCode:()=>u7,isValidDefaultRoute:()=>Jf,isValidErrorCode:()=>Fy,isValidLeadingWildcardRoute:()=>g7,isValidRoute:()=>p7,isValidTrailingWildcardRoute:()=>m7,isValidWildcardRoute:()=>Yf,isWsUrl:()=>Qf,parseConnectionError:()=>Tl,payloadId:()=>gi,validateJsonRpcError:()=>h7});var Dy="PARSE_ERROR",Cy="INVALID_REQUEST",Oy="METHOD_NOT_FOUND",Ly="INVALID_PARAMS",Kf="INTERNAL_ERROR",Ta="SERVER_ERROR",Ml=[-32700,-32600,-32601,-32602,-32603],Vf=[-32e3,-32099],cn={[Dy]:{code:-32700,message:"Parse error"},[Cy]:{code:-32600,message:"Invalid Request"},[Oy]:{code:-32601,message:"Method not found"},[Ly]:{code:-32602,message:"Invalid params"},[Kf]:{code:-32603,message:"Internal error"},[Ta]:{code:-32e3,message:"Server error"}},Pa=Ta;function u7(r){return r<=Vf[0]&&r>=Vf[1]}function $f(r){return Ml.includes(r)}function Fy(r){return typeof r=="number"}function Hf(r){return Object.keys(cn).includes(r)?cn[r]:cn[Pa]}function Gf(r){let e=Object.values(cn).find(t=>t.code===r);return e||cn[Pa]}function h7(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!Fy(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if($f(r.error.code)){let e=Gf(r.error.code);if(e.message!==cn[Pa].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Tl(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var kt={};qt(kt,{isNodeJs:()=>Vy});var Ky=Be(Rl());Ht(kt,Be(Rl()));var Vy=Ky.isNode;Ht(Ft,kt);function gi(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function Dr(r=6){return BigInt(gi(r))}function Cr(r,e,t){return{id:t||gi(),jsonrpc:"2.0",method:r,params:e}}function co(r,e){return{id:r,jsonrpc:"2.0",result:e}}function is(r,e,t){return{id:r,jsonrpc:"2.0",error:$y(e,t)}}function $y(r,e){return typeof r>"u"?Hf(Kf):(typeof r=="string"&&(r=Object.assign(Object.assign({},Hf(Ta)),{message:r})),typeof e<"u"&&(r.data=e),$f(r.code)&&(r=Gf(r.code)),r)}function p7(r){return r.includes("*")?Yf(r):!/\W/g.test(r)}function Jf(r){return r==="*"}function Yf(r){return Jf(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function g7(r){return!Jf(r)&&Yf(r)&&!r.split("*")[0].trim()}function m7(r){return!Jf(r)&&Yf(r)&&!r.split("*")[1].trim()}var Ra=class{},Nl=class extends Ra{constructor(e){super()}},Xf=class extends Ra{constructor(){super()}},Na=class extends Xf{constructor(e){super()}};var b7="^https?:",v7="^wss?:";function y7(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Hy(r,e){let t=y7(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function w7(r){return Hy(r,b7)}function Qf(r){return Hy(r,v7)}function Dl(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function Cl(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function fo(r){return Cl(r)&&"method"in r}function hn(r){return Cl(r)&&(Xt(r)||Lt(r))}function Xt(r){return"result"in r}function Lt(r){return"error"in r}function x7(r){return"error"in r&&r.valid===!1}var Zf=class extends Na{constructor(e){super(e),this.events=new Gy.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Cr(e.method,e.params||[],e.id||Dr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Lt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),hn(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Qy=Be(Fn());var _7=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Jy(),E7=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Yy=r=>r.split("?")[0],Xy=10,S7=_7(),eu=class{constructor(e){if(this.url=e,this.events=new Qy.EventEmitter,this.registering=!1,!Qf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(ar(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Qf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Ft.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Dl(e)},o=new S7(e,[],s);E7()?o.onerror=a=>{let f=a;i(this.emitError(f.error))}:o.on("error",a=>{i(this.emitError(a))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?Qr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=is(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Tl(e,Yy(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Xy&&this.events.setMaxListeners(Xy)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Yy(this.url)}`));return this.events.emit("register_error",t),t}};var t2=Be(Cw()),r2=Be(Qc()),i2="wc",n2=2,m0="core",yi=`${i2}@2:${m0}:`,tI={name:m0,logger:"error"},rI={database:":memory:"},iI="crypto",Ow="client_ed25519_seed",nI=ne.ONE_DAY,sI="keychain",oI="0.3",aI="messages",cI="0.3",fI=ne.SIX_HOURS,uI="publisher",b0="irn",hI="error",s2="wss://relay.walletconnect.org",dI="relayer",Ut={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lI="_subscription",gr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},pI=.1;var Gl="2.17.1";var We={link_mode:"link_mode",relay:"relay"},gI="0.3",mI="WALLETCONNECT_CLIENT_ID",Lw="WALLETCONNECT_LINK_MODE_APPS",bi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var bI="subscription",vI="0.3",yI=ne.FIVE_SECONDS*1e3,wI="pairing",xI="0.3";var Ua={wc_pairingDelete:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:0},res:{ttl:ne.ONE_DAY,prompt:!1,tag:0}}},pn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Or={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},_I="history",EI="0.3",SI="expirer",Qt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},II="0.3";var AI="verify-api",MI="https://verify.walletconnect.com",o2="https://verify.walletconnect.org",po=o2,TI=`${po}/v3`,PI=[MI,o2],RI="echo",NI="https://echo.walletconnect.com";var Lr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},vi={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},mr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},gn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},mn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},go={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},DI=.1,CI="event-client",OI=86400,LI="https://pulse.walletconnect.org/batch";function FI(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var C=k-O;C!==k&&B[C]===0;)C++;for(var W=f.repeat(P);C>>0,k=new Uint8Array(U);A[P];){var B=t[A.charCodeAt(P)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,P++}if(A[P]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var C=new Uint8Array(O+(U-L)),W=O;L!==U;)C[W++]=k[L++];return C}}}function I(A){var P=S(A);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var UI=FI,qI=UI,a2=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},BI=r=>new TextEncoder().encode(r),kI=r=>new TextDecoder().decode(r),Wl=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Jl=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return c2(this,e)}},Yl=class{constructor(e){this.decoders=e}or(e){return c2(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},c2=(r,e)=>new Yl({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Xl=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Wl(e,t,i),this.decoder=new Jl(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},du=({name:r,prefix:e,encode:t,decode:i})=>new Xl(r,e,t,i),ka=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=qI(t,e);return du({prefix:r,name:e,encode:i,decode:s=>a2(n(s))})},zI=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},jI=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<du({prefix:e,name:r,encode(n){return jI(n,i,t)},decode(n){return zI(n,i,t,r)}}),KI=du({prefix:"\0",name:"identity",encode:r=>kI(r),decode:r=>BI(r)}),VI=Object.freeze({__proto__:null,identity:KI}),$I=It({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),HI=Object.freeze({__proto__:null,base2:$I}),GI=It({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),WI=Object.freeze({__proto__:null,base8:GI}),JI=ka({prefix:"9",name:"base10",alphabet:"0123456789"}),YI=Object.freeze({__proto__:null,base10:JI}),XI=It({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),QI=It({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ZI=Object.freeze({__proto__:null,base16:XI,base16upper:QI}),eA=It({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tA=It({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),rA=It({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),iA=It({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nA=It({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sA=It({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),oA=It({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),aA=It({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cA=It({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),fA=Object.freeze({__proto__:null,base32:eA,base32upper:tA,base32pad:rA,base32padupper:iA,base32hex:nA,base32hexupper:sA,base32hexpad:oA,base32hexpadupper:aA,base32z:cA}),uA=ka({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hA=ka({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),dA=Object.freeze({__proto__:null,base36:uA,base36upper:hA}),lA=ka({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pA=ka({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),gA=Object.freeze({__proto__:null,base58btc:lA,base58flickr:pA}),mA=It({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bA=It({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vA=It({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yA=It({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),wA=Object.freeze({__proto__:null,base64:mA,base64pad:bA,base64url:vA,base64urlpad:yA}),f2=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),xA=f2.reduce((r,e,t)=>(r[t]=e,r),[]),_A=f2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function EA(r){return r.reduce((e,t)=>(e+=xA[t],e),"")}function SA(r){let e=[];for(let t of r){let i=_A[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var IA=du({prefix:"\u{1F680}",name:"base256emoji",encode:EA,decode:SA}),AA=Object.freeze({__proto__:null,base256emoji:IA}),MA=u2,Fw=128,TA=127,PA=~TA,RA=Math.pow(2,31);function u2(r,e,t){e=e||[],t=t||0;for(var i=t;r>=RA;)e[t++]=r&255|Fw,r/=128;for(;r&PA;)e[t++]=r&255|Fw,r>>>=7;return e[t]=r|0,u2.bytes=t-i+1,e}var NA=Ql,DA=128,Uw=127;function Ql(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw Ql.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&Uw)<=DA);return Ql.bytes=s-i,t}var CA=Math.pow(2,7),OA=Math.pow(2,14),LA=Math.pow(2,21),FA=Math.pow(2,28),UA=Math.pow(2,35),qA=Math.pow(2,42),BA=Math.pow(2,49),kA=Math.pow(2,56),zA=Math.pow(2,63),jA=function(r){return r(h2.encode(r,e,t),e),Bw=r=>h2.encodingLength(r),Zl=(r,e)=>{let t=e.byteLength,i=Bw(r),n=i+Bw(t),s=new Uint8Array(n+t);return qw(r,s,0),qw(t,s,i),s.set(e,n),new e0(r,t,e,s)},e0=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},d2=({name:r,code:e,encode:t})=>new t0(r,e,t),t0=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Zl(this.code,t):t.then(i=>Zl(this.code,i))}else throw Error("Unknown type, must be binary type")}},l2=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),VA=d2({name:"sha2-256",code:18,encode:l2("SHA-256")}),$A=d2({name:"sha2-512",code:19,encode:l2("SHA-512")}),HA=Object.freeze({__proto__:null,sha256:VA,sha512:$A}),p2=0,GA="identity",g2=a2,WA=r=>Zl(p2,g2(r)),JA={code:p2,name:GA,encode:g2,digest:WA},YA=Object.freeze({__proto__:null,identity:JA});new TextEncoder,new TextDecoder;var kw={...VI,...HI,...WI,...YI,...ZI,...fA,...dA,...gA,...wA,...AA};({...HA,...YA});function XA(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function m2(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var zw=m2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$l=m2("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=XA(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=wt(t,this.name)}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ol(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?al(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},i0=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=iI,this.randomSessionIdentifier=kf(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=rd(n);return Xc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=sy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=rd(s),a=this.randomSessionIdentifier;return await P1(a,n,nI,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let a=this.getPrivateKey(n),f=oy(a,s);return this.setSymKey(f,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||no(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let a=ml(o),f=ar(s);if(vl(a))return fy(f,o?.encoding);if(bl(a)){let S=a.senderPublicKey,I=a.receiverPublicKey;n=await this.generateSharedKey(S,I)}let u=this.getSymKey(n),{type:g,senderPublicKey:y}=a;return cy({type:g,symKey:u,message:f,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let a=ly(s,o);if(vl(a)){let f=hy(s,o?.encoding);return Qr(f)}if(bl(a)){let f=a.receiverPublicKey,u=a.senderPublicKey;n=await this.generateSharedKey(f,u)}try{let f=this.getSymKey(n),u=uy({symKey:f,encoded:s,encoding:o?.encoding});return Qr(u)}catch(f){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(f)}},this.getPayloadType=(n,s=pi)=>{let o=so({encoded:n,encoding:s});return sn(o.type)},this.getPayloadSenderPublicKey=(n,s=pi)=>{let o=so({encoded:n,encoding:s});return o.senderPublicKey?rt(o.senderPublicKey,Ct):void 0},this.core=e,this.logger=wt(t,this.name),this.keychain=i||new r0(this.core,this.logger)}get context(){return Mt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Ow)}catch{e=kf(),await this.keychain.set(Ow,e)}return ZA(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},n0=class extends Pc{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=aI,this.version=cI,this.initialized=!1,this.storagePrefix=yi,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=Nr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=Nr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=wt(e,this.name),this.core=t}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ol(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?al(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},s0=class extends Rc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Bi.EventEmitter,this.name=uI,this.queue=new Map,this.publishTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.failedPublishTimeout=(0,ne.toMiliseconds)(ne.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let a=s?.ttl||fI,f=zf(s),u=s?.prompt||!1,g=s?.tag||0,y=s?.id||Dr().toString(),S={topic:i,message:n,opts:{ttl:a,relay:f,prompt:u,tag:g,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${g}`,A=Date.now(),P,O=1;try{for(;P===void 0;){if(Date.now()-A>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:O},`publisher.publish - attempt ${O}`),P=await await rs(this.rpcPublish(i,n,a,f,u,g,y,s?.attestation).catch(N=>this.logger.warn(N)),this.publishTimeout,I),O++,P||await new Promise(N=>setTimeout(N,this.failedPublishTimeout))}this.relayer.events.emit(Ut.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw N;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=wt(t,this.name),this.registerEventListeners()}get context(){return Mt(this.logger)}rpcPublish(e,t,i,n,s,o,a,f){var u,g,y,S;let I={method:oo(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:f},id:a};return St((u=I.params)==null?void 0:u.prompt)&&((g=I.params)==null||delete g.prompt),St((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(Un.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ut.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ut.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},o0=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},eM=Object.defineProperty,tM=Object.defineProperties,rM=Object.getOwnPropertyDescriptors,jw=Object.getOwnPropertySymbols,iM=Object.prototype.hasOwnProperty,nM=Object.prototype.propertyIsEnumerable,Kw=(r,e,t)=>e in r?eM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qa=(r,e)=>{for(var t in e||(e={}))iM.call(e,t)&&Kw(r,t,e[t]);if(jw)for(var t of jw(e))nM.call(e,t)&&Kw(r,t,e[t]);return r},Hl=(r,e)=>tM(r,rM(e)),a0=class extends Cc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new o0,this.events=new Bi.EventEmitter,this.name=bI,this.version=vI,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=yi,this.subscribeTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=zf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let a=new ne.Watch;a.start(n);let f=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(f),a.stop(n),s(!0)),a.elapsed(n)>=yI&&(clearInterval(f),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=wt(t,this.name),this.clientId=""}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=zf(i);await this.rpcUnsubscribe(e,t,n);let s=ke("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===We.relay&&await this.restartToComplete();let s={method:oo(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let a=Nr(e+this.clientId);if(i?.transportType===We.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},(0,ne.toMiliseconds)(ne.ONE_SECOND)),a;let f=await rs(this.relayer.request(s).catch(u=>this.logger.warn(u)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!f&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return f?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ut.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:oo(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await rs(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:oo(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await rs(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:oo(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Hl(qa({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,qa({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,qa({},t)),this.topicMap.set(t.topic,e),this.events.emit(bi.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(bi.deleted,Hl(qa({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(bi.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);an(t)&&this.onBatchSubscribe(t.map((i,n)=>Hl(qa({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Un.pulse,async()=>{await this.checkPending()}),this.events.on(bi.created,async e=>{let t=bi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(bi.deleted,async e=>{let t=bi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},sM=Object.defineProperty,Vw=Object.getOwnPropertySymbols,oM=Object.prototype.hasOwnProperty,aM=Object.prototype.propertyIsEnumerable,$w=(r,e,t)=>e in r?sM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Hw=(r,e)=>{for(var t in e||(e={}))oM.call(e,t)&&$w(r,t,e[t]);if(Vw)for(var t of Vw(e))aM.call(e,t)&&$w(r,t,e[t]);return r},c0=class extends Nc{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Bi.EventEmitter,this.name=dI,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ne.toMiliseconds)(ne.THIRTY_SECONDS+ne.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||Dr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let a=await new Promise(async(f,u)=>{let g=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(gr.disconnect,g);let y=await o;this.provider.off(gr.disconnect,g),f(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(wa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ut.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Ut.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(gr.payload,this.onPayloadHandler),this.provider.on(gr.connect,this.onConnectHandler),this.provider.on(gr.disconnect,this.onDisconnectHandler),this.provider.on(gr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?wt(e.logger,this.name):(0,jo.default)(Vo({level:e.logger||hI})),this.messages=new n0(this.logger,e.core),this.subscriber=new a0(this,this.logger),this.publisher=new s0(this,this.logger),this.relayUrl=e?.relayUrl||s2,this.projectId=e.projectId,this.bundleId=Hv(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return Mt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:We.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",f,u=g=>{g.topic===e&&(this.subscriber.off(bi.created,u),f())};return await Promise.all([new Promise(g=>{f=g,this.subscriber.on(bi.created,u)}),new Promise(async(g,y)=>{a=await this.subscriber.subscribe(e,Hw({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||a,g()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await rs(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(gr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(gr.disconnect,n),await rs(this.provider.connect(),(0,ne.toMiliseconds)(ne.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Al())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=ut(ne.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ut.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(wa())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Zf(new eu(Gv({sdkVersion:Gl,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),fo(e)){if(!e.method.endsWith(lI))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,a={topic:i,message:n,publishedAt:s,transportType:We.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Hw({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else hn(e)&&this.events.emit(Ut.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ut.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=co(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(gr.payload,this.onPayloadHandler),this.provider.off(gr.connect,this.onConnectHandler),this.provider.off(gr.disconnect,this.onDisconnectHandler),this.provider.off(gr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Al();Ny(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ut.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ne.toMiliseconds)(pI))))}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},cM=Object.defineProperty,Gw=Object.getOwnPropertySymbols,fM=Object.prototype.hasOwnProperty,uM=Object.prototype.propertyIsEnumerable,Ww=(r,e,t)=>e in r?cM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jw=(r,e)=>{for(var t in e||(e={}))fM.call(e,t)&&Ww(r,t,e[t]);if(Gw)for(var t of Gw(e))uM.call(e,t)&&Ww(r,t,e[t]);return r},wi=class extends Dc{constructor(e,t,i,n=yi,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=gI,this.cached=[],this.initialized=!1,this.storagePrefix=yi,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!St(o)?this.map.set(this.getKey(o),o):by(o)?this.map.set(o.id,o):vy(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(f=>(0,t2.default)(a[f],o[f]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let f=Jw(Jw({},this.getData(o)),a);this.map.set(o,f),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=wt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},f0=class{constructor(e,t){this.core=e,this.logger=t,this.name=wI,this.version=xI,this.events=new Bi.default,this.initialized=!1,this.storagePrefix=yi,this.ignoredPayloadTypes=[Rr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=kf(),s=await this.core.crypto.setSymKey(n),o=ut(ne.FIVE_MINUTES),a={protocol:b0},f={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},u=wl({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(pn.create,f),this.core.expirer.set(s,o),await this.pairings.set(s,f),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Lr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:a,expiryTimestamp:f,methods:u}=yl(i.uri);n.props.properties.topic=s,n.addTrace(Lr.pairing_uri_validation_success),n.addTrace(Lr.pairing_uri_not_expired);let g;if(this.pairings.keys.includes(s)){if(g=this.pairings.get(s),n.addTrace(Lr.existing_pairing),g.active)throw n.setError(vi.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Lr.pairing_not_expired)}let y=f||ut(ne.FIVE_MINUTES),S={topic:s,relay:a,expiry:y,active:!1,methods:u};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(Lr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(pn.create,S),n.addTrace(Lr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Lr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(vi.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(I){throw n.setError(vi.subscribe_pairing_topic_failure),I}return n.addTrace(Lr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=ut(ne.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:f}=Fi();this.events.once(Fe("pairing_ping",s),({error:u})=>{u?f(u):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ke("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:a}=i,f=this.core.crypto.keychain.get(n);return wl({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:f,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{let o=Cr(n,s),a=await this.core.crypto.encode(i,o),f=Ua[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,f),o.id},this.sendResult=async(i,n,s)=>{let o=co(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=Ua[f.request.method].res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=is(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=Ua[f.request.method]?Ua[f.request.method].res:Ua.unregistered_method.res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ke("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>li(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(pn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{Xt(n)?this.events.emit(Fe("pairing_ping",s),{}):Lt(n)&&this.events.emit(Fe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(pn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let a=ke("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ke("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Ot(i)){let{message:a}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(vi.malformed_pairing_uri),new Error(a)}if(!my(i.uri)){let{message:a}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(vi.malformed_pairing_uri),new Error(a)}let o=yl(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(vi.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(vi.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0,ne.toMiliseconds)(o?.expiryTimestamp){if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!et(i,!1)){let{message:n}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(li(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=wt(t,this.name),this.pairings=new wi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Mt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ut.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===We.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{fo(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):hn(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Qt.expired,async e=>{let{topic:t}=qf(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(pn.expire,{topic:t}))})}},u0=class extends Tc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Bi.EventEmitter,this.name=_I,this.version=EI,this.cached=[],this.initialized=!1,this.storagePrefix=yi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:ut(ne.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Or.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Lt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Or.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Or.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:Cr(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Or.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Or.created,e=>{let t=Or.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.updated,e=>{let t=Or.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.deleted,e=>{let t=Or.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(Un.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,ne.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Or.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},h0=class extends Oc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Bi.EventEmitter,this.name=SI,this.version=II,this.cached=[],this.initialized=!1,this.storagePrefix=yi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Qt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Qt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Jv(e);if(typeof e=="number")return Yv(e);let{message:t}=Q("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Qt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,ne.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Qt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Un.pulse,()=>this.checkExpirations()),this.events.on(Qt.created,e=>{let t=Qt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Qt.expired,e=>{let t=Qt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Qt.deleted,e=>{let t=Qt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},d0=class extends Lc{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=AI,this.verifyUrlV3=TI,this.storagePrefix=yi,this.version=n2,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ne.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!eo()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:a}=n,f=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{let u=(0,r2.getDocument)(),g=this.startAbortTimer(ne.ONE_SECOND*5),y=await new Promise((S,I)=>{let A=()=>{window.removeEventListener("message",O),u.body.removeChild(P),I("attestation aborted")};this.abortController.signal.addEventListener("abort",A);let P=u.createElement("iframe");P.src=f,P.style.display="none",P.addEventListener("error",A,{signal:this.abortController.signal});let O=N=>{if(N.data&&typeof N.data=="string")try{let U=JSON.parse(N.data);if(U.type==="verify_attestation"){if(Os(U.attestation).payload.id!==o)return;clearInterval(g),u.body.removeChild(P),this.abortController.signal.removeEventListener("abort",A),window.removeEventListener("message",O),S(U.attestation===null?"":U.attestation)}}catch(U){this.logger.warn(U)}};u.body.appendChild(P),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Os(s).payload.id!==a)return;let u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;let f=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,f)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(ne.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=n=>{let s=n||po;return PI.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${po}`),s=po),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(ne.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=py(n,s.publicKey),a={hasExpired:(0,ne.toMiliseconds)(o.exp)this.abortController.abort(),(0,ne.toMiliseconds)(e))}},l0=class extends Fc{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=RI,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,f=`${NI}/${this.projectId}/clients`;await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})},this.logger=wt(t,this.context)}},hM=Object.defineProperty,Yw=Object.getOwnPropertySymbols,dM=Object.prototype.hasOwnProperty,lM=Object.prototype.propertyIsEnumerable,Xw=(r,e,t)=>e in r?hM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ba=(r,e)=>{for(var t in e||(e={}))dM.call(e,t)&&Xw(r,t,e[t]);if(Yw)for(var t of Yw(e))lM.call(e,t)&&Xw(r,t,e[t]);return r},p0=class extends Uc{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=CI,this.storagePrefix=yi,this.storageVersion=DI,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!_a())try{let n={eventId:fl(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:sl(this.core.relayer.protocol,this.core.relayer.version,Gl)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:a,trace:f}}=n,u=fl(),g=this.core.projectId||"",y=Date.now(),S=Ba({eventId:u,timestamp:y,props:{event:s,type:o,properties:{topic:a,trace:f}},bundleId:g,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let a=Array.from(this.events.values()).find(f=>f.props.properties.topic===o);if(a)return Ba(Ba({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Un.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,ne.fromMiliseconds)(Date.now())-(0,ne.fromMiliseconds)(n.timestamp)>OI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Ba(Ba({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${LI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Gl}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>to().url,this.logger=wt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},pM=Object.defineProperty,Qw=Object.getOwnPropertySymbols,gM=Object.prototype.hasOwnProperty,mM=Object.prototype.propertyIsEnumerable,Zw=(r,e,t)=>e in r?pM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,e2=(r,e)=>{for(var t in e||(e={}))gM.call(e,t)&&Zw(r,t,e[t]);if(Qw)for(var t of Qw(e))mM.call(e,t)&&Zw(r,t,e[t]);return r},g0=class r extends Mc{constructor(e){var t;super(e),this.protocol=i2,this.version=n2,this.name=m0,this.events=new Bi.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:f})=>{if(!o||!a)return;let u={topic:o,message:a,publishedAt:Date.now(),transportType:We.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:f})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||s2,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Vo({level:typeof e?.logger=="string"&&e.logger?e.logger:tI.logger}),{logger:n,chunkLoggerController:s}=yg({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=wt(n,this.name),this.heartbeat=new bc,this.crypto=new i0(this,this.logger,e?.keychain),this.history=new u0(this,this.logger),this.expirer=new h0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new wc(e2(e2({},rI),e?.storageOptions)),this.relayer=new c0({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new f0(this,this.logger),this.verify=new d0(this,this.logger,this.storage),this.echoClient=new l0(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new p0(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(mI,i),t}get context(){return Mt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Lw,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Lw)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},b2=g0;var gu=Be(Fn()),qe=Be(_s());var x2="wc",_2=2,E2="client",T0=`${x2}@${_2}:${E2}:`,v0={name:E2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var v2="WALLETCONNECT_DEEPLINK_CHOICE";var bM="proposal";var vM="Proposal expired",yM="session",mo=qe.SEVEN_DAYS,wM="engine",vt={wc_sessionPropose:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:qe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:qe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1119}}},y0={min:qe.FIVE_MINUTES,max:qe.SEVEN_DAYS},xi={idle:"IDLE",active:"ACTIVE"},xM="request",_M=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],EM="wc";var SM="auth",IM="authKeys",AM="pairingTopics",MM="requests",mu=`${EM}@${1.5}:${SM}:`,lu=`${mu}:PUB_KEY`,TM=Object.defineProperty,PM=Object.defineProperties,RM=Object.getOwnPropertyDescriptors,y2=Object.getOwnPropertySymbols,NM=Object.prototype.hasOwnProperty,DM=Object.prototype.propertyIsEnumerable,w2=(r,e,t)=>e in r?TM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e)=>{for(var t in e||(e={}))NM.call(e,t)&&w2(r,t,e[t]);if(y2)for(var t of y2(e))DM.call(e,t)&&w2(r,t,e[t]);return r},Fr=(r,e)=>PM(r,RM(e)),w0=class extends Bc{constructor(e){super(e),this.name=wM,this.events=new gu.default,this.initialized=!1,this.requestQueue={state:xi.idle,queue:[]},this.sessionRequestQueue={state:xi.idle,queue:[]},this.requestQueueDelay=qe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(vt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=Fr(st({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:f}=i,u=n,g,y=!1;try{u&&(y=this.client.core.pairing.pairings.get(u).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),B}if(!u||!y){let{topic:B,uri:j}=await this.client.core.pairing.create();u=B,g=j}if(!u){let{message:B}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(B)}let S=await this.client.core.crypto.generateKeyPair(),I=vt.wc_sessionPropose.req.ttl||qe.FIVE_MINUTES,A=ut(I),P=st({requiredNamespaces:s,optionalNamespaces:o,relays:f??[{protocol:b0}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:A,pairingTopic:u},a&&{sessionProperties:a}),{reject:O,resolve:N,done:U}=Fi(I,vM);this.events.once(Fe("session_connect"),async({error:B,session:j})=>{if(B)O(B);else if(j){j.self.publicKey=S;let V=Fr(st({},j),{pairingTopic:P.pairingTopic,requiredNamespaces:P.requiredNamespaces,optionalNamespaces:P.optionalNamespaces,transportType:We.relay});await this.client.session.set(j.topic,V),await this.setExpiry(j.topic,j.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(V),N(V)}});let k=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:P,throwOnFailedPublish:!0});return await this.setProposal(k,st({id:k},P)),{uri:g,approval:U}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[mr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(C){throw o.setError(gn.no_internet_connection),C}try{await this.isValidProposalId(t?.id)}catch(C){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(gn.proposal_not_found),C}try{await this.isValidApprove(t)}catch(C){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(gn.session_approve_namespace_validation_failure),C}let{id:a,relayProtocol:f,namespaces:u,sessionProperties:g,sessionConfig:y}=t,S=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:A,requiredNamespaces:P,optionalNamespaces:O}=S,N=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});N||(N=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:mr.session_approve_started,properties:{topic:I,trace:[mr.session_approve_started,mr.session_namespaces_validation_success]}}));let U=await this.client.core.crypto.generateKeyPair(),k=A.publicKey,B=await this.client.core.crypto.generateSharedKey(U,k),j=st(st({relay:{protocol:f??"irn"},namespaces:u,controller:{publicKey:U,metadata:this.client.metadata},expiry:ut(mo)},g&&{sessionProperties:g}),y&&{sessionConfig:y}),V=We.relay;N.addTrace(mr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(B,{transportType:V})}catch(C){throw N.setError(gn.subscribe_session_topic_failure),C}N.addTrace(mr.subscribe_session_topic_success);let L=Fr(st({},j),{topic:B,requiredNamespaces:P,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:A.publicKey,metadata:A.metadata},controller:U,transportType:We.relay});await this.client.session.set(B,L),N.addTrace(mr.store_session);try{N.addTrace(mr.publishing_session_settle),await this.sendRequest({topic:B,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(C=>{throw N?.setError(gn.session_settle_publish_failure),C}),N.addTrace(mr.session_settle_publish_success),N.addTrace(mr.publishing_session_approve),await this.sendResult({id:a,topic:I,result:{relay:{protocol:f??"irn"},responderPublicKey:U},throwOnFailedPublish:!0}).catch(C=>{throw N?.setError(gn.session_approve_publish_failure),C}),N.addTrace(mr.session_approve_publish_success)}catch(C){throw this.client.logger.error(C),this.client.session.delete(B,ke("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(B),C}return this.client.core.eventClient.deleteEvent({eventId:N.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:A.metadata}),await this.client.proposal.delete(a,ke("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(B,ut(mo)),{topic:B,acknowledged:()=>Promise.resolve(this.client.session.get(B))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:vt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:a}=Fi(),f=gi(),u=Dr().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Fe("session_update",f),({error:y})=>{y?a(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:f,relayRpcId:u}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:g}),a(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(f){throw this.client.logger.error("extend() -> isValidExtend() failed"),f}let{topic:i}=t,n=gi(),{done:s,resolve:o,reject:a}=Fi();return this.events.once(Fe("session_extend",n),({error:f})=>{f?a(f):o()}),await this.setExpiry(i,ut(mo)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(f=>{a(f)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(A){throw this.client.logger.error("request() -> isValidRequest() failed"),A}let{chainId:i,request:n,topic:s,expiry:o=vt.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(s);a?.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let f=gi(),u=Dr().toString(),{done:g,resolve:y,reject:S}=Fi(o,"Request expired. Please try again.");this.events.once(Fe("session_request",f),({error:A,result:P})=>{A?S(A):y(P)});let I=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return I?(await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(A=>S(A)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),await g()):await Promise.all([new Promise(async A=>{await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(P=>S(P)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),A()}),new Promise(async A=>{var P;if(!((P=a.sessionConfig)!=null&&P.disableDeepLink)){let O=await Qv(this.client.core.storage,v2);await Xv({id:f,topic:s,wcDeepLink:O})}A()}),g()]).then(A=>A[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Xt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Lt(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=gi(),s=Dr().toString(),{done:o,resolve:a,reject:f}=Fi();this.events.once(Fe("session_ping",n),({error:u})=>{u?f(u):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=Dr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ke("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gy(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?We.link_mode:We.relay;o===We.relay&&await this.confirmOnlineStateOrThrow();let{chains:a,statement:f="",uri:u,domain:g,nonce:y,type:S,exp:I,nbf:A,methods:P=[],expiry:O}=t,N=[...t.resources||[]],{topic:U,uri:k}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:U,uri:k}});let B=await this.client.core.crypto.generateKeyPair(),j=no(B);if(await Promise.all([this.client.auth.authKeys.set(lu,{responseTopic:j,publicKey:B}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:U})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${U}`),P.length>0){let{namespace:v}=ya(a[0]),h=ty(v,"request",P);Sa(N)&&(h=ry(h,N.pop())),N.push(h)}let V=O&&O>vt.wc_sessionAuthenticate.req.ttl?O:vt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:a,statement:f,aud:u,domain:g,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:A,resources:N},requester:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(V)},C={eip155:{chains:a,methods:[...new Set(["personal_sign",...P])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:U,proposer:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(vt.wc_sessionPropose.req.ttl)},{done:R,resolve:l,reject:w}=Fi(V,"Request expired"),p=async({error:v,session:h})=>{if(this.events.off(Fe("session_request",d),c),v)w(v);else if(h){h.self.publicKey=B,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:h.peer.metadata});let _=this.client.session.get(h.topic);await this.deleteProposal(b),l({session:_})}},c=async v=>{var h,_,M;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),v.error){let q=ke("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return v.error.code===q.code?void 0:(this.events.off(Fe("session_connect"),p),w(v.error.message))}await this.deleteProposal(b),this.events.off(Fe("session_connect"),p);let{cacaos:m,responder:T}=v.result,z=[],E=[];for(let q of m){await hl({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(ke("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,Y=Sa(K.resources),H=[Bf(K.iss)],$=Ea(K.iss);if(Y){let ee=ll(Y),G=pl(Y);z.push(...ee),H.push(...G)}for(let ee of H)E.push(`${ee}:${$}`)}let D=await this.client.core.crypto.generateSharedKey(B,T.publicKey),F;z.length>0&&(F={topic:D,acknowledged:!0,self:{publicKey:B,metadata:this.client.metadata},peer:T,controller:T.publicKey,expiry:ut(mo),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:U,namespaces:xl([...new Set(z)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(D,{transportType:o}),await this.client.session.set(D,F),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:T.metadata}),F=this.client.session.get(D)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(_=T.metadata.redirect)!=null&&_.linkMode&&(M=T.metadata.redirect)!=null&&M.universal&&i&&(this.client.core.addLinkModeSupportedApp(T.metadata.redirect.universal),this.client.session.update(D,{transportType:We.link_mode})),l({auths:m,session:F})},d=gi(),b=gi();this.events.once(Fe("session_connect"),p),this.events.once(Fe("session_request",d),c);let x;try{if(s){let v=Cr("wc_sessionAuthenticate",L,d);this.client.core.history.set(U,v);let h=await this.client.core.crypto.encode("",v,{type:io,encoding:ro});x=Aa(i,U,h)}else await Promise.all([this.sendRequest({topic:U,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:U,method:"wc_sessionPropose",params:W,expiry:vt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(v){throw this.events.off(Fe("session_connect"),p),this.events.off(Fe("session_request",d),c),v}return await this.setProposal(b,st({id:b},W)),await this.setAuthRequest(d,{request:Fr(st({},L),{verifyContext:{}}),pairingTopic:U,transportType:o}),{uri:x??k,response:R}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[mn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(go.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(go.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let a=o.transportType||We.relay;a===We.relay&&await this.confirmOnlineStateOrThrow();let f=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),g=no(f),y={type:Rr,receiverPublicKey:f,senderPublicKey:u},S=[],I=[];for(let O of n){if(!await hl({cacao:O,projectId:this.client.core.projectId})){s.setError(go.invalid_cacao);let j=ke("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:g,error:j,encodeOpts:y}),new Error(j.message)}s.addTrace(mn.cacaos_verified);let{p:N}=O,U=Sa(N.resources),k=[Bf(N.iss)],B=Ea(N.iss);if(U){let j=ll(U),V=pl(U);S.push(...j),k.push(...V)}for(let j of k)I.push(`${j}:${B}`)}let A=await this.client.core.crypto.generateSharedKey(u,f);s.addTrace(mn.create_authenticated_session_topic);let P;if(S?.length>0){P={topic:A,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:f,metadata:o.requester.metadata},controller:f,expiry:ut(mo),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:xl([...new Set(S)],[...new Set(I)]),transportType:a},s.addTrace(mn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(A,{transportType:a})}catch(O){throw s.setError(go.subscribe_authenticated_session_topic_failure),O}s.addTrace(mn.subscribe_authenticated_session_topic_success),await this.client.session.set(A,P),s.addTrace(mn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(mn.publishing_authenticated_session_approve);try{await this.sendResult({topic:g,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(O){throw s.setError(go.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:P}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),f=no(o),u={type:Rr,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:f,error:n,encodeOpts:u,rpcOpts:vt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return dl(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=t,{self:f}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ke("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(f.publicKey)&&await this.client.core.crypto.deleteKeyPair(f.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(v2).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,ke("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=xi.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(gn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,ke("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=xi.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,ut(vt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=We.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,a=s.request.expiryTimestamp||ut(vt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:f,throwOnFailedPublish:u,appLink:g}=t,y=Cr(n,s,f),S,I=!!g;try{let O=I?ro:pi;S=await this.client.core.crypto.encode(i,y,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let A;if(_M.includes(n)){let O=Nr(JSON.stringify(y)),N=Nr(S);A=await this.client.core.verify.register({id:N,decryptedId:O})}let P=vt[n].req;if(P.attestation=A,o&&(P.ttl=o),a&&(P.id=a),this.client.core.history.set(i,y),I){let O=Aa(g,i,S);await global.Linking.openURL(O,this.client.name)}else{let O=vt[n].req;o&&(O.ttl=o),a&&(O.id=a),u?(O.internal=Fr(st({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(N=>this.client.logger.error(N))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:f}=t,u=co(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ro:pi;g=await this.client.core.crypto.encode(n,u,Fr(st({},a||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Aa(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=vt[S.request.method].res;o?(I.internal=Fr(st({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,I)):this.client.core.relayer.publish(n,g,I).catch(A=>this.client.logger.error(A))}await this.client.core.history.resolve(u)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:f}=t,u=is(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ro:pi;g=await this.client.core.crypto.encode(n,u,Fr(st({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Aa(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=a||vt[S.request.method].res;this.client.core.relayer.publish(n,g,I)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;li(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{li(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===xi.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=xi.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=xi.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=t,f=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:f}))switch(f){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${f}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:a,id:f}=n;try{let u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(st({},n.params));let g=a.expiryTimestamp||ut(vt.wc_sessionPropose.req.ttl),y=st({id:f,pairingTopic:i,expiryTimestamp:g},a);await this.setProposal(f,y);let S=await this.getVerifyContext({attestationId:s,hash:Nr(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(vi.proposal_listener_not_found)),u?.addTrace(Lr.emit_session_proposal),this.client.events.emit("session_proposal",{id:f,params:y,verifyContext:S})}catch(u){await this.sendError({id:f,topic:i,error:u,rpcOpts:vt.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(Xt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});let f=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:f});let u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});let g=await this.client.core.crypto.generateSharedKey(f,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});let y=await this.client.core.relayer.subscribe(g,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(Lt(i)){await this.client.proposal.delete(s,ke("USER_DISCONNECTED"));let o=Fe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Fe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:a,expiry:f,namespaces:u,sessionProperties:g,sessionConfig:y}=i.params,S=Fr(st(st({topic:t,relay:o,expiry:f,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},g&&{sessionProperties:g}),y&&{sessionConfig:y}),{transportType:We.relay}),I=Fe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Fe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;Xt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Fe("session_approve",n),{})):Lt(i)&&(await this.client.session.delete(t,ke("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,a=on.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:ke("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(st({topic:t},n));try{on.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(f){throw on.delete(o),f}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Fe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Xt(i)?this.events.emit(Fe("session_update",n),{}):Lt(i)&&this.events.emit(Fe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,ut(mo)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Fe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Xt(i)?this.events.emit(Fe("session_extend",n),{}):Lt(i)&&this.events.emit(Fe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Fe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Xt(i)?this.events.emit(Fe("session_ping",n),{}):Lt(i)&&this.events.emit(Fe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ut.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:ke("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:a,attestation:f,encryptedId:u,transportType:g}=t,{id:y,params:S}=a;try{await this.isValidRequest(st({topic:o},S));let I=this.client.session.get(o),A=await this.getVerifyContext({attestationId:f,hash:Nr(JSON.stringify(Cr("wc_sessionRequest",S,y))),encryptedId:u,metadata:I.peer.metadata,transportType:g}),P={id:y,topic:o,params:S,verifyContext:A};await this.setPendingSessionRequest(P),g===We.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(P):(this.addSessionRequestToSessionRequestQueue(P),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Fe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Xt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,a=on.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(st({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),on.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Xt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:a,transportType:f}=t;try{let{requester:u,authPayload:g,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:Nr(JSON.stringify(s)),encryptedId:a,metadata:u.metadata,transportType:f}),I={requester:u,pairingTopic:n,id:s.id,authPayload:g,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:f}),f===We.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(u){this.client.logger.error(u);let g=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,f),I={type:Rr,receiverPublicKey:g,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:I,rpcOpts:vt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=xi.idle,this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,a=Fe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Fe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===xi.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=xi.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Cr("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(f)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=t;if(St(i)||await this.isValidPairingTopic(i),!_y(a,!0)){let{message:f}=Q("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(f)}!St(n)&&Ma(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!St(s)&&Ma(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),St(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=xy(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Ot(t))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let a=this.client.proposal.get(i),f=jf(n,"approve()");if(f)throw new Error(f.message);let u=Il(a.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!et(s,!0)){let{message:g}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}St(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Ot(t)){let{message:s}=Q("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Sy(n)){let{message:s}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Ot(t)){let{message:u}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(u)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!El(i)){let{message:u}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}let a=yy(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);let f=jf(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(li(o)){let{message:u}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(f)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=jf(n,"update()");if(o)throw new Error(o.message);let a=Il(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(f)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:a}=this.client.session.get(i);if(!Sl(a,s)){let{message:f}=Q("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!Iy(n)){let{message:f}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(f)}if(!Ty(a,s,n.method)){let{message:f}=Q("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(f)}if(o&&!Ry(o,y0)){let{message:f}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${y0.min} and ${y0.max}`);throw new Error(f)}},this.isValidRespond=async t=>{var i;if(!Ot(t)){let{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!Ay(s)){let{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Ot(t)){let{message:a}=Q("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!Sl(o,s)){let{message:a}=Q("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!My(n)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!Py(o,s,n.name)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!et(n,!1))throw new Error("uri is required parameter");if(!et(s,!1))throw new Error("domain is required parameter");if(!et(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(f=>ya(f).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:a}=ya(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=t,f={verified:{verifyUrl:o.verifyUrl||po,validation:"UNKNOWN",origin:o.url||""}};try{if(a===We.link_mode){let g=this.getAppLinkIfEnabled(o,a);return f.verified.validation=g&&new URL(g).origin===new URL(o.url).origin?"VALID":"INVALID",f}let u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(f.verified.origin=u.origin,f.verified.isScam=u.isScam,f.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(f)}`),f},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!et(n,!1)){let{message:s}=Q("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,a,f,u,g,y,S;return!t||i!==We.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((u=(f=this.client.metadata)==null?void 0:f.redirect)==null?void 0:u.universal)!==""&&((g=t?.redirect)==null?void 0:g.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=cl(t,"topic")||"",n=decodeURIComponent(cl(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:We.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(_a()||ts()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ut.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(lu)?this.client.auth.authKeys.get(lu):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===We.link_mode?ro:pi});try{fo(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:n,transportType:s,encryptedId:Nr(i)})):hn(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:s}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:s})}catch(f){this.client.logger.error(f)}}registerExpirerEvents(){this.client.core.expirer.on(Qt.expired,async e=>{let{topic:t,id:i}=qf(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(pn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(pn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(li(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(li(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=Q("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=Q("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(et(e,!1)){let{message:t}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Ey(e)){let{message:t}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(li(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},x0=class extends wi{constructor(e,t){super(e,t,bM,T0),this.core=e,this.logger=t}},_0=class extends wi{constructor(e,t){super(e,t,yM,T0),this.core=e,this.logger=t}},E0=class extends wi{constructor(e,t){super(e,t,xM,T0,i=>i.id),this.core=e,this.logger=t}},S0=class extends wi{constructor(e,t){super(e,t,IM,mu,()=>lu),this.core=e,this.logger=t}},I0=class extends wi{constructor(e,t){super(e,t,AM,mu),this.core=e,this.logger=t}},A0=class extends wi{constructor(e,t){super(e,t,MM,mu,i=>i.id),this.core=e,this.logger=t}},M0=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new S0(this.core,this.logger),this.pairingTopics=new I0(this.core,this.logger),this.requests=new A0(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},pu=class r extends qc{constructor(e){super(e),this.protocol=x2,this.version=_2,this.name=v0.name,this.events=new gu.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||v0.name,this.metadata=e?.metadata||to(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,jo.default)(Vo({level:e?.logger||v0.logger}));this.core=e?.core||new b2(e),this.logger=wt(t,this.name),this.session=new _0(this.core,this.logger),this.proposal=new x0(this.core,this.logger),this.pendingRequest=new E0(this.core,this.logger),this.engine=new w0(this),this.auth=new M0(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return Mt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};function P0(r,e){let t=[...Sp,...e?.methods??[]];e?.methods?.includes("mvx_signLoginToken")||t.push("mvx_signLoginToken");let i=[`${wr}:${r}`],n=e?.events??[];return{requiredNamespaces:{[wr]:{methods:t,chains:i,events:n}}}}function R0(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=e.find(P0(r)).filter(i=>i.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function ki(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=R0(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function S2(r){return!!r}function N0(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function D0({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,a=r.guardian;if(a&&a!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=or(t),i&&(r.guardianSignature=or(i)),r}function I2(r){if(r)return{...r,url:to().url}}async function A2(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var Zt=class{constructor(e,t,i,n,s){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.options=s}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:I2(this.options?.metadata)}:{},t=await pu.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=P0(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await A2(Ep);let i=N0(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||ki(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:ke("USER_DISCONNECTED")});else{let t=ki(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:ke("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new Gt({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=yt.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return D0({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return yt.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];D0({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=ki(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?S2(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=N0(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&ki(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=R0(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!an(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var C0=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},er=class r{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:vp,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(i=>{setTimeout(()=>{window.location.href=e,i(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:yp,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let i=this.buildWalletUrl({endpoint:_p,callbackUrl:t?.callbackUrl,params:{message:ji(e.data)}});return await this.redirect(i),i}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=ju(e);if((t.status?.toString()||"")!=="signed")throw new sc;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(xp,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(wp,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=ju(e.slice(1));return r.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,Po)&&e[Po]===Za}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let s of t)if(!e[s]||!Array.isArray(e[s]))throw new Do;let i=e.nonce.length;for(let s of t)if(e[s].length!==i)throw new Do;let n=[];for(let s=0;s{let a=r.prepareWalletTransaction(o);for(let f in a)Object.prototype.hasOwnProperty.call(a,f)&&!Object.prototype.hasOwnProperty.call(n,f)&&(n[f]=[]),n[f].push(a[f])});let s=this.buildWalletUrl({endpoint:e,callbackUrl:i?.callbackUrl,params:n});window.location.href=s}};var O0=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},bo=class{constructor(e){this.config=Object.assign(new O0,e)}getToken(e,t,i){let n=this.encodeValue(e),s=this.encodeValue(t);return`${n}.${s}.${i}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),i=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${i}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(o=>o.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(Xa(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var bu=(r,e)=>t=>{let i=t.data;try{i=Ku()&&typeof i=="string"?JSON.parse(i):i}catch{console.error("error parsing eventData",i)}let{type:n,payload:s}=i;!Ku()&&t.origin!=To()||!(r===n||n==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",bu(r,e)),e({type:n,payload:s}))};var bn=class r{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",bu("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:i}=e.payload;if(i||!t)throw new Error("Unable to re-login");let{accessToken:n}=t;return n?(this.account=t,n):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(s=>yt.transactionToPlainObject(s))}),{data:i,error:n}=t.payload;if(n||!i)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return i.map(s=>yt.plainObjectToTransaction(s))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:ji(e.data)}}),{data:i,error:n}=t.payload;return n||!i?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):i.status!=="signed"?(console.error("Could not sign message"),null):new Gt({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:or(i.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),To()):t.parent&&t.parent.postMessage(e,To())),await this.waitingForResponse(Ip[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",bu(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return r._instance||(r._instance=new r(e)),r._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var te=class{static set(e,t){if(!e)return;let i={...this.events,[e]:t};this.events=i}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var M2=(U=>(U.onLoginStart="onLoginStart",U.onLoginSuccess="onLoginSuccess",U.onLoginFailure="onLoginFailure",U.onLogoutStart="onLogoutStart",U.onLogoutSuccess="onLogoutSuccess",U.onLogoutFailure="onLogoutFailure",U.onQrPending="onQrPending",U.onQrLoaded="onQrLoaded",U.onTxStart="onTxStart",U.onTxSent="onTxSent",U.onTxFinalized="onTxFinalized",U.onTxFailure="onTxFailure",U.onSignMsgStart="onSignMsgStart",U.onSignMsgFinalized="onSignMsgFinalized",U.onSignMsgFailure="onSignMsgFailure",U.onQueryStart="onQueryStart",U.onQueryFinalized="onQueryFinalized",U.onQueryFailure="onQueryFailure",U))(M2||{}),L0=(o=>(o.ledger="ledger",o.mobile="mobile",o.webWallet="web-wallet",o.browserExtension="browser-extension",o.xAlias="x-alias",o.webview="webview",o))(L0||{}),CM=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(CM||{}),OM=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(OM||{});var ot=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);var vo=async r=>{if(!r.dappProvider)throw new Error("Logout failed: There is no active session!");te.run("onLogoutStart");try{let e=await r.dappProvider.logout();return e&&(re.clear(),te.run("onLogoutSuccess")),e}catch(e){let t=ot(e);console.warn(`Something went wrong trying to logout the user: ${t}`),te.run("onLogoutFailure",t)}};function vu(r){return r[Math.floor(Math.random()*r.length)]}var T2=async r=>{if(!r.initOptions.walletConnectV2ProjectId||!r.initOptions.chainType)return;let e={onClientLogin:()=>{},onClientLogout:()=>vo(r),onClientEvent:n=>{console.log("wc2 session event: ",n)}},t=vu(r.initOptions.walletConnectV2RelayAddresses),i=new Zt(e,At[r.initOptions.chainType].shortId,t,r.initOptions.walletConnectV2ProjectId);try{return await i.init(),i}catch{console.warn("Can't initialize the Dapp Provider!")}};var $t=r=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(r)}};var F0=async(r,e)=>{let t=$t("signature"),i=$t("address"),n=re.get("address"),s=re.get("loginToken");if(t&&re.set("signature",t),i||n){i&&(re.set("address",i),window.history.replaceState(null,"",window.location.pathname));let o=new er(`${r}${Vi}`);if(t&&e&&i){let f=new bo({apiUrl:e,origin:window.location.origin}).getToken(i,s,t);re.set("accessToken",f)}return o}};var yu=class r{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new r("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var wu=class{constructor({apiUrl:e,chainType:t,apiTimeout:i}){this.chainType=t||ac,this.apiUrl=e||At[this.chainType]?.apiAddress,this.apiTimeout=i||At[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let i=new AbortController,n=setTimeout(()=>i.abort(),this.apiTimeout),s={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:i.signal};try{let o=await fetch(this.apiUrl+"/"+e,Object.assign(s,t||{})),a=await o.json();if(!o.ok){let f=a?.error||o.status;return clearTimeout(n),Promise.reject(f)}return clearTimeout(n),a}catch(o){this.handleApiError(o,e)}}}async apiPost(e,t,i){if(typeof fetch<"u"){let n=new AbortController,s=setTimeout(()=>n.abort(),this.apiTimeout),o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:n.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(o,i||{})),f=await a.json();if(!a.ok){let u=f?.error||a.status;return clearTimeout(s),Promise.reject(u)}return clearTimeout(s),f}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let i=e.response.data,n=i.error||i.message||JSON.stringify(i);throw new Error(n)}async sendTransaction(e){let t=yt.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),i=new yu(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:On(t.data||""),status:i,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!i.isPending()}}async queryContract({address:e,func:t,args:i,value:n,caller:s}){try{let o={scAddress:e,caller:s,funcName:t,value:n,args:()=>i?.map(f=>Xa(f))},a=await this.apiPost("query",o);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(o){this.handleApiError(o,"query")}}};var yo=()=>new Date().setHours(new Date().getHours()+24),xu=r=>Date.now()>r;var cs=async r=>{let e=re.get("address"),t=re.get("expires");if(!(t&&xu(t))&&e&&r.networkProvider){let n=new _i(e);try{let s=await r.networkProvider.getAccount(e),o=await r.networkProvider.getGuardianData(e);re.set("address",e),re.set("activeGuardian",o.guarded&&o.activeGuardian?.address?o.activeGuardian.address:""),re.set("nonce",s.nonce.valueOf()),re.set("balance",s.balance.toString()),n.update(s)}catch(s){let o=ot(s);console.warn(`Something went wrong trying to synchronize the user account: ${o}`)}}};var P2=async(r,e,t,i="/")=>{let n=await cc(),o={callbackUrl:encodeURIComponent(`${window.location.origin}${i}`),token:e};try{if(n&&!await n.login(o))throw new Error("There were problems while logging in!")}catch(u){let g=ot(u);throw new Error(g)}if(!n)throw new Error("There were problems with auth provider initialization!");let a=n.getAccount();re.set("loginToken",e);let f=a?.signature;if(f&&re.set("signature",f),r.networkProvider&&f)try{let u=await n.getAddress();if(!u)throw new Error("Canceled!");re.set("address",u),re.set("loginMethod","browser-extension"),re.set("expires",yo()),await cs(r);let g=t.getToken(u,e,f);return re.set("accessToken",g),te.run("onLoginSuccess"),n}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var R3=Be(P3(),1);var TT=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},PT=r=>{let e=`${Mp}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},RT=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},NT=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},op={},DT=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",op[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:op[r.topic].signal}),t},Cu={},CT=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=DT(r,e);return i.appendChild(s),Cu[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:Cu[r.topic].signal}),i},OT=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},LT=r=>{if(!r)return;document.getElementById(r)?.remove()},FT=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),UT=async r=>r?await(0,R3.toString)(r,{type:"svg"}):void 0,N3=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=await UT(e),o;if(s&&(o=TT(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),FT()&&n.appendChild(PT(e))),n&&t instanceof Zt){let a=t.pairings,f=async g=>{try{g&&(await t.logout({topic:g}),LT(g))}catch(y){let S=ot(y);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{Cu[g].abort()}},u=async g=>{try{let{approval:y}=await t.connect({topic:g,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(g)?.after(OT()),await t.login({approval:y,token:i})}catch(y){let S=ot(y);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let y of Object.values(Cu))y?.abort();for(let y of Object.values(op))y?.abort()}};if(a&&a.length>0){let g=RT();n.appendChild(g);let y=NT();g.appendChild(y);for(let S of a){let I=CT(S,f,u);g.appendChild(I)}}}return n};var D3=async(r,e,t,i)=>{if(!i)throw new Error("You haven't provided the QR code container DOM element id");let n=vu(r.initOptions.walletConnectV2RelayAddresses);if(!n||!r.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!r.initOptions.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!r.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let s,o={onClientLogin:async()=>{if(r.dappProvider instanceof Zt){let f=await r.dappProvider.getAddress(),u=await r.dappProvider.getSignature();re.set("address",f),re.set("loginMethod","mobile"),re.set("expires",yo()),await cs(r),u&&re.set("signature",u),re.set("loginToken",e);let g=t.getToken(f,e,u);re.set("accessToken",g),te.run("onLoginSuccess"),s?.replaceChildren()}},onClientLogout:async()=>{r.dappProvider instanceof Zt&&await vo(r)},onClientEvent:f=>{console.log("wc2 session event: ",f)}},a=new Zt(o,At[r.initOptions.chainType].shortId,n,r.initOptions.walletConnectV2ProjectId);try{if(a){r.dappProvider=a,te.run("onQrPending"),await a.init();let{uri:f,approval:u}=await a.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),g=e?`${f}&token=${e}`:f;return i&&g&&(s=await N3(i,g,a,e),te.run("onQrLoaded")),await a.login({approval:u,token:e}),a}}catch(f){let u=ot(f);console.warn(`Something went wrong trying to login the user: ${u}`),te.run("onLoginFailure",u)}};var ap=async(r,e,t,i)=>{let n=new er(`${r}${Vi}`),o={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${i||"/"}`):"/",token:e};try{return re.set("loginMethod",At[t].xAliasAddress===r?"x-alias":"web-wallet"),await n.login(o),re.set("expires",yo()),re.set("loginToken",e),n}catch(a){let f=ot(a);console.warn(`Something went wrong trying to login the user: ${f}`),re.set("loginMethod",""),te.run("onLoginFailure",f)}};var Ou=async(r,e)=>{te.run("onTxSent",r);let i=await new Co(e).awaitCompleted(r.txHash),n=i.sender,s=new _i(n),o=await e.getAccount(n);s.update(o),re.set("address",s.bech32()),re.set("balance",s.balance),te.run("onTxFinalized",i)};var Lu=r=>{let e=r.sender,t=new _i(e),i=r.nonce.valueOf();t.incrementNonce(),re.set("nonce",(i+1n).toString())};var C3=async(r,e,t,i)=>{if($t(Po)===Za&&r&&e){let s=re.get("activeGuardian"),o=re.get("loginMethod"),a=$t("hasWebWalletGuardianSign"),f;if("getTransactionsFromWalletUrl"in r){if(f=r.getTransactionsFromWalletUrl()?.[0],!f)return;o==="web-wallet"&&(f.data=Ki(f.data))}else s&&o!=="web-wallet"&&o!=="x-alias"&&a&&(f=new er(`${t}${Vi}`).getTransactionsFromWalletUrl()?.[0]);if(f){let u=yt.plainObjectToTransaction(f);u.nonce=BigInt(i),Lu(u);try{te.run("onTxStart",u);let g=await e.sendTransaction(u);await Ou(g,e)}catch(g){let S=`Getting transaction information failed! ${ot(g)}`;throw te.run("onTxFailure",u,S),new Error(S)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var O3=r=>{let e=re.get("activeGuardian");return e&&(r.version=Qa,r.options=gp,r.guardian=e),r},L3=async(r,e)=>{let t=new er(`${e}${Vi}`),i=window?.location.href,n=new URL(i);n.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([r],{callbackUrl:encodeURIComponent(n.toString())})},F3=r=>{let e=re.get("activeGuardian");return!(!re.get("address")||!e||r.isGuardedTransaction())};var U3=()=>{let r=!$t("walletProviderStatus"),e=$t("status")==="signed",t=$t("message"),i=$t("signature");r&&e&&t&&i&&(te.run("onSignMsgFinalized",t,i),window.history.replaceState(null,"",window.location.pathname))};function qT(r){try{let e=atob(r),t=btoa(e),i=Mo(r),n=Ki(i),s=r===t||t.startsWith(r),o=r===n||n.startsWith(r);if(s&&o)return!0}catch{return!1}return!1}function Io(r){return qT(r)?atob(r):r}var Fu=r=>Object.prototype.toString.call(r)==="[object String]";var q3=r=>{if(!r||!Fu(r))return null;let e=r.split(".");if(e.length!==4)return null;try{let[t,i,n,s]=e,o=JSON.parse(Io(s)),a=Io(t);return{ttl:Number(n),extraInfo:o,origin:a,blockHash:i}}catch(t){return console.error(`Error trying to decode ${r}:`,t),null}};var B3=r=>{if(!r||!Fu(r))return null;let e=r.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,i,n]=e,s=Io(t),o=Io(i),a=q3(o);if(!a)return{address:s,body:o,signature:n,blockHash:"",origin:"",ttl:0};let f={...a,address:s,body:o,signature:n};return a.extraInfo?.timestamp||delete f.extraInfo,f}catch{return null}};function k3(r,e){let t=B3(r);if(t==null)return;let{signature:i,address:n,body:s}=t;i&&r&&n&&(re.set("loginToken",s),re.set("accessToken",r),re.set("signature",i),re.set("address",n),re.set("loginMethod","webview"),e.dappProvider=new bn)}var z3=r=>{r.onLoginStart&&te.set("onLoginStart",r.onLoginStart),r.onLoginSuccess&&te.set("onLoginSuccess",r.onLoginSuccess),r.onLoginFailure&&te.set("onLoginFailure",r.onLoginFailure),r.onLogoutStart&&te.set("onLogoutStart",r.onLogoutStart),r.onLogoutSuccess&&te.set("onLogoutSuccess",r.onLogoutSuccess),r.onLogoutFailure&&te.set("onLogoutFailure",r.onLogoutFailure),r.onQrPending&&te.set("onQrPending",r.onQrPending),r.onQrLoaded&&te.set("onQrLoaded",r.onQrLoaded),r.onTxStart&&te.set("onTxStart",r.onTxStart),r.onTxSent&&te.set("onTxSent",r.onTxSent),r.onTxFinalized&&te.set("onTxFinalized",r.onTxFinalized),r.onTxFailure&&te.set("onTxFailure",r.onTxFailure),r.onSignMsgStart&&te.set("onSignMsgStart",r.onSignMsgStart),r.onSignMsgFinalized&&te.set("onSignMsgFinalized",r.onSignMsgFinalized),r.onSignMsgFailure&&te.set("onSignMsgFailure",r.onSignMsgFailure),r.onQueryStart&&te.set("onQueryStart",r.onQueryStart),r.onQueryFinalized&&te.set("onQueryFinalized",r.onQueryFinalized),r.onQueryFailure&&te.set("onQueryFailure",r.onQueryFailure)};var Uu=async r=>{te.run("onLoginStart");try{await r(()=>{te.run("onLoginSuccess")})}catch(e){let t=ot(e);console.warn(`Something went wrong trying to login the user: ${t}`),te.run("onLoginFailure",t)}};var cp=class{static async init(e){let t=re.get();if(t.expires&&xu(t.expires)){re.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:ac,apiUrl:Ap,apiTimeout:1e4,walletConnectV2ProjectId:"",walletConnectV2RelayAddresses:Tp,...e},this.networkProvider=new wu(this.initOptions),z3(this.initOptions);let i=$t("accessToken");i&&await Uu(async s=>{k3(i,this),await cs(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&$t("address"))&&t?.loginMethod&&(await Uu(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await cc()),t.loginMethod==="mobile"&&(this.dappProvider=await T2(this)),t.loginMethod==="webview"&&(this.dappProvider=new bn),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await F0(At[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await F0(At[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await cs(this),s()}),this.initOptions?.chainType&&(await C3(this.dappProvider,this.networkProvider,At[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),U3()))}static async login(e,t){if(!Object.values(L0).includes(e)){let n="Wrong login method!";throw te.run("onLoginFailure",n),new Error(n)}if(!this.networkProvider){let n="Login failed: Use ElvenJs.init() first!";throw te.run("onLoginFailure",n),new Error(n)}await Uu(async()=>{let n=new bo({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),s=await n.initialize();if(e==="browser-extension"){let o=await P2(this,s,n,t?.callbackRoute);this.dappProvider=o}if(e==="mobile"){let o=await D3(this,s,n,t?.qrCodeContainer);this.dappProvider=o}if(e==="web-wallet"&&this.initOptions?.chainType){let o=await ap(At[this.initOptions.chainType].walletAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}if(e==="x-alias"&&this.initOptions?.chainType){let o=await ap(At[this.initOptions.chainType].xAliasAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}})}static async logout(){try{let e=await vo(this);return this.dappProvider=void 0,e}catch(e){let t=ot(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let i="Transaction signing failed: There is no active session!";throw te.run("onTxFailure",e,i),new Error(i)}if(!this.networkProvider){let i="Transaction signing failed: There is no active network provider!";throw te.run("onTxFailure",e,i),new Error(i)}let t=O3(e);try{te.run("onTxStart",e);let i=re.get();if(e.nonce=i.nonce,this.dappProvider instanceof Ln&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof Zt&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof bn&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof er&&await this.dappProvider.signTransaction(e),i.loginMethod!=="web-wallet"&&i.loginMethod!=="x-alias"){let n=F3(t);if(n||Lu(t),n&&this.initOptions?.chainType){await L3(t,At[this.initOptions.chainType].walletAddress);return}let s=await this.networkProvider.sendTransaction(t);await Ou(s,this.networkProvider)}}catch(i){let n=ot(i);throw te.run("onTxFailure",t,`Getting transaction information failed! ${n}`),new Error(`Getting transaction information failed! ${n}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let n="Message signing failed: There is no active session!";throw te.run("onSignMsgFailure",e,n),new Error(n)}if(!this.networkProvider){let n="Message signing failed: There is no active network provider!";throw te.run("onSignMsgFailure",e,n),new Error(n)}let i="";try{if(te.run("onSignMsgStart",e),this.dappProvider instanceof Ln){let s=await this.dappProvider.signMessage(new Gt({data:Cn(e)}));s?.signature&&(i=yr(s.signature))}if(this.dappProvider instanceof Zt){let s=await this.dappProvider.signMessage(new Gt({data:Cn(e)}));s?.signature&&(i=yr(s.signature))}if(this.dappProvider instanceof bn){let s=await this.dappProvider.signMessage(new Gt({data:Cn(e)}));s?.signature&&(i=yr(s.signature))}if(this.dappProvider instanceof er){let s=a=>encodeURIComponent(a).replace(/[!'()*]/g,f=>`%${f.charCodeAt(0).toString(16).toUpperCase()}`),o=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new Gt({data:Cn(e)}),{callbackUrl:encodeURIComponent(`${o}${o.includes("?")?"&":"?"}message=${s(e)}`)})}let n=re.get();return n.loginMethod!=="web-wallet"&&n.loginMethod!=="x-alias"&&te.run("onSignMsgFinalized",e,i),{message:e,messageSignature:i}}catch(n){let s=ot(n);throw te.run("onSignMsgFailure",e,s),new Error(`Message signing failed! ${s}`)}}static async queryContract({address:e,func:t,args:i=[],value:n=0,caller:s}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let o={address:e,func:t,args:i,value:n,caller:s};try{te.run("onQueryStart",o);let a=await this.networkProvider.queryContract(o);return te.run("onQueryFinalized",a),a}catch(a){let f=ot(a);throw te.run("onQueryFinalized",o,f),new Error(`Smart contract query failed! ${f}`)}}static{this.storage=re}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,te.clear()}}};var BT=({amount:r,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=r.toString().replace(/,/g,""),[i,n=""]=t.split("."),s=i+n.padEnd(e,"0");return s=s.substring(0,i.length+e),BigInt(s)},j3=({amount:r,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let i=BigInt(r)<0n,n=BigInt(r).toString();i&&(n=n.slice(1)),n=n.padStart(e+1,"0");let s=n.slice(0,-e),o=n.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),g=BigInt(r)+u;return i&&(g=-g),j3({amount:g,decimals:e,rounding:t})}}let a=`${s}.${o.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),i&&(a=`-${a}`),a};export{_i as Account,CM as DappCoreWCV2CustomMethodsEnum,cp as ElvenJS,M2 as EventStoreEvents,L0 as LoginMethodsEnum,Ro as Transaction,Co as TransactionWatcher,OM as WebWalletUrlParamsEnum,j3 as formatAmount,BT as parseAmount}; + Approved: ${S.toString()}`))}),o.forEach(y=>{i||(is(n[y].methods,s[y].methods)?is(n[y].events,s[y].events)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function f9(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function Wv(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function u9(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:lo(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Uy(r,e){return Tl(r,!1)&&r<=e.max&&r>=e.min}function Nl(){let r=Aa();return new Promise(e=>{switch(r){case Vt.browser:e(h9());break;case Vt.reactNative:e(d9());break;case Vt.node:e(l9());break;default:e(!0)}})}function h9(){return so()&&navigator?.onLine}async function d9(){return ss()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function l9(){return!0}function qy(r){switch(Aa()){case Vt.browser:p9(r);break;case Vt.reactNative:g9(r);break;case Vt.node:break}}function p9(r){!ss()&&so()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function g9(r){ss()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>r(e?.isConnected))}var cl={},un=class{static get(e){return cl[e]}static set(e,t){cl[e]=t}static delete(e){delete cl[e]}};var e2=Be(kn());var Ft={};qt(Ft,{DEFAULT_ERROR:()=>Oa,IBaseJsonRpcProvider:()=>ru,IEvents:()=>La,IJsonRpcConnection:()=>Fl,IJsonRpcProvider:()=>Fa,INTERNAL_ERROR:()=>Wf,INVALID_PARAMS:()=>jy,INVALID_REQUEST:()=>ky,METHOD_NOT_FOUND:()=>zy,PARSE_ERROR:()=>By,RESERVED_ERROR_CODES:()=>Cl,SERVER_ERROR:()=>Da,SERVER_ERROR_CODE_RANGE:()=>Jf,STANDARD_ERROR_MAP:()=>dn,formatErrorMessage:()=>Qy,formatJsonRpcError:()=>as,formatJsonRpcRequest:()=>Dr,formatJsonRpcResult:()=>po,getBigIntRpcId:()=>Cr,getError:()=>Xf,getErrorByCode:()=>Qf,isHttpUrl:()=>A9,isJsonRpcError:()=>Lt,isJsonRpcPayload:()=>ql,isJsonRpcRequest:()=>go,isJsonRpcResponse:()=>gn,isJsonRpcResult:()=>Qt,isJsonRpcValidationInvalid:()=>T9,isLocalhostUrl:()=>Ul,isNodeJs:()=>Xy,isReservedErrorCode:()=>Yf,isServerErrorCode:()=>m9,isValidDefaultRoute:()=>eu,isValidErrorCode:()=>Ky,isValidLeadingWildcardRoute:()=>x9,isValidRoute:()=>w9,isValidTrailingWildcardRoute:()=>_9,isValidWildcardRoute:()=>tu,isWsUrl:()=>iu,parseConnectionError:()=>Dl,payloadId:()=>bi,validateJsonRpcError:()=>b9});var By="PARSE_ERROR",ky="INVALID_REQUEST",zy="METHOD_NOT_FOUND",jy="INVALID_PARAMS",Wf="INTERNAL_ERROR",Da="SERVER_ERROR",Cl=[-32700,-32600,-32601,-32602,-32603],Jf=[-32e3,-32099],dn={[By]:{code:-32700,message:"Parse error"},[ky]:{code:-32600,message:"Invalid Request"},[zy]:{code:-32601,message:"Method not found"},[jy]:{code:-32602,message:"Invalid params"},[Wf]:{code:-32603,message:"Internal error"},[Da]:{code:-32e3,message:"Server error"}},Oa=Da;function m9(r){return r<=Jf[0]&&r>=Jf[1]}function Yf(r){return Cl.includes(r)}function Ky(r){return typeof r=="number"}function Xf(r){return Object.keys(dn).includes(r)?dn[r]:dn[Oa]}function Qf(r){let e=Object.values(dn).find(t=>t.code===r);return e||dn[Oa]}function b9(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!Ky(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(Yf(r.error.code)){let e=Qf(r.error.code);if(e.message!==dn[Oa].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Dl(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var kt={};qt(kt,{isNodeJs:()=>Xy});var Yy=Be(Ll());Ht(kt,Be(Ll()));var Xy=Yy.isNode;Ht(Ft,kt);function bi(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function Cr(r=6){return BigInt(bi(r))}function Dr(r,e,t){return{id:t||bi(),jsonrpc:"2.0",method:r,params:e}}function po(r,e){return{id:r,jsonrpc:"2.0",result:e}}function as(r,e,t){return{id:r,jsonrpc:"2.0",error:Qy(e,t)}}function Qy(r,e){return typeof r>"u"?Xf(Wf):(typeof r=="string"&&(r=Object.assign(Object.assign({},Xf(Da)),{message:r})),typeof e<"u"&&(r.data=e),Yf(r.code)&&(r=Qf(r.code)),r)}function w9(r){return r.includes("*")?tu(r):!/\W/g.test(r)}function eu(r){return r==="*"}function tu(r){return eu(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function x9(r){return!eu(r)&&tu(r)&&!r.split("*")[0].trim()}function _9(r){return!eu(r)&&tu(r)&&!r.split("*")[1].trim()}var La=class{},Fl=class extends La{constructor(e){super()}},ru=class extends La{constructor(){super()}},Fa=class extends ru{constructor(e){super()}};var E9="^https?:",S9="^wss?:";function I9(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Zy(r,e){let t=I9(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function A9(r){return Zy(r,E9)}function iu(r){return Zy(r,S9)}function Ul(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function ql(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function go(r){return ql(r)&&"method"in r}function gn(r){return ql(r)&&(Qt(r)||Lt(r))}function Qt(r){return"result"in r}function Lt(r){return"error"in r}function T9(r){return"error"in r&&r.valid===!1}var nu=class extends Fa{constructor(e){super(e),this.events=new e2.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Dr(e.method,e.params||[],e.id||Cr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Lt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),gn(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var s2=Be(kn());var M9=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:r2(),R9=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",i2=r=>r.split("?")[0],n2=10,P9=M9(),su=class{constructor(e){if(this.url=e,this.events=new s2.EventEmitter,this.registering=!1,!iu(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(cr(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!iu(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Ft.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Ul(e)},o=new P9(e,[],s);R9()?o.onerror=a=>{let f=a;i(this.emitError(f.error))}:o.on("error",a=>{i(this.emitError(a))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?ei(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=as(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Dl(e,i2(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>n2&&this.events.setMaxListeners(n2)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${i2(this.url)}`));return this.events.emit("register_error",t),t}};var cw=Be(k2()),fw=Be(nf()),uw="wc",hw=2,x0="core",xi=`${uw}@2:${x0}:`,aI={name:x0,logger:"error"},cI={database:":memory:"},fI="crypto",z2="client_ed25519_seed",uI=ne.ONE_DAY,hI="keychain",dI="0.3",lI="messages",pI="0.3",gI=ne.SIX_HOURS,mI="publisher",_0="irn",bI="error",dw="wss://relay.walletconnect.org",vI="relayer",Ut={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},yI="_subscription",mr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},wI=.1;var Ql="2.17.1";var We={link_mode:"link_mode",relay:"relay"},xI="0.3",_I="WALLETCONNECT_CLIENT_ID",j2="WALLETCONNECT_LINK_MODE_APPS",yi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var EI="subscription",SI="0.3",II=ne.FIVE_SECONDS*1e3,AI="pairing",TI="0.3";var ja={wc_pairingDelete:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:0},res:{ttl:ne.ONE_DAY,prompt:!1,tag:0}}},vn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Or={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},MI="history",RI="0.3",PI="expirer",Zt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},NI="0.3";var CI="verify-api",DI="https://verify.walletconnect.com",lw="https://verify.walletconnect.org",yo=lw,OI=`${yo}/v3`,LI=[DI,lw],FI="echo",UI="https://echo.walletconnect.com";var Lr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},wi={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},br={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},yn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},wn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},wo={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},qI=.1,BI="event-client",kI=86400,zI="https://pulse.walletconnect.org/batch";function jI(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var D=k-O;D!==k&&B[D]===0;)D++;for(var W=f.repeat(R);D>>0,k=new Uint8Array(U);A[R];){var B=t[A.charCodeAt(R)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,R++}if(A[R]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var D=new Uint8Array(O+(U-L)),W=O;L!==U;)D[W++]=k[L++];return D}}}function I(A){var R=S(A);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var KI=jI,VI=KI,pw=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},$I=r=>new TextEncoder().encode(r),HI=r=>new TextDecoder().decode(r),Zl=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},e0=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return gw(this,e)}},t0=class{constructor(e){this.decoders=e}or(e){return gw(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},gw=(r,e)=>new t0({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),r0=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Zl(e,t,i),this.decoder=new e0(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},bu=({name:r,prefix:e,encode:t,decode:i})=>new r0(r,e,t,i),$a=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=VI(t,e);return bu({prefix:r,name:e,encode:i,decode:s=>pw(n(s))})},GI=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},WI=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<bu({prefix:e,name:r,encode(n){return WI(n,i,t)},decode(n){return GI(n,i,t,r)}}),JI=bu({prefix:"\0",name:"identity",encode:r=>HI(r),decode:r=>$I(r)}),YI=Object.freeze({__proto__:null,identity:JI}),XI=It({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),QI=Object.freeze({__proto__:null,base2:XI}),ZI=It({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),eA=Object.freeze({__proto__:null,base8:ZI}),tA=$a({prefix:"9",name:"base10",alphabet:"0123456789"}),rA=Object.freeze({__proto__:null,base10:tA}),iA=It({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),nA=It({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),sA=Object.freeze({__proto__:null,base16:iA,base16upper:nA}),oA=It({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),aA=It({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cA=It({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fA=It({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uA=It({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hA=It({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dA=It({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),lA=It({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),pA=It({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),gA=Object.freeze({__proto__:null,base32:oA,base32upper:aA,base32pad:cA,base32padupper:fA,base32hex:uA,base32hexupper:hA,base32hexpad:dA,base32hexpadupper:lA,base32z:pA}),mA=$a({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bA=$a({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),vA=Object.freeze({__proto__:null,base36:mA,base36upper:bA}),yA=$a({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wA=$a({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),xA=Object.freeze({__proto__:null,base58btc:yA,base58flickr:wA}),_A=It({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),EA=It({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),SA=It({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),IA=It({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),AA=Object.freeze({__proto__:null,base64:_A,base64pad:EA,base64url:SA,base64urlpad:IA}),mw=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),TA=mw.reduce((r,e,t)=>(r[t]=e,r),[]),MA=mw.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function RA(r){return r.reduce((e,t)=>(e+=TA[t],e),"")}function PA(r){let e=[];for(let t of r){let i=MA[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var NA=bu({prefix:"\u{1F680}",name:"base256emoji",encode:RA,decode:PA}),CA=Object.freeze({__proto__:null,base256emoji:NA}),DA=bw,K2=128,OA=127,LA=~OA,FA=Math.pow(2,31);function bw(r,e,t){e=e||[],t=t||0;for(var i=t;r>=FA;)e[t++]=r&255|K2,r/=128;for(;r&LA;)e[t++]=r&255|K2,r>>>=7;return e[t]=r|0,bw.bytes=t-i+1,e}var UA=i0,qA=128,V2=127;function i0(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw i0.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&V2)<=qA);return i0.bytes=s-i,t}var BA=Math.pow(2,7),kA=Math.pow(2,14),zA=Math.pow(2,21),jA=Math.pow(2,28),KA=Math.pow(2,35),VA=Math.pow(2,42),$A=Math.pow(2,49),HA=Math.pow(2,56),GA=Math.pow(2,63),WA=function(r){return r(vw.encode(r,e,t),e),H2=r=>vw.encodingLength(r),n0=(r,e)=>{let t=e.byteLength,i=H2(r),n=i+H2(t),s=new Uint8Array(n+t);return $2(r,s,0),$2(t,s,i),s.set(e,n),new s0(r,t,e,s)},s0=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},yw=({name:r,code:e,encode:t})=>new o0(r,e,t),o0=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?n0(this.code,t):t.then(i=>n0(this.code,i))}else throw Error("Unknown type, must be binary type")}},ww=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),YA=yw({name:"sha2-256",code:18,encode:ww("SHA-256")}),XA=yw({name:"sha2-512",code:19,encode:ww("SHA-512")}),QA=Object.freeze({__proto__:null,sha256:YA,sha512:XA}),xw=0,ZA="identity",_w=pw,eT=r=>n0(xw,_w(r)),tT={code:xw,name:ZA,encode:_w,digest:eT},rT=Object.freeze({__proto__:null,identity:tT});new TextEncoder,new TextDecoder;var G2={...YI,...QI,...eA,...rA,...sA,...gA,...vA,...xA,...AA,...CA};({...QA,...rT});function iT(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Ew(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var W2=Ew("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yl=Ew("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=iT(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=wt(t,this.name)}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,hl(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?dl(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},c0=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=fI,this.randomSessionIdentifier=$f(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=ad(n);return rf(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=dy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=ad(s),a=this.randomSessionIdentifier;return await F1(a,n,uI,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let a=this.getPrivateKey(n),f=ly(a,s);return this.setSymKey(f,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||fo(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let a=xl(o),f=cr(s);if(El(a))return my(f,o?.encoding);if(_l(a)){let S=a.senderPublicKey,I=a.receiverPublicKey;n=await this.generateSharedKey(S,I)}let u=this.getSymKey(n),{type:g,senderPublicKey:y}=a;return gy({type:g,symKey:u,message:f,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let a=wy(s,o);if(El(a)){let f=vy(s,o?.encoding);return ei(f)}if(_l(a)){let f=a.receiverPublicKey,u=a.senderPublicKey;n=await this.generateSharedKey(f,u)}try{let f=this.getSymKey(n),u=by({symKey:f,encoded:s,encoding:o?.encoding});return ei(u)}catch(f){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(f)}},this.getPayloadType=(n,s=mi)=>{let o=uo({encoded:n,encoding:s});return fn(o.type)},this.getPayloadSenderPublicKey=(n,s=mi)=>{let o=uo({encoded:n,encoding:s});return o.senderPublicKey?rt(o.senderPublicKey,Dt):void 0},this.core=e,this.logger=wt(t,this.name),this.keychain=i||new a0(this.core,this.logger)}get context(){return Tt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(z2)}catch{e=$f(),await this.keychain.set(z2,e)}return sT(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},f0=class extends Oc{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=lI,this.version=pI,this.initialized=!1,this.storagePrefix=xi,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=Nr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=Nr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=wt(e,this.name),this.core=t}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,hl(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?dl(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},u0=class extends Lc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new zi.EventEmitter,this.name=mI,this.queue=new Map,this.publishTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.failedPublishTimeout=(0,ne.toMiliseconds)(ne.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let a=s?.ttl||gI,f=Hf(s),u=s?.prompt||!1,g=s?.tag||0,y=s?.id||Cr().toString(),S={topic:i,message:n,opts:{ttl:a,relay:f,prompt:u,tag:g,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${g}`,A=Date.now(),R,O=1;try{for(;R===void 0;){if(Date.now()-A>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:O},`publisher.publish - attempt ${O}`),R=await await os(this.rpcPublish(i,n,a,f,u,g,y,s?.attestation).catch(N=>this.logger.warn(N)),this.publishTimeout,I),O++,R||await new Promise(N=>setTimeout(N,this.failedPublishTimeout))}this.relayer.events.emit(Ut.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw N;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=wt(t,this.name),this.registerEventListeners()}get context(){return Tt(this.logger)}rpcPublish(e,t,i,n,s,o,a,f){var u,g,y,S;let I={method:ho(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:f},id:a};return St((u=I.params)==null?void 0:u.prompt)&&((g=I.params)==null||delete g.prompt),St((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(zn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ut.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ut.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},h0=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},oT=Object.defineProperty,aT=Object.defineProperties,cT=Object.getOwnPropertyDescriptors,J2=Object.getOwnPropertySymbols,fT=Object.prototype.hasOwnProperty,uT=Object.prototype.propertyIsEnumerable,Y2=(r,e,t)=>e in r?oT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ka=(r,e)=>{for(var t in e||(e={}))fT.call(e,t)&&Y2(r,t,e[t]);if(J2)for(var t of J2(e))uT.call(e,t)&&Y2(r,t,e[t]);return r},Xl=(r,e)=>aT(r,cT(e)),d0=class extends qc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new h0,this.events=new zi.EventEmitter,this.name=EI,this.version=SI,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=xi,this.subscribeTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=Hf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let a=new ne.Watch;a.start(n);let f=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(f),a.stop(n),s(!0)),a.elapsed(n)>=II&&(clearInterval(f),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=wt(t,this.name),this.clientId=""}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=Hf(i);await this.rpcUnsubscribe(e,t,n);let s=ke("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===We.relay&&await this.restartToComplete();let s={method:ho(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let a=Nr(e+this.clientId);if(i?.transportType===We.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},(0,ne.toMiliseconds)(ne.ONE_SECOND)),a;let f=await os(this.relayer.request(s).catch(u=>this.logger.warn(u)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!f&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return f?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ut.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:ho(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await os(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:ho(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await os(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:ho(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Xl(Ka({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,Ka({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,Ka({},t)),this.topicMap.set(t.topic,e),this.events.emit(yi.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(yi.deleted,Xl(Ka({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(yi.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);hn(t)&&this.onBatchSubscribe(t.map((i,n)=>Xl(Ka({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(zn.pulse,async()=>{await this.checkPending()}),this.events.on(yi.created,async e=>{let t=yi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(yi.deleted,async e=>{let t=yi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},hT=Object.defineProperty,X2=Object.getOwnPropertySymbols,dT=Object.prototype.hasOwnProperty,lT=Object.prototype.propertyIsEnumerable,Q2=(r,e,t)=>e in r?hT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Z2=(r,e)=>{for(var t in e||(e={}))dT.call(e,t)&&Q2(r,t,e[t]);if(X2)for(var t of X2(e))lT.call(e,t)&&Q2(r,t,e[t]);return r},l0=class extends Fc{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new zi.EventEmitter,this.name=vI,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ne.toMiliseconds)(ne.THIRTY_SECONDS+ne.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||Cr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let a=await new Promise(async(f,u)=>{let g=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(mr.disconnect,g);let y=await o;this.provider.off(mr.disconnect,g),f(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Ia())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ut.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Ut.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(mr.payload,this.onPayloadHandler),this.provider.on(mr.connect,this.onConnectHandler),this.provider.on(mr.disconnect,this.onDisconnectHandler),this.provider.on(mr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?wt(e.logger,this.name):(0,Go.default)(Jo({level:e.logger||bI})),this.messages=new f0(this.logger,e.core),this.subscriber=new d0(this,this.logger),this.publisher=new u0(this,this.logger),this.relayUrl=e?.relayUrl||dw,this.projectId=e.projectId,this.bundleId=Zv(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return Tt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:We.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",f,u=g=>{g.topic===e&&(this.subscriber.off(yi.created,u),f())};return await Promise.all([new Promise(g=>{f=g,this.subscriber.on(yi.created,u)}),new Promise(async(g,y)=>{a=await this.subscriber.subscribe(e,Z2({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||a,g()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await os(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(mr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(mr.disconnect,n),await os(this.provider.connect(),(0,ne.toMiliseconds)(ne.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Nl())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=ut(ne.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ut.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Ia())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new nu(new su(ey({sdkVersion:Ql,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),go(e)){if(!e.method.endsWith(yI))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,a={topic:i,message:n,publishedAt:s,transportType:We.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Z2({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else gn(e)&&this.events.emit(Ut.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ut.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=po(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(mr.payload,this.onPayloadHandler),this.provider.off(mr.connect,this.onConnectHandler),this.provider.off(mr.disconnect,this.onDisconnectHandler),this.provider.off(mr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Nl();qy(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ut.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ne.toMiliseconds)(wI))))}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},pT=Object.defineProperty,ew=Object.getOwnPropertySymbols,gT=Object.prototype.hasOwnProperty,mT=Object.prototype.propertyIsEnumerable,tw=(r,e,t)=>e in r?pT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rw=(r,e)=>{for(var t in e||(e={}))gT.call(e,t)&&tw(r,t,e[t]);if(ew)for(var t of ew(e))mT.call(e,t)&&tw(r,t,e[t]);return r},_i=class extends Uc{constructor(e,t,i,n=xi,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=xI,this.cached=[],this.initialized=!1,this.storagePrefix=xi,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!St(o)?this.map.set(this.getKey(o),o):Sy(o)?this.map.set(o.id,o):Iy(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(f=>(0,cw.default)(a[f],o[f]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let f=rw(rw({},this.getData(o)),a);this.map.set(o,f),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=wt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},p0=class{constructor(e,t){this.core=e,this.logger=t,this.name=AI,this.version=TI,this.events=new zi.default,this.initialized=!1,this.storagePrefix=xi,this.ignoredPayloadTypes=[Pr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=$f(),s=await this.core.crypto.setSymKey(n),o=ut(ne.FIVE_MINUTES),a={protocol:_0},f={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},u=Il({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(vn.create,f),this.core.expirer.set(s,o),await this.pairings.set(s,f),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Lr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:a,expiryTimestamp:f,methods:u}=Sl(i.uri);n.props.properties.topic=s,n.addTrace(Lr.pairing_uri_validation_success),n.addTrace(Lr.pairing_uri_not_expired);let g;if(this.pairings.keys.includes(s)){if(g=this.pairings.get(s),n.addTrace(Lr.existing_pairing),g.active)throw n.setError(wi.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Lr.pairing_not_expired)}let y=f||ut(ne.FIVE_MINUTES),S={topic:s,relay:a,expiry:y,active:!1,methods:u};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(Lr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(vn.create,S),n.addTrace(Lr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Lr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(wi.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(I){throw n.setError(wi.subscribe_pairing_topic_failure),I}return n.addTrace(Lr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=ut(ne.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:f}=qi();this.events.once(Fe("pairing_ping",s),({error:u})=>{u?f(u):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ke("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:a}=i,f=this.core.crypto.keychain.get(n);return Il({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:f,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{let o=Dr(n,s),a=await this.core.crypto.encode(i,o),f=ja[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,f),o.id},this.sendResult=async(i,n,s)=>{let o=po(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=ja[f.request.method].res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=as(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=ja[f.request.method]?ja[f.request.method].res:ja.unregistered_method.res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ke("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>gi(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(vn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{Qt(n)?this.events.emit(Fe("pairing_ping",s),{}):Lt(n)&&this.events.emit(Fe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(vn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let a=ke("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ke("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Ot(i)){let{message:a}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(wi.malformed_pairing_uri),new Error(a)}if(!Ey(i.uri)){let{message:a}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(wi.malformed_pairing_uri),new Error(a)}let o=Sl(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(wi.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(wi.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0,ne.toMiliseconds)(o?.expiryTimestamp){if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!et(i,!1)){let{message:n}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(gi(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=wt(t,this.name),this.pairings=new _i(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Tt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ut.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===We.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{go(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):gn(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Zt.expired,async e=>{let{topic:t}=Kf(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(vn.expire,{topic:t}))})}},g0=class extends Dc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new zi.EventEmitter,this.name=MI,this.version=RI,this.cached=[],this.initialized=!1,this.storagePrefix=xi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:ut(ne.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Or.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Lt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Or.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Or.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:Dr(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Or.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Or.created,e=>{let t=Or.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.updated,e=>{let t=Or.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.deleted,e=>{let t=Or.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(zn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,ne.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Or.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},m0=class extends Bc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new zi.EventEmitter,this.name=PI,this.version=NI,this.cached=[],this.initialized=!1,this.storagePrefix=xi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Zt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Zt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return ry(e);if(typeof e=="number")return iy(e);let{message:t}=Q("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Zt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,ne.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Zt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(zn.pulse,()=>this.checkExpirations()),this.events.on(Zt.created,e=>{let t=Zt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Zt.expired,e=>{let t=Zt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Zt.deleted,e=>{let t=Zt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},b0=class extends kc{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=CI,this.verifyUrlV3=OI,this.storagePrefix=xi,this.version=hw,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ne.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!so()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:a}=n,f=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{let u=(0,fw.getDocument)(),g=this.startAbortTimer(ne.ONE_SECOND*5),y=await new Promise((S,I)=>{let A=()=>{window.removeEventListener("message",O),u.body.removeChild(R),I("attestation aborted")};this.abortController.signal.addEventListener("abort",A);let R=u.createElement("iframe");R.src=f,R.style.display="none",R.addEventListener("error",A,{signal:this.abortController.signal});let O=N=>{if(N.data&&typeof N.data=="string")try{let U=JSON.parse(N.data);if(U.type==="verify_attestation"){if(Bs(U.attestation).payload.id!==o)return;clearInterval(g),u.body.removeChild(R),this.abortController.signal.removeEventListener("abort",A),window.removeEventListener("message",O),S(U.attestation===null?"":U.attestation)}}catch(U){this.logger.warn(U)}};u.body.appendChild(R),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Bs(s).payload.id!==a)return;let u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;let f=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,f)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(ne.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=n=>{let s=n||yo;return LI.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${yo}`),s=yo),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(ne.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=xy(n,s.publicKey),a={hasExpired:(0,ne.toMiliseconds)(o.exp)this.abortController.abort(),(0,ne.toMiliseconds)(e))}},v0=class extends zc{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=FI,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,f=`${UI}/${this.projectId}/clients`;await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})},this.logger=wt(t,this.context)}},bT=Object.defineProperty,iw=Object.getOwnPropertySymbols,vT=Object.prototype.hasOwnProperty,yT=Object.prototype.propertyIsEnumerable,nw=(r,e,t)=>e in r?bT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Va=(r,e)=>{for(var t in e||(e={}))vT.call(e,t)&&nw(r,t,e[t]);if(iw)for(var t of iw(e))yT.call(e,t)&&nw(r,t,e[t]);return r},y0=class extends jc{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=BI,this.storagePrefix=xi,this.storageVersion=qI,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Ta())try{let n={eventId:pl(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:ul(this.core.relayer.protocol,this.core.relayer.version,Ql)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:a,trace:f}}=n,u=pl(),g=this.core.projectId||"",y=Date.now(),S=Va({eventId:u,timestamp:y,props:{event:s,type:o,properties:{topic:a,trace:f}},bundleId:g,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let a=Array.from(this.events.values()).find(f=>f.props.properties.topic===o);if(a)return Va(Va({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(zn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,ne.fromMiliseconds)(Date.now())-(0,ne.fromMiliseconds)(n.timestamp)>kI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Va(Va({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${zI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ql}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>oo().url,this.logger=wt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},wT=Object.defineProperty,sw=Object.getOwnPropertySymbols,xT=Object.prototype.hasOwnProperty,_T=Object.prototype.propertyIsEnumerable,ow=(r,e,t)=>e in r?wT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,aw=(r,e)=>{for(var t in e||(e={}))xT.call(e,t)&&ow(r,t,e[t]);if(sw)for(var t of sw(e))_T.call(e,t)&&ow(r,t,e[t]);return r},w0=class r extends Cc{constructor(e){var t;super(e),this.protocol=uw,this.version=hw,this.name=x0,this.events=new zi.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:f})=>{if(!o||!a)return;let u={topic:o,message:a,publishedAt:Date.now(),transportType:We.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:f})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||dw,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Jo({level:typeof e?.logger=="string"&&e.logger?e.logger:aI.logger}),{logger:n,chunkLoggerController:s}=Ag({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=wt(n,this.name),this.heartbeat=new _c,this.crypto=new c0(this,this.logger,e?.keychain),this.history=new g0(this,this.logger),this.expirer=new m0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Ic(aw(aw({},cI),e?.storageOptions)),this.relayer=new l0({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new p0(this,this.logger),this.verify=new b0(this,this.logger,this.storage),this.echoClient=new v0(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new y0(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(_I,i),t}get context(){return Tt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(j2,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(j2)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},Sw=w0;var wu=Be(kn()),qe=Be(Ts());var Mw="wc",Rw=2,Pw="client",D0=`${Mw}@${Rw}:${Pw}:`,E0={name:Pw,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var Iw="WALLETCONNECT_DEEPLINK_CHOICE";var ET="proposal";var ST="Proposal expired",IT="session",xo=qe.SEVEN_DAYS,AT="engine",vt={wc_sessionPropose:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:qe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:qe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1119}}},S0={min:qe.FIVE_MINUTES,max:qe.SEVEN_DAYS},Ei={idle:"IDLE",active:"ACTIVE"},TT="request",MT=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],RT="wc";var PT="auth",NT="authKeys",CT="pairingTopics",DT="requests",xu=`${RT}@${1.5}:${PT}:`,vu=`${xu}:PUB_KEY`,OT=Object.defineProperty,LT=Object.defineProperties,FT=Object.getOwnPropertyDescriptors,Aw=Object.getOwnPropertySymbols,UT=Object.prototype.hasOwnProperty,qT=Object.prototype.propertyIsEnumerable,Tw=(r,e,t)=>e in r?OT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e)=>{for(var t in e||(e={}))UT.call(e,t)&&Tw(r,t,e[t]);if(Aw)for(var t of Aw(e))qT.call(e,t)&&Tw(r,t,e[t]);return r},Fr=(r,e)=>LT(r,FT(e)),I0=class extends Vc{constructor(e){super(e),this.name=AT,this.events=new wu.default,this.initialized=!1,this.requestQueue={state:Ei.idle,queue:[]},this.sessionRequestQueue={state:Ei.idle,queue:[]},this.requestQueueDelay=qe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(vt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=Fr(st({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:f}=i,u=n,g,y=!1;try{u&&(y=this.client.core.pairing.pairings.get(u).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),B}if(!u||!y){let{topic:B,uri:j}=await this.client.core.pairing.create();u=B,g=j}if(!u){let{message:B}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(B)}let S=await this.client.core.crypto.generateKeyPair(),I=vt.wc_sessionPropose.req.ttl||qe.FIVE_MINUTES,A=ut(I),R=st({requiredNamespaces:s,optionalNamespaces:o,relays:f??[{protocol:_0}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:A,pairingTopic:u},a&&{sessionProperties:a}),{reject:O,resolve:N,done:U}=qi(I,ST);this.events.once(Fe("session_connect"),async({error:B,session:j})=>{if(B)O(B);else if(j){j.self.publicKey=S;let V=Fr(st({},j),{pairingTopic:R.pairingTopic,requiredNamespaces:R.requiredNamespaces,optionalNamespaces:R.optionalNamespaces,transportType:We.relay});await this.client.session.set(j.topic,V),await this.setExpiry(j.topic,j.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(V),N(V)}});let k=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:R,throwOnFailedPublish:!0});return await this.setProposal(k,st({id:k},R)),{uri:g,approval:U}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[br.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(D){throw o.setError(yn.no_internet_connection),D}try{await this.isValidProposalId(t?.id)}catch(D){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(yn.proposal_not_found),D}try{await this.isValidApprove(t)}catch(D){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(yn.session_approve_namespace_validation_failure),D}let{id:a,relayProtocol:f,namespaces:u,sessionProperties:g,sessionConfig:y}=t,S=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:A,requiredNamespaces:R,optionalNamespaces:O}=S,N=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});N||(N=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:br.session_approve_started,properties:{topic:I,trace:[br.session_approve_started,br.session_namespaces_validation_success]}}));let U=await this.client.core.crypto.generateKeyPair(),k=A.publicKey,B=await this.client.core.crypto.generateSharedKey(U,k),j=st(st({relay:{protocol:f??"irn"},namespaces:u,controller:{publicKey:U,metadata:this.client.metadata},expiry:ut(xo)},g&&{sessionProperties:g}),y&&{sessionConfig:y}),V=We.relay;N.addTrace(br.subscribing_session_topic);try{await this.client.core.relayer.subscribe(B,{transportType:V})}catch(D){throw N.setError(yn.subscribe_session_topic_failure),D}N.addTrace(br.subscribe_session_topic_success);let L=Fr(st({},j),{topic:B,requiredNamespaces:R,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:A.publicKey,metadata:A.metadata},controller:U,transportType:We.relay});await this.client.session.set(B,L),N.addTrace(br.store_session);try{N.addTrace(br.publishing_session_settle),await this.sendRequest({topic:B,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(D=>{throw N?.setError(yn.session_settle_publish_failure),D}),N.addTrace(br.session_settle_publish_success),N.addTrace(br.publishing_session_approve),await this.sendResult({id:a,topic:I,result:{relay:{protocol:f??"irn"},responderPublicKey:U},throwOnFailedPublish:!0}).catch(D=>{throw N?.setError(yn.session_approve_publish_failure),D}),N.addTrace(br.session_approve_publish_success)}catch(D){throw this.client.logger.error(D),this.client.session.delete(B,ke("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(B),D}return this.client.core.eventClient.deleteEvent({eventId:N.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:A.metadata}),await this.client.proposal.delete(a,ke("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(B,ut(xo)),{topic:B,acknowledged:()=>Promise.resolve(this.client.session.get(B))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:vt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:a}=qi(),f=bi(),u=Cr().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Fe("session_update",f),({error:y})=>{y?a(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:f,relayRpcId:u}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:g}),a(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(f){throw this.client.logger.error("extend() -> isValidExtend() failed"),f}let{topic:i}=t,n=bi(),{done:s,resolve:o,reject:a}=qi();return this.events.once(Fe("session_extend",n),({error:f})=>{f?a(f):o()}),await this.setExpiry(i,ut(xo)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(f=>{a(f)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(A){throw this.client.logger.error("request() -> isValidRequest() failed"),A}let{chainId:i,request:n,topic:s,expiry:o=vt.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(s);a?.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let f=bi(),u=Cr().toString(),{done:g,resolve:y,reject:S}=qi(o,"Request expired. Please try again.");this.events.once(Fe("session_request",f),({error:A,result:R})=>{A?S(A):y(R)});let I=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return I?(await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(A=>S(A)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),await g()):await Promise.all([new Promise(async A=>{await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(R=>S(R)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),A()}),new Promise(async A=>{var R;if(!((R=a.sessionConfig)!=null&&R.disableDeepLink)){let O=await sy(this.client.core.storage,Iw);await ny({id:f,topic:s,wcDeepLink:O})}A()}),g()]).then(A=>A[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Qt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Lt(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=bi(),s=Cr().toString(),{done:o,resolve:a,reject:f}=qi();this.events.once(Fe("session_ping",n),({error:u})=>{u?f(u):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=Cr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ke("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>_y(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?We.link_mode:We.relay;o===We.relay&&await this.confirmOnlineStateOrThrow();let{chains:a,statement:f="",uri:u,domain:g,nonce:y,type:S,exp:I,nbf:A,methods:R=[],expiry:O}=t,N=[...t.resources||[]],{topic:U,uri:k}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:U,uri:k}});let B=await this.client.core.crypto.generateKeyPair(),j=fo(B);if(await Promise.all([this.client.auth.authKeys.set(vu,{responseTopic:j,publicKey:B}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:U})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${U}`),R.length>0){let{namespace:v}=Sa(a[0]),h=cy(v,"request",R);Ra(N)&&(h=fy(h,N.pop())),N.push(h)}let V=O&&O>vt.wc_sessionAuthenticate.req.ttl?O:vt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:a,statement:f,aud:u,domain:g,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:A,resources:N},requester:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(V)},D={eip155:{chains:a,methods:[...new Set(["personal_sign",...R])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:D,relays:[{protocol:"irn"}],pairingTopic:U,proposer:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(vt.wc_sessionPropose.req.ttl)},{done:P,resolve:l,reject:w}=qi(V,"Request expired"),p=async({error:v,session:h})=>{if(this.events.off(Fe("session_request",d),c),v)w(v);else if(h){h.self.publicKey=B,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:h.peer.metadata});let _=this.client.session.get(h.topic);await this.deleteProposal(b),l({session:_})}},c=async v=>{var h,_,T;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),v.error){let q=ke("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return v.error.code===q.code?void 0:(this.events.off(Fe("session_connect"),p),w(v.error.message))}await this.deleteProposal(b),this.events.off(Fe("session_connect"),p);let{cacaos:m,responder:M}=v.result,z=[],E=[];for(let q of m){await ml({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(ke("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,Y=Ra(K.resources),H=[Vf(K.iss)],$=Ma(K.iss);if(Y){let ee=vl(Y),G=yl(Y);z.push(...ee),H.push(...G)}for(let ee of H)E.push(`${ee}:${$}`)}let C=await this.client.core.crypto.generateSharedKey(B,M.publicKey),F;z.length>0&&(F={topic:C,acknowledged:!0,self:{publicKey:B,metadata:this.client.metadata},peer:M,controller:M.publicKey,expiry:ut(xo),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:U,namespaces:Al([...new Set(z)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(C,{transportType:o}),await this.client.session.set(C,F),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:M.metadata}),F=this.client.session.get(C)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(_=M.metadata.redirect)!=null&&_.linkMode&&(T=M.metadata.redirect)!=null&&T.universal&&i&&(this.client.core.addLinkModeSupportedApp(M.metadata.redirect.universal),this.client.session.update(C,{transportType:We.link_mode})),l({auths:m,session:F})},d=bi(),b=bi();this.events.once(Fe("session_connect"),p),this.events.once(Fe("session_request",d),c);let x;try{if(s){let v=Dr("wc_sessionAuthenticate",L,d);this.client.core.history.set(U,v);let h=await this.client.core.crypto.encode("",v,{type:co,encoding:ao});x=Na(i,U,h)}else await Promise.all([this.sendRequest({topic:U,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:U,method:"wc_sessionPropose",params:W,expiry:vt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(v){throw this.events.off(Fe("session_connect"),p),this.events.off(Fe("session_request",d),c),v}return await this.setProposal(b,st({id:b},W)),await this.setAuthRequest(d,{request:Fr(st({},L),{verifyContext:{}}),pairingTopic:U,transportType:o}),{uri:x??k,response:P}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[wn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(wo.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(wo.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let a=o.transportType||We.relay;a===We.relay&&await this.confirmOnlineStateOrThrow();let f=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),g=fo(f),y={type:Pr,receiverPublicKey:f,senderPublicKey:u},S=[],I=[];for(let O of n){if(!await ml({cacao:O,projectId:this.client.core.projectId})){s.setError(wo.invalid_cacao);let j=ke("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:g,error:j,encodeOpts:y}),new Error(j.message)}s.addTrace(wn.cacaos_verified);let{p:N}=O,U=Ra(N.resources),k=[Vf(N.iss)],B=Ma(N.iss);if(U){let j=vl(U),V=yl(U);S.push(...j),k.push(...V)}for(let j of k)I.push(`${j}:${B}`)}let A=await this.client.core.crypto.generateSharedKey(u,f);s.addTrace(wn.create_authenticated_session_topic);let R;if(S?.length>0){R={topic:A,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:f,metadata:o.requester.metadata},controller:f,expiry:ut(xo),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Al([...new Set(S)],[...new Set(I)]),transportType:a},s.addTrace(wn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(A,{transportType:a})}catch(O){throw s.setError(wo.subscribe_authenticated_session_topic_failure),O}s.addTrace(wn.subscribe_authenticated_session_topic_success),await this.client.session.set(A,R),s.addTrace(wn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(wn.publishing_authenticated_session_approve);try{await this.sendResult({topic:g,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(O){throw s.setError(wo.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:R}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),f=fo(o),u={type:Pr,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:f,error:n,encodeOpts:u,rpcOpts:vt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return bl(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=t,{self:f}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ke("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(f.publicKey)&&await this.client.core.crypto.deleteKeyPair(f.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Iw).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,ke("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Ei.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(yn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,ke("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=Ei.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,ut(vt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=We.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,a=s.request.expiryTimestamp||ut(vt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:f,throwOnFailedPublish:u,appLink:g}=t,y=Dr(n,s,f),S,I=!!g;try{let O=I?ao:mi;S=await this.client.core.crypto.encode(i,y,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let A;if(MT.includes(n)){let O=Nr(JSON.stringify(y)),N=Nr(S);A=await this.client.core.verify.register({id:N,decryptedId:O})}let R=vt[n].req;if(R.attestation=A,o&&(R.ttl=o),a&&(R.id=a),this.client.core.history.set(i,y),I){let O=Na(g,i,S);await global.Linking.openURL(O,this.client.name)}else{let O=vt[n].req;o&&(O.ttl=o),a&&(O.id=a),u?(O.internal=Fr(st({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(N=>this.client.logger.error(N))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:f}=t,u=po(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ao:mi;g=await this.client.core.crypto.encode(n,u,Fr(st({},a||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Na(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=vt[S.request.method].res;o?(I.internal=Fr(st({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,I)):this.client.core.relayer.publish(n,g,I).catch(A=>this.client.logger.error(A))}await this.client.core.history.resolve(u)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:f}=t,u=as(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ao:mi;g=await this.client.core.crypto.encode(n,u,Fr(st({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Na(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=a||vt[S.request.method].res;this.client.core.relayer.publish(n,g,I)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;gi(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{gi(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Ei.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Ei.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Ei.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=t,f=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:f}))switch(f){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${f}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:a,id:f}=n;try{let u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(st({},n.params));let g=a.expiryTimestamp||ut(vt.wc_sessionPropose.req.ttl),y=st({id:f,pairingTopic:i,expiryTimestamp:g},a);await this.setProposal(f,y);let S=await this.getVerifyContext({attestationId:s,hash:Nr(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&u?.setError(wi.proposal_listener_not_found),u?.addTrace(Lr.emit_session_proposal),this.client.events.emit("session_proposal",{id:f,params:y,verifyContext:S})}catch(u){await this.sendError({id:f,topic:i,error:u,rpcOpts:vt.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(Qt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});let f=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:f});let u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});let g=await this.client.core.crypto.generateSharedKey(f,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});let y=await this.client.core.relayer.subscribe(g,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(Lt(i)){await this.client.proposal.delete(s,ke("USER_DISCONNECTED"));let o=Fe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Fe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:a,expiry:f,namespaces:u,sessionProperties:g,sessionConfig:y}=i.params,S=Fr(st(st({topic:t,relay:o,expiry:f,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},g&&{sessionProperties:g}),y&&{sessionConfig:y}),{transportType:We.relay}),I=Fe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Fe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;Qt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Fe("session_approve",n),{})):Lt(i)&&(await this.client.session.delete(t,ke("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,a=un.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:ke("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(st({topic:t},n));try{un.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(f){throw un.delete(o),f}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Fe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qt(i)?this.events.emit(Fe("session_update",n),{}):Lt(i)&&this.events.emit(Fe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,ut(xo)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Fe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qt(i)?this.events.emit(Fe("session_extend",n),{}):Lt(i)&&this.events.emit(Fe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Fe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Qt(i)?this.events.emit(Fe("session_ping",n),{}):Lt(i)&&this.events.emit(Fe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ut.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:ke("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:a,attestation:f,encryptedId:u,transportType:g}=t,{id:y,params:S}=a;try{await this.isValidRequest(st({topic:o},S));let I=this.client.session.get(o),A=await this.getVerifyContext({attestationId:f,hash:Nr(JSON.stringify(Dr("wc_sessionRequest",S,y))),encryptedId:u,metadata:I.peer.metadata,transportType:g}),R={id:y,topic:o,params:S,verifyContext:A};await this.setPendingSessionRequest(R),g===We.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(R):(this.addSessionRequestToSessionRequestQueue(R),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Fe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,a=un.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(st({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),un.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Qt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:a,transportType:f}=t;try{let{requester:u,authPayload:g,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:Nr(JSON.stringify(s)),encryptedId:a,metadata:u.metadata,transportType:f}),I={requester:u,pairingTopic:n,id:s.id,authPayload:g,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:f}),f===We.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(u){this.client.logger.error(u);let g=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,f),I={type:Pr,receiverPublicKey:g,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:I,rpcOpts:vt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Ei.idle,this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,a=Fe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Fe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Ei.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Ei.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Dr("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(f)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=t;if(St(i)||await this.isValidPairingTopic(i),!Ry(a,!0)){let{message:f}=Q("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(f)}!St(n)&&Ca(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!St(s)&&Ca(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),St(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=My(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Ot(t))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let a=this.client.proposal.get(i),f=Gf(n,"approve()");if(f)throw new Error(f.message);let u=Pl(a.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!et(s,!0)){let{message:g}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}St(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Ot(t)){let{message:s}=Q("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Ny(n)){let{message:s}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Ot(t)){let{message:u}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(u)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Ml(i)){let{message:u}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}let a=Ay(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);let f=Gf(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(gi(o)){let{message:u}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(f)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=Gf(n,"update()");if(o)throw new Error(o.message);let a=Pl(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(f)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:a}=this.client.session.get(i);if(!Rl(a,s)){let{message:f}=Q("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!Cy(n)){let{message:f}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(f)}if(!Ly(a,s,n.method)){let{message:f}=Q("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(f)}if(o&&!Uy(o,S0)){let{message:f}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${S0.min} and ${S0.max}`);throw new Error(f)}},this.isValidRespond=async t=>{var i;if(!Ot(t)){let{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!Dy(s)){let{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Ot(t)){let{message:a}=Q("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!Rl(o,s)){let{message:a}=Q("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Oy(n)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!Fy(o,s,n.name)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!et(n,!1))throw new Error("uri is required parameter");if(!et(s,!1))throw new Error("domain is required parameter");if(!et(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(f=>Sa(f).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:a}=Sa(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=t,f={verified:{verifyUrl:o.verifyUrl||yo,validation:"UNKNOWN",origin:o.url||""}};try{if(a===We.link_mode){let g=this.getAppLinkIfEnabled(o,a);return f.verified.validation=g&&new URL(g).origin===new URL(o.url).origin?"VALID":"INVALID",f}let u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(f.verified.origin=u.origin,f.verified.isScam=u.isScam,f.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(f)}`),f},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!et(n,!1)){let{message:s}=Q("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,a,f,u,g,y,S;return!t||i!==We.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((u=(f=this.client.metadata)==null?void 0:f.redirect)==null?void 0:u.universal)!==""&&((g=t?.redirect)==null?void 0:g.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=ll(t,"topic")||"",n=decodeURIComponent(ll(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:We.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Ta()||ss()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ut.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(vu)?this.client.auth.authKeys.get(vu):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===We.link_mode?ao:mi});try{go(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:n,transportType:s,encryptedId:Nr(i)})):gn(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:s}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:s})}catch(f){this.client.logger.error(f)}}registerExpirerEvents(){this.client.core.expirer.on(Zt.expired,async e=>{let{topic:t,id:i}=Kf(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(vn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(vn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=Q("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=Q("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(et(e,!1)){let{message:t}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Py(e)){let{message:t}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},A0=class extends _i{constructor(e,t){super(e,t,ET,D0),this.core=e,this.logger=t}},T0=class extends _i{constructor(e,t){super(e,t,IT,D0),this.core=e,this.logger=t}},M0=class extends _i{constructor(e,t){super(e,t,TT,D0,i=>i.id),this.core=e,this.logger=t}},R0=class extends _i{constructor(e,t){super(e,t,NT,xu,()=>vu),this.core=e,this.logger=t}},P0=class extends _i{constructor(e,t){super(e,t,CT,xu),this.core=e,this.logger=t}},N0=class extends _i{constructor(e,t){super(e,t,DT,xu,i=>i.id),this.core=e,this.logger=t}},C0=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new R0(this.core,this.logger),this.pairingTopics=new P0(this.core,this.logger),this.requests=new N0(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},yu=class r extends Kc{constructor(e){super(e),this.protocol=Mw,this.version=Rw,this.name=E0.name,this.events=new wu.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||E0.name,this.metadata=e?.metadata||oo(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,Go.default)(Jo({level:e?.logger||E0.logger}));this.core=e?.core||new Sw(e),this.logger=wt(t,this.name),this.session=new T0(this.core,this.logger),this.proposal=new A0(this.core,this.logger),this.pendingRequest=new M0(this.core,this.logger),this.engine=new I0(this),this.auth=new C0(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return Tt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};function O0(r,e){let t=[...Np,...e?.methods??[]];e?.methods?.includes("mvx_signLoginToken")||t.push("mvx_signLoginToken");let i=[`${wr}:${r}`],n=e?.events??[];return{requiredNamespaces:{[wr]:{methods:t,chains:i,events:n}}}}function L0(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=e.find(O0(r)).filter(i=>i.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw"WalletConnect Session is not connected",new Error("WalletConnect Session is not connected")}function ji(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=L0(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function Nw(r){return!!r}function F0(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function U0({transaction:r,response:e}){if(!e)throw"WalletConnect could not sign the transactions. Invalid signatures",new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,a=r.guardian;if(a&&a!==o)throw"WalletConnect: Invalid Guardian",new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=Gt(t),i&&(r.guardianSignature=Gt(i)),r}function Cw(r){if(r)return{...r,url:oo().url}}async function Dw(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var er=class{constructor(e,t,i,n,s){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.options=s}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:Cw(this.options?.metadata)}:{},t=await yu.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=O0(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await Dw(Pp);let i=F0(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||ji(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:ke("USER_DISCONNECTED")});else{let t=ji(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:ke("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new Wt({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=yt.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return U0({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return yt.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];U0({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=ji(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?Nw(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=F0(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&ji(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=L0(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!hn(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var q0=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},tr=class r{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:Ip,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(i=>{setTimeout(()=>{window.location.href=e,i(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:Ap,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let i=this.buildWalletUrl({endpoint:Rp,callbackUrl:t?.callbackUrl,params:{message:$i(e.data)}});return await this.redirect(i),i}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1),t=Gu(e);if((t.status?.toString()||"")!=="signed")throw new uc;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Mp,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(Tp,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=Gu(e.slice(1));return r.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,Oo)&&e[Oo]===nc}getTxSignReturnValue(e){let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let s of t)if(!e[s]||!Array.isArray(e[s]))throw new Uo;let i=e.nonce.length;for(let s of t)if(e[s].length!==i)throw new Uo;let n=[];for(let s=0;s{let a=r.prepareWalletTransaction(o);for(let f in a)Object.prototype.hasOwnProperty.call(a,f)&&!Object.prototype.hasOwnProperty.call(n,f)&&(n[f]=[]),n[f].push(a[f])});let s=this.buildWalletUrl({endpoint:e,callbackUrl:i?.callbackUrl,params:n});window.location.href=s}};var B0=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},_o=class{constructor(e){this.config=Object.assign(new B0,e)}getToken(e,t,i){let n=this.encodeValue(e),s=this.encodeValue(t);return`${n}.${s}.${i}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),i=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${i}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(o=>o.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(rc(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var _u=(r,e)=>t=>{let i=t.data;try{i=Wu()&&typeof i=="string"?JSON.parse(i):i}catch{console.error("error parsing eventData",i)}let{type:n,payload:s}=i;!Wu()&&t.origin!=Do()||!(r===n||n==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",_u(r,e)),e({type:n,payload:s}))};var xn=class r{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",_u("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:i}=e.payload;if(i||!t)throw new Error("Unable to re-login");let{accessToken:n}=t;return n?(this.account=t,n):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(s=>yt.transactionToPlainObject(s))}),{data:i,error:n}=t.payload;if(n||!i)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return i.map(s=>yt.plainObjectToTransaction(s))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:$i(e.data)}}),{data:i,error:n}=t.payload;return n||!i?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(this.cancelAction(),null):i.status!=="signed"?(console.error("Could not sign message"),null):new Wt({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:Gt(i.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),Do()):t.parent&&t.parent.postMessage(e,Do())),await this.waitingForResponse(Cp[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",_u(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return r._instance||(r._instance=new r(e)),r._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var te=class{static set(e,t){if(!e)return;let i={...this.events,[e]:t};this.events=i}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var Ur=(U=>(U.onLoginStart="onLoginStart",U.onLoginSuccess="onLoginSuccess",U.onLoginFailure="onLoginFailure",U.onLogoutStart="onLogoutStart",U.onLogoutSuccess="onLogoutSuccess",U.onLogoutFailure="onLogoutFailure",U.onQrPending="onQrPending",U.onQrLoaded="onQrLoaded",U.onTxStart="onTxStart",U.onTxSent="onTxSent",U.onTxFinalized="onTxFinalized",U.onTxFailure="onTxFailure",U.onSignMsgStart="onSignMsgStart",U.onSignMsgFinalized="onSignMsgFinalized",U.onSignMsgFailure="onSignMsgFailure",U.onQueryStart="onQueryStart",U.onQueryFinalized="onQueryFinalized",U.onQueryFailure="onQueryFailure",U))(Ur||{}),_n=(o=>(o.ledger="ledger",o.mobile="mobile",o.webWallet="web-wallet",o.browserExtension="browser-extension",o.xAlias="x-alias",o.webview="webview",o))(_n||{}),k0=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(k0||{}),z0=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(z0||{});var ot=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);var Eo=async r=>{if(!r.dappProvider)throw new Error("Logout failed: There is no active session!");te.run("onLogoutStart");try{let e=await r.dappProvider.logout();return e&&(re.clear(),te.run("onLogoutSuccess")),e}catch(e){let t=ot(e);`${t}`,te.run("onLogoutFailure",t)}};function Eu(r){return r[Math.floor(Math.random()*r.length)]}var Ow=async r=>{if(!r.initOptions.walletConnectV2ProjectId||!r.initOptions.chainType)return;let e={onClientLogin:()=>{},onClientLogout:()=>Eo(r),onClientEvent:n=>{}},t=Eu(r.initOptions.walletConnectV2RelayAddresses),i=new er(e,At[r.initOptions.chainType].shortId,t,r.initOptions.walletConnectV2ProjectId);try{return await i.init(),i}catch{}};var $t=r=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(r)}};var j0=async(r,e)=>{let t=$t("signature"),i=$t("address"),n=re.get("address"),s=re.get("loginToken");if(t&&re.set("signature",t),i||n){i&&(re.set("address",i),window.history.replaceState(null,"",window.location.pathname));let o=new tr(`${r}${Wi}`);if(t&&e&&i){let f=new _o({apiUrl:e,origin:window.location.origin}).getToken(i,s,t);re.set("accessToken",f)}return o}};var Su=class r{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new r("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var Iu=class{constructor({apiUrl:e,chainType:t,apiTimeout:i}){this.chainType=t||dc,this.apiUrl=e||At[this.chainType]?.apiAddress,this.apiTimeout=i||At[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let i=new AbortController,n=setTimeout(()=>i.abort(),this.apiTimeout),s={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:i.signal};try{let o=await fetch(this.apiUrl+"/"+e,Object.assign(s,t||{})),a=await o.json();if(!o.ok){let f=a?.error||o.status;return clearTimeout(n),Promise.reject(f)}return clearTimeout(n),a}catch(o){this.handleApiError(o,e)}}}async apiPost(e,t,i){if(typeof fetch<"u"){let n=new AbortController,s=setTimeout(()=>n.abort(),this.apiTimeout),o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:n.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(o,i||{})),f=await a.json();if(!a.ok){let u=f?.error||a.status;return clearTimeout(s),Promise.reject(u)}return clearTimeout(s),f}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let i=e.response.data,n=i.error||i.message||JSON.stringify(i);throw new Error(n)}async sendTransaction(e){let t=yt.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),i=new Su(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:qn(t.data||""),status:i,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!i.isPending()}}async queryContract({address:e,func:t,args:i,value:n,caller:s}){try{let o={scAddress:e,caller:s,funcName:t,value:n,args:()=>i?.map(f=>rc(f))},a=await this.apiPost("query",o);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(o){this.handleApiError(o,"query")}}};var So=()=>new Date().setHours(new Date().getHours()+24),Au=r=>Date.now()>r;var ds=async r=>{let e=re.get("address"),t=re.get("expires");if(!(t&&Au(t))&&e&&r.networkProvider){let n=new Si(e);try{let s=await r.networkProvider.getAccount(e),o=await r.networkProvider.getGuardianData(e);re.set("address",e),re.set("activeGuardian",o.guarded&&o.activeGuardian?.address?o.activeGuardian.address:""),re.set("nonce",s.nonce.valueOf()),re.set("balance",s.balance.toString()),n.update(s)}catch(s){`${ot(s)}`}}};var Lw=async(r,e,t,i="/")=>{let n=await lc(),o={callbackUrl:encodeURIComponent(`${window.location.origin}${i}`),token:e};try{if(n&&!await n.login(o))throw new Error("There were problems while logging in!")}catch(u){let g=ot(u);throw new Error(g)}if(!n)throw new Error("There were problems with auth provider initialization!");let a=n.getAccount();re.set("loginToken",e);let f=a?.signature;if(f&&re.set("signature",f),r.networkProvider&&f)try{let u=await n.getAddress();if(!u)throw new Error("Canceled!");re.set("address",u),re.set("loginMethod","browser-extension"),re.set("expires",So()),await ds(r);let g=t.getToken(u,e,f);return re.set("accessToken",g),te.run("onLoginSuccess"),n}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var F3=Be(L3(),1);var DM=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},OM=r=>{let e=`${Op}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},LM=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},FM=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},dp={},UM=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",dp[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:dp[r.topic].signal}),t},qu={},qM=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=UM(r,e);return i.appendChild(s),qu[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:qu[r.topic].signal}),i},BM=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},kM=r=>{if(!r)return;document.getElementById(r)?.remove()},zM=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),jM=async r=>r?await(0,F3.toString)(r,{type:"svg"}):void 0,U3=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=await jM(e),o;if(s&&(o=DM(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),zM()&&n.appendChild(OM(e))),n&&t instanceof er){let a=t.pairings,f=async g=>{try{g&&(await t.logout({topic:g}),kM(g))}catch(y){`${ot(y)}`}finally{qu[g].abort()}},u=async g=>{try{let{approval:y}=await t.connect({topic:g,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(g)?.after(BM()),await t.login({approval:y,token:i})}catch(y){`${ot(y)}`}finally{for(let y of Object.values(qu))y?.abort();for(let y of Object.values(dp))y?.abort()}};if(a&&a.length>0){let g=LM();n.appendChild(g);let y=FM();g.appendChild(y);for(let S of a){let I=qM(S,f,u);g.appendChild(I)}}}return n};var q3=async(r,e,t,i)=>{if(!i)throw new Error("You haven't provided the QR code container DOM element id");let n=Eu(r.initOptions.walletConnectV2RelayAddresses);if(!n||!r.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!r.initOptions.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!r.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let s,o={onClientLogin:async()=>{if(r.dappProvider instanceof er){let f=await r.dappProvider.getAddress(),u=await r.dappProvider.getSignature();re.set("address",f),re.set("loginMethod","mobile"),re.set("expires",So()),await ds(r),u&&re.set("signature",u),re.set("loginToken",e);let g=t.getToken(f,e,u);re.set("accessToken",g),te.run("onLoginSuccess"),s?.replaceChildren()}},onClientLogout:async()=>{r.dappProvider instanceof er&&await Eo(r)},onClientEvent:f=>{}},a=new er(o,At[r.initOptions.chainType].shortId,n,r.initOptions.walletConnectV2ProjectId);try{if(a){r.dappProvider=a,te.run("onQrPending"),await a.init();let{uri:f,approval:u}=await a.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),g=e?`${f}&token=${e}`:f;return i&&g&&(s=await U3(i,g,a,e),te.run("onQrLoaded")),await a.login({approval:u,token:e}),a}}catch(f){let u=ot(f);`${u}`,te.run("onLoginFailure",u)}};var lp=async(r,e,t,i)=>{let n=new tr(`${r}${Wi}`),o={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${i||"/"}`):"/",token:e};try{return re.set("loginMethod",At[t].xAliasAddress===r?"x-alias":"web-wallet"),await n.login(o),re.set("expires",So()),re.set("loginToken",e),n}catch(a){let f=ot(a);`${f}`,re.set("loginMethod",""),te.run("onLoginFailure",f)}};var Bu=async(r,e)=>{te.run("onTxSent",r);let i=await new qo(e).awaitCompleted(r.txHash),n=i.sender,s=new Si(n),o=await e.getAccount(n);s.update(o),re.set("address",s.bech32()),re.set("balance",s.balance),te.run("onTxFinalized",i)};var ku=r=>{let e=r.sender,t=new Si(e),i=r.nonce.valueOf();t.incrementNonce(),re.set("nonce",(i+1n).toString())};var B3=async(r,e,t,i)=>{if($t(Oo)===nc&&r&&e){let s=re.get("activeGuardian"),o=re.get("loginMethod"),a=$t("hasWebWalletGuardianSign"),f;if("getTransactionsFromWalletUrl"in r){if(f=r.getTransactionsFromWalletUrl()?.[0],!f)return;o==="web-wallet"&&(f.data=Hi(f.data))}else s&&o!=="web-wallet"&&o!=="x-alias"&&a&&(f=new tr(`${t}${Wi}`).getTransactionsFromWalletUrl()?.[0]);if(f){let u=yt.plainObjectToTransaction(f);u.nonce=BigInt(i),ku(u);try{te.run("onTxStart",u);let g=await e.sendTransaction(u);await Bu(g,e)}catch(g){let S=`Getting transaction information failed! ${ot(g)}`;throw te.run("onTxFailure",u,S),new Error(S)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var k3=r=>{let e=re.get("activeGuardian");return e&&(r.version=ic,r.options=_p,r.guardian=e),r},z3=async(r,e)=>{let t=new tr(`${e}${Wi}`),i=window?.location.href,n=new URL(i);n.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([r],{callbackUrl:encodeURIComponent(n.toString())})},j3=r=>{let e=re.get("activeGuardian");return!(!re.get("address")||!e||r.isGuardedTransaction())};var K3=()=>{let r=!$t("walletProviderStatus"),e=$t("status")==="signed",t=$t("message"),i=$t("signature");r&&e&&t&&i&&(te.run("onSignMsgFinalized",t,i),window.history.replaceState(null,"",window.location.pathname))};function KM(r){try{let e=atob(r),t=btoa(e),i=Co(r),n=Hi(i),s=r===t||t.startsWith(r),o=r===n||n.startsWith(r);if(s&&o)return!0}catch{return!1}return!1}function Po(r){return KM(r)?atob(r):r}var zu=r=>Object.prototype.toString.call(r)==="[object String]";var V3=r=>{if(!r||!zu(r))return null;let e=r.split(".");if(e.length!==4)return null;try{let[t,i,n,s]=e,o=JSON.parse(Po(s)),a=Po(t);return{ttl:Number(n),extraInfo:o,origin:a,blockHash:i}}catch(t){return console.error(`Error trying to decode ${r}:`,t),null}};var $3=r=>{if(!r||!zu(r))return null;let e=r.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,i,n]=e,s=Po(t),o=Po(i),a=V3(o);if(!a)return{address:s,body:o,signature:n,blockHash:"",origin:"",ttl:0};let f={...a,address:s,body:o,signature:n};return a.extraInfo?.timestamp||delete f.extraInfo,f}catch{return null}};function H3(r,e){let t=$3(r);if(t==null)return;let{signature:i,address:n,body:s}=t;i&&r&&n&&(re.set("loginToken",s),re.set("accessToken",r),re.set("signature",i),re.set("address",n),re.set("loginMethod","webview"),e.dappProvider=new xn)}var G3=r=>{r.onLoginStart&&te.set("onLoginStart",r.onLoginStart),r.onLoginSuccess&&te.set("onLoginSuccess",r.onLoginSuccess),r.onLoginFailure&&te.set("onLoginFailure",r.onLoginFailure),r.onLogoutStart&&te.set("onLogoutStart",r.onLogoutStart),r.onLogoutSuccess&&te.set("onLogoutSuccess",r.onLogoutSuccess),r.onLogoutFailure&&te.set("onLogoutFailure",r.onLogoutFailure),r.onQrPending&&te.set("onQrPending",r.onQrPending),r.onQrLoaded&&te.set("onQrLoaded",r.onQrLoaded),r.onTxStart&&te.set("onTxStart",r.onTxStart),r.onTxSent&&te.set("onTxSent",r.onTxSent),r.onTxFinalized&&te.set("onTxFinalized",r.onTxFinalized),r.onTxFailure&&te.set("onTxFailure",r.onTxFailure),r.onSignMsgStart&&te.set("onSignMsgStart",r.onSignMsgStart),r.onSignMsgFinalized&&te.set("onSignMsgFinalized",r.onSignMsgFinalized),r.onSignMsgFailure&&te.set("onSignMsgFailure",r.onSignMsgFailure),r.onQueryStart&&te.set("onQueryStart",r.onQueryStart),r.onQueryFinalized&&te.set("onQueryFinalized",r.onQueryFinalized),r.onQueryFailure&&te.set("onQueryFailure",r.onQueryFailure)};var ju=async r=>{te.run("onLoginStart");try{await r(()=>{te.run("onLoginSuccess")})}catch(e){let t=ot(e);`${t}`,te.run("onLoginFailure",t)}};var bs=class bs{static async init(e){let t=re.get();if(t.expires&&Au(t.expires)){re.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:dc,apiUrl:Dp,apiTimeout:1e4,walletConnectV2ProjectId:"",walletConnectV2RelayAddresses:Lp,...e},this.networkProvider=new Iu(this.initOptions),G3(this.initOptions);let i=$t("accessToken");i&&await ju(async s=>{H3(i,this),await ds(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&$t("address"))&&t?.loginMethod&&(await ju(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await lc()),t.loginMethod==="mobile"&&(this.dappProvider=await Ow(this)),t.loginMethod==="webview"&&(this.dappProvider=new xn),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await j0(At[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await j0(At[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await ds(this),s()}),this.initOptions?.chainType&&(await B3(this.dappProvider,this.networkProvider,At[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),K3()))}static async login(e,t){if(!Object.values(_n).includes(e)){let n="Wrong login method!";throw te.run("onLoginFailure",n),new Error(n)}if(!this.networkProvider){let n="Login failed: Use ElvenJs.init() first!";throw te.run("onLoginFailure",n),new Error(n)}await ju(async()=>{let n=new _o({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),s=await n.initialize();if(e==="browser-extension"){let o=await Lw(this,s,n,t?.callbackRoute);this.dappProvider=o}if(e==="mobile"){let o=await q3(this,s,n,t?.qrCodeContainer);this.dappProvider=o}if(e==="web-wallet"&&this.initOptions?.chainType){let o=await lp(At[this.initOptions.chainType].walletAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}if(e==="x-alias"&&this.initOptions?.chainType){let o=await lp(At[this.initOptions.chainType].xAliasAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}})}static async logout(){try{let e=await Eo(this);return this.dappProvider=void 0,e}catch(e){let t=ot(e)}}static async signAndSendTransaction(e){if(!this.dappProvider){let i="Transaction signing failed: There is no active session!";throw te.run("onTxFailure",e,i),new Error(i)}if(!this.networkProvider){let i="Transaction signing failed: There is no active network provider!";throw te.run("onTxFailure",e,i),new Error(i)}let t=k3(e);try{te.run("onTxStart",e);let i=re.get();if(e.nonce=i.nonce,this.dappProvider instanceof Bn&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof er&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof xn&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof tr&&await this.dappProvider.signTransaction(e),i.loginMethod!=="web-wallet"&&i.loginMethod!=="x-alias"){let n=j3(t);if(n||ku(t),n&&this.initOptions?.chainType){await z3(t,At[this.initOptions.chainType].walletAddress);return}let s=await this.networkProvider.sendTransaction(t);await Bu(s,this.networkProvider)}}catch(i){let n=ot(i);throw te.run("onTxFailure",t,`Getting transaction information failed! ${n}`),new Error(`Getting transaction information failed! ${n}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let n="Message signing failed: There is no active session!";throw te.run("onSignMsgFailure",e,n),new Error(n)}if(!this.networkProvider){let n="Message signing failed: There is no active network provider!";throw te.run("onSignMsgFailure",e,n),new Error(n)}let i="";try{if(te.run("onSignMsgStart",e),this.dappProvider instanceof Bn){let s=await this.dappProvider.signMessage(new Wt({data:Vi(e)}));s?.signature&&(i=ar(s.signature))}if(this.dappProvider instanceof er){let s=await this.dappProvider.signMessage(new Wt({data:Vi(e)}));s?.signature&&(i=ar(s.signature))}if(this.dappProvider instanceof xn){let s=await this.dappProvider.signMessage(new Wt({data:Vi(e)}));s?.signature&&(i=ar(s.signature))}if(this.dappProvider instanceof tr){let s=a=>encodeURIComponent(a).replace(/[!'()*]/g,f=>`%${f.charCodeAt(0).toString(16).toUpperCase()}`),o=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new Wt({data:Vi(e)}),{callbackUrl:encodeURIComponent(`${o}${o.includes("?")?"&":"?"}message=${s(e)}`)})}let n=re.get();return n.loginMethod!=="web-wallet"&&n.loginMethod!=="x-alias"&&te.run("onSignMsgFinalized",e,i),{message:e,messageSignature:i}}catch(n){let s=ot(n);throw te.run("onSignMsgFailure",e,s),new Error(`Message signing failed! ${s}`)}}static async queryContract({address:e,func:t,args:i=[],value:n=0,caller:s}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let o={address:e,func:t,args:i,value:n,caller:s};try{te.run("onQueryStart",o);let a=await this.networkProvider.queryContract(o);return te.run("onQueryFinalized",a),a}catch(a){let f=ot(a);throw te.run("onQueryFinalized",o,f),new Error(`Smart contract query failed! ${f}`)}}};bs.storage=re,bs.destroy=()=>{bs.networkProvider=void 0,bs.dappProvider=void 0,bs.initOptions=void 0,te.clear()};var pp=bs;var VM=({amount:r,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=r.toString().replace(/,/g,""),[i,n=""]=t.split("."),s=i+n.padEnd(e,"0");return s=s.substring(0,i.length+e),BigInt(s)},W3=({amount:r,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let i=BigInt(r)<0n,n=BigInt(r).toString();i&&(n=n.slice(1)),n=n.padStart(e+1,"0");let s=n.slice(0,-e),o=n.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),g=BigInt(r)+u;return i&&(g=-g),W3({amount:g,decimals:e,rounding:t})}}let a=`${s}.${o.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),i&&(a=`-${a}`),a};export{Si as Account,k0 as DappCoreWCV2CustomMethodsEnum,pp as ElvenJS,Ur as EventStoreEvents,_n as LoginMethodsEnum,Lo as Transaction,qo as TransactionWatcher,z0 as WebWalletUrlParamsEnum,W3 as formatAmount,VM as parseAmount}; +/** keccak.js https://github.com/adraffy/keccak.js @license MIT */ +/** https://github.com/emn178/js-sha3/blob/master/src/sha3.js @license MIT */ /*! Bundled license information: tslib/tslib.es6.js: diff --git a/demo-app/mobile-signing-provider.js b/demo-app/mobile-signing-provider.js new file mode 100644 index 0000000..66228aa --- /dev/null +++ b/demo-app/mobile-signing-provider.js @@ -0,0 +1,9 @@ +/*! + * Portions of this code are derived from MultiversX libraries. + * These portions are licensed under the MIT License. + * + * See the MultiversX repository for details: https://github.com/multiversx + * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE + */ + +var o=()=>(n=>1+n)(2),r=o;export{r as default}; diff --git a/dev-server.mjs b/dev-server.js similarity index 94% rename from dev-server.mjs rename to dev-server.js index 93d6440..f33306a 100644 --- a/dev-server.mjs +++ b/dev-server.js @@ -3,7 +3,7 @@ import http from 'http'; const server = http.createServer((request, response) => { return handler(request, response, { - public: 'apps/demo-app', + public: 'demo-app', headers: [ { source: '**/*', diff --git a/package-lock.json b/package-lock.json index c353a96..d65d8a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "eslint": "9.14.0", "prettier": "3.3.3", "rimraf": "6.0.1", + "serve-handler": "6.1.6", "turbo": "2.2.3", "typescript": "5.6.3" } @@ -2355,6 +2356,15 @@ "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", "dev": true }, + "node_modules/bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2556,6 +2566,15 @@ "node": "^14.18.0 || >=16.10.0" } }, + "node_modules/content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/cookie-es": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/cookie-es/-/cookie-es-1.2.2.tgz", @@ -3612,6 +3631,27 @@ "node": ">=10.0.0" } }, + "node_modules/mime-db": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "dev": true, + "dependencies": { + "mime-db": "~1.33.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", @@ -3874,6 +3914,12 @@ "node": ">=8" } }, + "node_modules/path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w==", + "dev": true + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -3899,6 +3945,12 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/path-to-regexp": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", + "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==", + "dev": true + }, "node_modules/pathe": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/pathe/-/pathe-1.1.2.tgz", @@ -4061,6 +4113,15 @@ "integrity": "sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==", "dev": true }, + "node_modules/range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha512-kA5WQoNVo4t9lNx2kQNFCxKeBl5IbbSNBl1M/tLkw9WCn+hxNBAW5Qh8gdhs63CJnhjJ2zQWFoqPJP2sK1AV5A==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/readable-stream": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", @@ -4168,6 +4229,21 @@ "node": ">=10" } }, + "node_modules/serve-handler": { + "version": "6.1.6", + "resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.6.tgz", + "integrity": "sha512-x5RL9Y2p5+Sh3D38Fh9i/iQ5ZK+e4xuXRd/pGbM4D13tgo/MGwbttUk8emytcr1YYzBYs+apnUngBDFYfpjPuQ==", + "dev": true, + "dependencies": { + "bytes": "3.0.0", + "content-disposition": "0.5.2", + "mime-types": "2.1.18", + "minimatch": "3.1.2", + "path-is-inside": "1.0.2", + "path-to-regexp": "3.3.0", + "range-parser": "1.2.0" + } + }, "node_modules/set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", diff --git a/package.json b/package.json index e35ed93..66a35b4 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ ], "scripts": { "build": "turbo run build", - "dev": "turbo run dev", + "dev:server": "node dev-server.js", "lint": "turbo run lint", "check-types": "turbo run check-types", "prettier": "turbo run prettier", @@ -23,6 +23,7 @@ "eslint": "9.14.0", "prettier": "3.3.3", "rimraf": "6.0.1", + "serve-handler": "6.1.6", "turbo": "2.2.3", "typescript": "5.6.3" } diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json index 8f3db20..8a7513b 100644 --- a/packages/elven.js/package.json +++ b/packages/elven.js/package.json @@ -15,7 +15,7 @@ "./package.json": "./package.json" }, "scripts": { - "build": "rimraf build && node ./esbuild.config.js && tsc", + "build": "rimraf build && node ./esbuild.config.js && tsc && cp build/elven.js ../../demo-app/elven.js", "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", "prettier": "prettier --write 'src/**/*.{js,ts,json}'", "check-types": "tsc --noEmit", diff --git a/packages/mobile-signing-provider/package.json b/packages/mobile-signing-provider/package.json index 1a547fd..37f7747 100644 --- a/packages/mobile-signing-provider/package.json +++ b/packages/mobile-signing-provider/package.json @@ -15,7 +15,7 @@ "./package.json": "./package.json" }, "scripts": { - "build": "rimraf build && node ./esbuild.config.js && tsc", + "build": "rimraf build && node ./esbuild.config.js && tsc && cp build/mobile-signing-provider.js ../../demo-app/mobile-signing-provider.js", "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", "prettier": "prettier --write 'src/**/*.{js,ts,json}'", "check-types": "tsc --noEmit", diff --git a/packages/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/mobile-signing-provider/src/mobile-signing-provider.ts index e71da89..5cdd43a 100644 --- a/packages/mobile-signing-provider/src/mobile-signing-provider.ts +++ b/packages/mobile-signing-provider/src/mobile-signing-provider.ts @@ -1,5 +1,7 @@ const nothingHereForNow = () => { - console.log('nothing here for now'); + const a = 1; + const add = (b: number) => a + b; + return add(2); }; // SOME comment here lorem ipsum dolor sit amet diff --git a/turbo.json b/turbo.json index af987d6..5de72fa 100644 --- a/turbo.json +++ b/turbo.json @@ -17,10 +17,6 @@ "outputs": [], "cache": true }, - "dev": { - "cache": false, - "persistent": true - }, "check-types": { "cache": true, "outputs": [] From 401eaaf41ebbefecc8c3a6b5249231726eeb9a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 12:57:28 +0100 Subject: [PATCH 05/13] fix building typescript and publishing --- .npmignore | 4 +- README.md | 168 +----------------- configs/tsconfig/base.json | 2 +- .../elven.js/CHANGELOG.md | 0 packages/elven.js/README.md | 167 +++++++++++++++++ packages/elven.js/package.json | 2 +- packages/elven.js/tsconfig.json | 4 + packages/mobile-signing-provider/CHANGELOG.md | 1 + packages/mobile-signing-provider/README.md | 1 + .../mobile-signing-provider/tsconfig.json | 4 + 10 files changed, 184 insertions(+), 169 deletions(-) rename CHANGELOG.md => packages/elven.js/CHANGELOG.md (100%) create mode 100644 packages/elven.js/README.md create mode 100644 packages/mobile-signing-provider/CHANGELOG.md create mode 100644 packages/mobile-signing-provider/README.md diff --git a/.npmignore b/.npmignore index ae184d4..3262ec1 100644 --- a/.npmignore +++ b/.npmignore @@ -1,13 +1,15 @@ -apps +demo-app node_modules src configs .prettierrc .eslintrc .editorconfig +.turbo dev-server.mjs esbuild.config.cjs tsconfig.json meta.txt meta.json eslint.config.mjs +esbuild.config.js diff --git a/README.md b/README.md index ddf4bf3..dff9f19 100644 --- a/README.md +++ b/README.md @@ -1,167 +1,3 @@ -## ElvenJS +## Elven monorepo -### One static file to rule it all on the MultiversX blockchain! - -## Docs -- [www.elvenjs.com](https://www.elvenjs.com) - -## Videos -- [JavaScript browser SDK for MultiversX Blockchain](https://youtu.be/tcTukpkjcQw) - -## Demos -- [elvenjs.netlify.app](https://elvenjs.netlify.app/) - EGLD, ESDT transactions, smart contract queries and transactions -- [elrond-donate-widget-demo.netlify.app](https://multiversx-donate-widget-demo.netlify.app/) - donation-like widget demo -- [StackBlitz vanilla html demo](https://stackblitz.com/edit/web-platform-d4rx5v?file=index.html) -- [StackBlitz Solid.js demo](https://stackblitz.com/edit/vitejs-vite-rbo6du?file=src/App.tsx) -- [StackBlitz React demo](https://stackblitz.com/edit/vitejs-vite-qr2u7l?file=src/App.tsx) -- [StackBlitz Vue demo](https://stackblitz.com/edit/vue-zrb8y5?file=src/App.vue) - -Authenticate, sign and send transactions on the MultiversX blockchain in the browser. No need for bundlers, frameworks, etc. Just attach the script source, and you are ready to go. You can incorporate it into your preferred CMS framework like WordPress or an e-commerce system. Plus, it will also work on a standard static HTML website. - -The primary purpose of this tool is to have a lite script for browser usage where you can authenticate and sign/send transactions on the MultiversX blockchain and do this without any additional build steps. - -The purpose is to simplify the usage for primary use cases and open the doors for many frontend tools and approaches. - -It is a script for browsers incorporates ES6 modules. If you need fully functional JavaScript/Typescript SDK (also in Nodejs), please use [sdk-js](https://docs.multiversx.com/sdk-and-tools/sdk-js/), an official Typescript MultiversX SDK. And if you are React developer, please check the [Nextjs dapp](https://github.com/xdevguild/nextjs-dapp-template). - -**You can use it already, but it is under active development, and the API might change, there could be breaking changes without changing major versions.** - -### How to use it - -Copy and include the `elven.js` script from the `build` directory or the best would be to use CDN (https://unpkg.com/elven.js/build/elven.js). Please don't link the script using the [demo](https://elvenjs.netlify.app/) domain. - -Use module type, like: - -```html - -``` -or from CDN: - -```html - -``` - -### SDK reference - -Please check the docs here: [www.elvenjs.com/docs/sdk-reference.html](https://www.elvenjs.com/docs/sdk-reference.html) - -### Recipes - -Please check how to use it with a couple of recipes here: [www.elvenjs.com/docs/recipes.html](https://www.elvenjs.com/docs/recipes.html) - -Check for more complete examples in the [example/index.html](/example/index.html) - -### Usage example with static website (base demo): - -Check out the example file: [example/index.html](/example/index.html) - -You will find the whole demo there. The same is deployed here: [elvenjs.netlify.app](https://elvenjs.netlify.app) - -### Usage in frontend frameworks - -Elven.js can also be used in many different frameworks by importing it from node_modules (of course, it is a client-side library). When it comes to React/Nextjs, it is advised to use one of the ready templates, for example, the one mentioned above. But Elven.js can be helpful in other frameworks where there are no templates yet. Example: - -```bash -npm install elven.js -``` -and then in your client side framework: -```typescript -import { ElvenJS } from 'elven.js'; -``` - -The types should also be exported. - -### What can it do? - -The API is limited for now, this will change, but even now, it can do most of the core operations: - -- authenticate using the xPortal mobile, MultiversX browser extension, MultiversX Web Wallet and xAlias -- integrate with xPortal Hub -- handle expiration of the auth state -- handle login with tokens to be able to get the signature -- sign transactions -- send transactions (also custom smart contracts) -- sign custom messages -- basic global states handling (local storage) -- basic structures for transaction payload -- sync the network on page load -- querying the smart contracts (without tools for result parsing yet) -- support for guarded transactions using MultiversX 2FA solutions - -### What will it do soon? (TODO): - -- authenticate with Ledger Nano -- result parsing (separate library) -- more advanced global state handling and (real-time updates (if needed)?) -- more structures and simplification for payload builders -- split it into more files/libraries -- make it as small as possible - -### What it won't probably do: - -- crypto tasks -- results parsing (but it will land in a separate package) - -Why? Because it is supposed to be a browser script, it should be as small as possible. All that functionality can be replaced if needed by a custom implementation or other libraries. There will be docs with examples for that. And in the future, there may be more similar libraries, but optional and separated. - -### Development - -1. clone the repo -2. `npm install` dependencies -3. `npm run build` -4. test on example -> `npm run dev:server` -5. rebuild with every change in the script - -To test the MultiversX browser extension you would need to run localhost with SSL. -For quick dev testing tools like [localhost.run](https://localhost.run/) should be enough. -After you run `npm run dev:server`, in separate teriminal window run `ssh -R 80:localhost:3000 localhost.run`. You can also relay on your own SSL setup. - -### Articles - -- [How to Interact With the MultiversX Blockchain in a Simple Static Website](https://hackernoon.com/how-to-interact-with-the-elrond-blockchain-in-a-simple-static-website) -- [How to enable donations on any website using the MultiversX blockchain and EGLD tokens](https://dev.to/juliancwirko/how-to-enable-donations-on-any-website-using-the-elrond-blockchain-and-egld-tokens-3fkf) - -### TODO -- [Kanban board](https://github.com/elven-js/projects/1) - -### Other tools - -If you need to use MultiversX SDK with React-based projects, you can try these tools: - -- [sdk-dapp](https://github.com/multiversx/mx-sdk-dapp) - for standard React-based SPA -- [nextjs-dapp-template](https://github.com/xdevguild/nextjs-dapp-template) - or Nextjs apps -- [useElven](https://www.useelven.com) - React Hooks for interacting with MultiversX blockchain - -If you are interested in creating and managing your own PFP NFT collection, you might be interested in: - -- [Elven Tools](https://www.elven.tools) - What is included: NFT minter smart contract (decentralized way of minting), minter Nextjs dapp (interaction on the frontend side), CLI tool (deploy, configuration, interaction) -- [nft-art-maker](https://github.com/juliancwirko/nft-art-maker) - tool for creating png assets from provided layers. It can also pack files and upload them to IPFS using nft.storage. All CIDs will be auto-updated - -Other tools: - -- [Buildo Begins](https://github.com/xdevguild/buildo-begins) - all MultiversX blockchain CLI interactions with sdk-js, still in progress, but usable -- [Buildo.dev](https://www.buildo.dev) - Buildo.dev is a MultiversX app that helps with blockchain interactions, like issuing tokens and querying smart contracts. +TODO link other readmes diff --git a/configs/tsconfig/base.json b/configs/tsconfig/base.json index e298026..ac64156 100644 --- a/configs/tsconfig/base.json +++ b/configs/tsconfig/base.json @@ -7,7 +7,7 @@ "target": "ES2020", "module": "ES2020", "declaration": true, - "declarationDir": "build/types", + "declarationDir": "./build/types", "emitDeclarationOnly": true, "moduleResolution": "Node", "allowSyntheticDefaultImports": true, diff --git a/CHANGELOG.md b/packages/elven.js/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to packages/elven.js/CHANGELOG.md diff --git a/packages/elven.js/README.md b/packages/elven.js/README.md new file mode 100644 index 0000000..ddf4bf3 --- /dev/null +++ b/packages/elven.js/README.md @@ -0,0 +1,167 @@ +## ElvenJS + +### One static file to rule it all on the MultiversX blockchain! + +## Docs +- [www.elvenjs.com](https://www.elvenjs.com) + +## Videos +- [JavaScript browser SDK for MultiversX Blockchain](https://youtu.be/tcTukpkjcQw) + +## Demos +- [elvenjs.netlify.app](https://elvenjs.netlify.app/) - EGLD, ESDT transactions, smart contract queries and transactions +- [elrond-donate-widget-demo.netlify.app](https://multiversx-donate-widget-demo.netlify.app/) - donation-like widget demo +- [StackBlitz vanilla html demo](https://stackblitz.com/edit/web-platform-d4rx5v?file=index.html) +- [StackBlitz Solid.js demo](https://stackblitz.com/edit/vitejs-vite-rbo6du?file=src/App.tsx) +- [StackBlitz React demo](https://stackblitz.com/edit/vitejs-vite-qr2u7l?file=src/App.tsx) +- [StackBlitz Vue demo](https://stackblitz.com/edit/vue-zrb8y5?file=src/App.vue) + +Authenticate, sign and send transactions on the MultiversX blockchain in the browser. No need for bundlers, frameworks, etc. Just attach the script source, and you are ready to go. You can incorporate it into your preferred CMS framework like WordPress or an e-commerce system. Plus, it will also work on a standard static HTML website. + +The primary purpose of this tool is to have a lite script for browser usage where you can authenticate and sign/send transactions on the MultiversX blockchain and do this without any additional build steps. + +The purpose is to simplify the usage for primary use cases and open the doors for many frontend tools and approaches. + +It is a script for browsers incorporates ES6 modules. If you need fully functional JavaScript/Typescript SDK (also in Nodejs), please use [sdk-js](https://docs.multiversx.com/sdk-and-tools/sdk-js/), an official Typescript MultiversX SDK. And if you are React developer, please check the [Nextjs dapp](https://github.com/xdevguild/nextjs-dapp-template). + +**You can use it already, but it is under active development, and the API might change, there could be breaking changes without changing major versions.** + +### How to use it + +Copy and include the `elven.js` script from the `build` directory or the best would be to use CDN (https://unpkg.com/elven.js/build/elven.js). Please don't link the script using the [demo](https://elvenjs.netlify.app/) domain. + +Use module type, like: + +```html + +``` +or from CDN: + +```html + +``` + +### SDK reference + +Please check the docs here: [www.elvenjs.com/docs/sdk-reference.html](https://www.elvenjs.com/docs/sdk-reference.html) + +### Recipes + +Please check how to use it with a couple of recipes here: [www.elvenjs.com/docs/recipes.html](https://www.elvenjs.com/docs/recipes.html) + +Check for more complete examples in the [example/index.html](/example/index.html) + +### Usage example with static website (base demo): + +Check out the example file: [example/index.html](/example/index.html) + +You will find the whole demo there. The same is deployed here: [elvenjs.netlify.app](https://elvenjs.netlify.app) + +### Usage in frontend frameworks + +Elven.js can also be used in many different frameworks by importing it from node_modules (of course, it is a client-side library). When it comes to React/Nextjs, it is advised to use one of the ready templates, for example, the one mentioned above. But Elven.js can be helpful in other frameworks where there are no templates yet. Example: + +```bash +npm install elven.js +``` +and then in your client side framework: +```typescript +import { ElvenJS } from 'elven.js'; +``` + +The types should also be exported. + +### What can it do? + +The API is limited for now, this will change, but even now, it can do most of the core operations: + +- authenticate using the xPortal mobile, MultiversX browser extension, MultiversX Web Wallet and xAlias +- integrate with xPortal Hub +- handle expiration of the auth state +- handle login with tokens to be able to get the signature +- sign transactions +- send transactions (also custom smart contracts) +- sign custom messages +- basic global states handling (local storage) +- basic structures for transaction payload +- sync the network on page load +- querying the smart contracts (without tools for result parsing yet) +- support for guarded transactions using MultiversX 2FA solutions + +### What will it do soon? (TODO): + +- authenticate with Ledger Nano +- result parsing (separate library) +- more advanced global state handling and (real-time updates (if needed)?) +- more structures and simplification for payload builders +- split it into more files/libraries +- make it as small as possible + +### What it won't probably do: + +- crypto tasks +- results parsing (but it will land in a separate package) + +Why? Because it is supposed to be a browser script, it should be as small as possible. All that functionality can be replaced if needed by a custom implementation or other libraries. There will be docs with examples for that. And in the future, there may be more similar libraries, but optional and separated. + +### Development + +1. clone the repo +2. `npm install` dependencies +3. `npm run build` +4. test on example -> `npm run dev:server` +5. rebuild with every change in the script + +To test the MultiversX browser extension you would need to run localhost with SSL. +For quick dev testing tools like [localhost.run](https://localhost.run/) should be enough. +After you run `npm run dev:server`, in separate teriminal window run `ssh -R 80:localhost:3000 localhost.run`. You can also relay on your own SSL setup. + +### Articles + +- [How to Interact With the MultiversX Blockchain in a Simple Static Website](https://hackernoon.com/how-to-interact-with-the-elrond-blockchain-in-a-simple-static-website) +- [How to enable donations on any website using the MultiversX blockchain and EGLD tokens](https://dev.to/juliancwirko/how-to-enable-donations-on-any-website-using-the-elrond-blockchain-and-egld-tokens-3fkf) + +### TODO +- [Kanban board](https://github.com/elven-js/projects/1) + +### Other tools + +If you need to use MultiversX SDK with React-based projects, you can try these tools: + +- [sdk-dapp](https://github.com/multiversx/mx-sdk-dapp) - for standard React-based SPA +- [nextjs-dapp-template](https://github.com/xdevguild/nextjs-dapp-template) - or Nextjs apps +- [useElven](https://www.useelven.com) - React Hooks for interacting with MultiversX blockchain + +If you are interested in creating and managing your own PFP NFT collection, you might be interested in: + +- [Elven Tools](https://www.elven.tools) - What is included: NFT minter smart contract (decentralized way of minting), minter Nextjs dapp (interaction on the frontend side), CLI tool (deploy, configuration, interaction) +- [nft-art-maker](https://github.com/juliancwirko/nft-art-maker) - tool for creating png assets from provided layers. It can also pack files and upload them to IPFS using nft.storage. All CIDs will be auto-updated + +Other tools: + +- [Buildo Begins](https://github.com/xdevguild/buildo-begins) - all MultiversX blockchain CLI interactions with sdk-js, still in progress, but usable +- [Buildo.dev](https://www.buildo.dev) - Buildo.dev is a MultiversX app that helps with blockchain interactions, like issuing tokens and querying smart contracts. diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json index 8a7513b..730e5c6 100644 --- a/packages/elven.js/package.json +++ b/packages/elven.js/package.json @@ -15,7 +15,7 @@ "./package.json": "./package.json" }, "scripts": { - "build": "rimraf build && node ./esbuild.config.js && tsc && cp build/elven.js ../../demo-app/elven.js", + "build": "rimraf build && node ./esbuild.config.js && tsc --project ./tsconfig.json && cp build/elven.js ../../demo-app/elven.js", "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", "prettier": "prettier --write 'src/**/*.{js,ts,json}'", "check-types": "tsc --noEmit", diff --git a/packages/elven.js/tsconfig.json b/packages/elven.js/tsconfig.json index 6633db5..1c1f647 100644 --- a/packages/elven.js/tsconfig.json +++ b/packages/elven.js/tsconfig.json @@ -1,5 +1,9 @@ { "extends": "../../tsconfig.json", + "compilerOptions": { + "declarationDir": "./build/types", + "outDir": "./build" + }, "include": ["src/**/*"], "exclude": ["node_modules", "build"] } diff --git a/packages/mobile-signing-provider/CHANGELOG.md b/packages/mobile-signing-provider/CHANGELOG.md new file mode 100644 index 0000000..802ac1f --- /dev/null +++ b/packages/mobile-signing-provider/CHANGELOG.md @@ -0,0 +1 @@ +## TODO diff --git a/packages/mobile-signing-provider/README.md b/packages/mobile-signing-provider/README.md new file mode 100644 index 0000000..802ac1f --- /dev/null +++ b/packages/mobile-signing-provider/README.md @@ -0,0 +1 @@ +## TODO diff --git a/packages/mobile-signing-provider/tsconfig.json b/packages/mobile-signing-provider/tsconfig.json index 6633db5..1c1f647 100644 --- a/packages/mobile-signing-provider/tsconfig.json +++ b/packages/mobile-signing-provider/tsconfig.json @@ -1,5 +1,9 @@ { "extends": "../../tsconfig.json", + "compilerOptions": { + "declarationDir": "./build/types", + "outDir": "./build" + }, "include": ["src/**/*"], "exclude": ["node_modules", "build"] } From 4171434f8fbbff2f2350652b1951d4fed9d9111a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 13:02:58 +0100 Subject: [PATCH 06/13] remove script --- demo-app/index.html | 1 - packages/elven.js/CHANGELOG.md | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/demo-app/index.html b/demo-app/index.html index 7526291..8acfbe2 100644 --- a/demo-app/index.html +++ b/demo-app/index.html @@ -23,7 +23,6 @@ - diff --git a/packages/elven.js/CHANGELOG.md b/packages/elven.js/CHANGELOG.md index 334a476..e370ae7 100644 --- a/packages/elven.js/CHANGELOG.md +++ b/packages/elven.js/CHANGELOG.md @@ -3,8 +3,8 @@ - introduce new API (breaking changes) - add esbuild adjustments - elven.js script is now much smaller -- add some most crucial automatic tests -- xPortal and Webview signing providers are now extracted as separate js file to be used as optional signing providers +- add some most crucial automated tests +- xPortal signing provider is now extracted as separate JS file to be used as optional signing providers - ... ### [0.20.0](https://github.com/elven-js/elven.js/releases/tag/v0.20.0) (2024-10-13) From 0dde15a21abdb5d72d8da373ef14b6d17d0a42ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 16:48:40 +0100 Subject: [PATCH 07/13] working version --- TODO.md | 8 +- configs/esbuild/index.js | 2 +- demo-app/elven.js | 60 +------------ demo-app/index.html | 22 +++-- demo-app/mobile-signing-provider.js | 60 ++++++++++++- package-lock.json | 14 +-- packages/elven.js/package.json | 7 +- packages/elven.js/src/main.ts | 66 ++++++++++---- packages/elven.js/src/types.ts | 59 ++++++++++++- packages/elven.js/src/utils/constants.ts | 2 +- packages/mobile-signing-provider/package.json | 10 ++- .../src/components/constants.ts | 7 ++ .../src/components}/init-mobile-provider.ts | 29 ++++--- .../src/components}/login-with-mobile.ts | 44 ++++++---- .../qr-code-and-pairings-builder.ts | 13 ++- .../src/components/types.ts | 67 +++++++++++++++ .../src/components/utils.ts | 26 ++++++ .../src/components}/walletconnect-signing.ts | 41 ++++++--- .../src/components}/walletconnect-utils.ts | 5 +- .../src/mobile-signing-provider.ts | 86 +++++++++++++++++-- 20 files changed, 457 insertions(+), 171 deletions(-) create mode 100644 packages/mobile-signing-provider/src/components/constants.ts rename packages/{elven.js/src/auth => mobile-signing-provider/src/components}/init-mobile-provider.ts (56%) rename packages/{elven.js/src/auth => mobile-signing-provider/src/components}/login-with-mobile.ts (78%) rename packages/{elven.js/src/auth => mobile-signing-provider/src/components}/qr-code-and-pairings-builder.ts (95%) create mode 100644 packages/mobile-signing-provider/src/components/types.ts create mode 100644 packages/mobile-signing-provider/src/components/utils.ts rename packages/{elven.js/src/core => mobile-signing-provider/src/components}/walletconnect-signing.ts (96%) rename packages/{elven.js/src/core => mobile-signing-provider/src/components}/walletconnect-utils.ts (98%) diff --git a/TODO.md b/TODO.md index 587c7aa..3b8399a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,14 +1,12 @@ -- move xPortal integration to separate file - - do a monorepo, mainly for example testing - - the wallet connect dependencies are quite big, there is not much that can be done here - - anyway check what can be done with wallet connect to make it as small as possible +- anyway check what can be done with wallet connect to make it as small as possible +- check and handle all the errors for the mobile provider when the provider is not initialized etc. - add tests for at least most used utilities, maybe some core tools, check tests in MVX SDKs (more tests can be added later) - prepare a new API - for token operations - for smart contracts interactions - the the best would be to pass the arguments as is (always requiring ABI without typed helpers ???) - pass ABI as link to a file or as content or both? - test guardians -- use Knip to detect unused stuff and do the cleanup +- use Knip to detect unused stuff (in both packages) and do the cleanup - test on the testnet - update README and docs and demos - how it is built now diff --git a/configs/esbuild/index.js b/configs/esbuild/index.js index d50b3b5..79883e5 100644 --- a/configs/esbuild/index.js +++ b/configs/esbuild/index.js @@ -17,7 +17,7 @@ export const baseConfig = { target: ['es2020'], banner: { js: banner }, treeShaking: true, - pure: ['console.log', 'console.info', 'console.debug', 'console.warn'], + // pure: ['console.log', 'console.info', 'console.debug', 'console.warn'], sourcemap: false, define: { 'process.env.NODE_ENV': '"production"', diff --git a/demo-app/elven.js b/demo-app/elven.js index 02e0045..c1b025f 100644 --- a/demo-app/elven.js +++ b/demo-app/elven.js @@ -6,64 +6,6 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var J3=Object.create;var tc=Object.defineProperty;var Y3=Object.getOwnPropertyDescriptor;var X3=Object.getOwnPropertyNames;var Q3=Object.getPrototypeOf,Z3=Object.prototype.hasOwnProperty;var gp=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var e6=(r,e)=>()=>(r&&(e=r(r=0)),e);var J=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),qt=(r,e)=>{for(var t in e)tc(r,t,{get:e[t],enumerable:!0})},ec=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of X3(e))!Z3.call(r,n)&&n!==t&&tc(r,n,{get:()=>e[n],enumerable:!(i=Y3(e,n))||i.enumerable});return r},Ht=(r,e,t)=>(ec(r,e,"default"),t&&ec(t,e,"default")),Be=(r,e,t)=>(t=r!=null?J3(Q3(r)):{},ec(e||!r||!r.__esModule?tc(t,"default",{value:r,enumerable:!0}):t,r)),No=r=>ec(tc({},"__esModule",{value:!0}),r);var kn=J((NR,Xu)=>{"use strict";var xs=typeof Reflect=="object"?Reflect:null,Fp=xs&&typeof xs.apply=="function"?xs.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},pc;xs&&typeof xs.ownKeys=="function"?pc=xs.ownKeys:Object.getOwnPropertySymbols?pc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:pc=function(e){return Object.getOwnPropertyNames(e)};var qp=Number.isNaN||function(e){return e!==e};function $e(){$e.init.call(this)}Xu.exports=$e;Xu.exports.once=h6;$e.EventEmitter=$e;$e.prototype._events=void 0;$e.prototype._eventsCount=0;$e.prototype._maxListeners=void 0;var Up=10;function gc(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty($e,"defaultMaxListeners",{enumerable:!0,get:function(){return Up},set:function(r){if(typeof r!="number"||r<0||qp(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Up=r}});$e.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};$e.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||qp(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Bp(r){return r._maxListeners===void 0?$e.defaultMaxListeners:r._maxListeners}$e.prototype.getMaxListeners=function(){return Bp(this)};$e.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")Fp(f,this,t);else for(var u=f.length,g=Vp(f,u),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=o.length}return r}$e.prototype.addListener=function(e,t){return kp(this,e,t,!1)};$e.prototype.on=$e.prototype.addListener;$e.prototype.prependListener=function(e,t){return kp(this,e,t,!0)};function c6(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function zp(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=c6.bind(i);return n.listener=t,i.wrapFn=n,n}$e.prototype.once=function(e,t){return gc(t),this.on(e,zp(this,e,t)),this};$e.prototype.prependOnceListener=function(e,t){return gc(t),this.prependListener(e,zp(this,e,t)),this};$e.prototype.removeListener=function(e,t){var i,n,s,o,a;if(gc(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():f6(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};$e.prototype.off=$e.prototype.removeListener;$e.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function jp(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?u6(n):Vp(n,n.length)}$e.prototype.listeners=function(e){return jp(this,e,!0)};$e.prototype.rawListeners=function(e){return jp(this,e,!1)};$e.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Kp.call(r,e)};$e.prototype.listenerCount=Kp;function Kp(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}$e.prototype.eventNames=function(){return this._eventsCount>0?pc(this._events):[]};function Vp(r,e){for(var t=new Array(e),i=0;iZu,__asyncDelegator:()=>I6,__asyncGenerator:()=>S6,__asyncValues:()=>A6,__await:()=>Bo,__awaiter:()=>v6,__classPrivateFieldGet:()=>P6,__classPrivateFieldSet:()=>N6,__createBinding:()=>w6,__decorate:()=>g6,__exportStar:()=>x6,__extends:()=>l6,__generator:()=>y6,__importDefault:()=>R6,__importStar:()=>M6,__makeTemplateObject:()=>T6,__metadata:()=>b6,__param:()=>m6,__read:()=>Hp,__rest:()=>p6,__spread:()=>_6,__spreadArrays:()=>E6,__values:()=>eh});function l6(r,e){Qu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function p6(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;a--)(o=r[a])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function m6(r,e){return function(t,i){e(t,i,r)}}function b6(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function v6(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(g){try{u(i.next(g))}catch(y){o(y)}}function f(g){try{u(i.throw(g))}catch(y){o(y)}}function u(g){g.done?s(g.value):n(g.value).then(a,f)}u((i=i.apply(r,e||[])).next())})}function y6(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(g){return f([u,g])}}function f(u){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Hp(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function _6(){for(var r=[],e=0;e1||a(S,I)})})}function a(S,I){try{f(i[S](I))}catch(A){y(s[0][3],A)}}function f(S){S.value instanceof Bo?Promise.resolve(S.value.v).then(u,g):y(s[0][2],S)}function u(S){a("next",S)}function g(S){a("throw",S)}function y(S,I){S(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function I6(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Bo(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function A6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof eh=="function"?eh(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(a,f){o=r[s](o),n(a,f,o.done,o.value)})}}function n(s,o,a,f){Promise.resolve(f).then(function(u){s({value:u,done:a})},o)}}function T6(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function M6(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function R6(r){return r&&r.__esModule?r:{default:r}}function P6(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function N6(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var Qu,Zu,Es=e6(()=>{Qu=function(r,e){return Qu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},Qu(r,e)};Zu=function(){return Zu=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});mc.delay=void 0;function C6(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}mc.delay=C6});var Wp=J(Ss=>{"use strict";Object.defineProperty(Ss,"__esModule",{value:!0});Ss.ONE_THOUSAND=Ss.ONE_HUNDRED=void 0;Ss.ONE_HUNDRED=100;Ss.ONE_THOUSAND=1e3});var Jp=J(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.ONE_YEAR=Z.FOUR_WEEKS=Z.THREE_WEEKS=Z.TWO_WEEKS=Z.ONE_WEEK=Z.THIRTY_DAYS=Z.SEVEN_DAYS=Z.FIVE_DAYS=Z.THREE_DAYS=Z.ONE_DAY=Z.TWENTY_FOUR_HOURS=Z.TWELVE_HOURS=Z.SIX_HOURS=Z.THREE_HOURS=Z.ONE_HOUR=Z.SIXTY_MINUTES=Z.THIRTY_MINUTES=Z.TEN_MINUTES=Z.FIVE_MINUTES=Z.ONE_MINUTE=Z.SIXTY_SECONDS=Z.THIRTY_SECONDS=Z.TEN_SECONDS=Z.FIVE_SECONDS=Z.ONE_SECOND=void 0;Z.ONE_SECOND=1;Z.FIVE_SECONDS=5;Z.TEN_SECONDS=10;Z.THIRTY_SECONDS=30;Z.SIXTY_SECONDS=60;Z.ONE_MINUTE=Z.SIXTY_SECONDS;Z.FIVE_MINUTES=Z.ONE_MINUTE*5;Z.TEN_MINUTES=Z.ONE_MINUTE*10;Z.THIRTY_MINUTES=Z.ONE_MINUTE*30;Z.SIXTY_MINUTES=Z.ONE_MINUTE*60;Z.ONE_HOUR=Z.SIXTY_MINUTES;Z.THREE_HOURS=Z.ONE_HOUR*3;Z.SIX_HOURS=Z.ONE_HOUR*6;Z.TWELVE_HOURS=Z.ONE_HOUR*12;Z.TWENTY_FOUR_HOURS=Z.ONE_HOUR*24;Z.ONE_DAY=Z.TWENTY_FOUR_HOURS;Z.THREE_DAYS=Z.ONE_DAY*3;Z.FIVE_DAYS=Z.ONE_DAY*5;Z.SEVEN_DAYS=Z.ONE_DAY*7;Z.THIRTY_DAYS=Z.ONE_DAY*30;Z.ONE_WEEK=Z.SEVEN_DAYS;Z.TWO_WEEKS=Z.ONE_WEEK*2;Z.THREE_WEEKS=Z.ONE_WEEK*3;Z.FOUR_WEEKS=Z.ONE_WEEK*4;Z.ONE_YEAR=Z.ONE_DAY*365});var th=J(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var Yp=(Es(),No(_s));Yp.__exportStar(Wp(),bc);Yp.__exportStar(Jp(),bc)});var Qp=J(Is=>{"use strict";Object.defineProperty(Is,"__esModule",{value:!0});Is.fromMiliseconds=Is.toMiliseconds=void 0;var Xp=th();function D6(r){return r*Xp.ONE_THOUSAND}Is.toMiliseconds=D6;function O6(r){return Math.floor(r/Xp.ONE_THOUSAND)}Is.fromMiliseconds=O6});var eg=J(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var Zp=(Es(),No(_s));Zp.__exportStar(Gp(),vc);Zp.__exportStar(Qp(),vc)});var tg=J(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:!0});ko.Watch=void 0;var yc=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};ko.Watch=yc;ko.default=yc});var rg=J(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});wc.IWatch=void 0;var rh=class{};wc.IWatch=rh});var ig=J(ih=>{"use strict";Object.defineProperty(ih,"__esModule",{value:!0});var L6=(Es(),No(_s));L6.__exportStar(rg(),ih)});var Ts=J(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});var xc=(Es(),No(_s));xc.__exportStar(eg(),As);xc.__exportStar(tg(),As);xc.__exportStar(ig(),As);xc.__exportStar(th(),As)});var yg=J((nP,vg)=>{"use strict";function i5(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}vg.exports=n5;function n5(r,e,t){var i=t&&t.stringify||i5,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var a=1;a-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(g>=f||e[g]==null)break;y=f||e[g]==null)break;y=f||e[g]===void 0)break;y",y=I+2,I++;break}u+=i(e[g]),y=I+2,I++;break;case 115:if(g>=f)break;y{"use strict";var wg=yg();Eg.exports=ti;var $o=p5().console||{},s5={mapHttpRequest:Ac,mapHttpResponse:Ac,wrapRequestSerializer:dh,wrapResponseSerializer:dh,wrapErrorSerializer:dh,req:Ac,res:Ac,err:u5};function o5(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function ti(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||$o;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=o5(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let a=r.level||"info",f=Object.create(t);f.log||(f.log=Ho),Object.defineProperty(f,"levelVal",{get:g}),Object.defineProperty(f,"level",{get:y,set:S});let u={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:h5(r)};f.levels=ti.levels,f.level=a,f.setMaxListeners=f.getMaxListeners=f.emit=f.addListener=f.on=f.prependListener=f.once=f.prependOnceListener=f.removeListener=f.removeAllListeners=f.listeners=f.listenerCount=f.eventNames=f.write=f.flush=Ho,f.serializers=i,f._serialize=n,f._stdErrSerialize=s,f.child=I,e&&(f._logEvent=lh());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(A){if(A!=="silent"&&!this.levels.values[A])throw Error("unknown level "+A);this._level=A,Ms(u,f,"error","log"),Ms(u,f,"fatal","error"),Ms(u,f,"warn","error"),Ms(u,f,"info","log"),Ms(u,f,"debug","log"),Ms(u,f,"trace","log")}function I(A,R){if(!A)throw new Error("missing bindings for child Pino");R=R||{},n&&A.serializers&&(R.serializers=A.serializers);let O=R.serializers;if(n&&O){var N=Object.assign({},i,O),U=r.browser.serialize===!0?Object.keys(N):n;delete A.serializers,Tc([A],U,N,this._stdErrSerialize)}function k(B){this._childLevel=(B._childLevel|0)+1,this.error=Rs(B,A,"error"),this.fatal=Rs(B,A,"fatal"),this.warn=Rs(B,A,"warn"),this.info=Rs(B,A,"info"),this.debug=Rs(B,A,"debug"),this.trace=Rs(B,A,"trace"),N&&(this.serializers=N,this._serialize=U),e&&(this._logEvent=lh([].concat(B._logEvent.bindings,A)))}return k.prototype=this,new k(this)}return f}ti.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};ti.stdSerializers=s5;ti.stdTimeFunctions=Object.assign({},{nullTime:xg,epochTime:_g,unixTime:d5,isoTime:l5});function Ms(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?Ho:n[t]?n[t]:$o[t]||$o[i]||Ho,a5(r,e,t)}function a5(r,e,t){!r.transmit&&e[t]===Ho||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===$o?$o:this;for(var f=0;f-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function Rs(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty($c,"__esModule",{value:!0});$c.BrowserRandomSource=void 0;var Mg=65536,yh=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(wh,"__esModule",{value:!0});function A5(r){for(var e=0;e{});var Pg=J(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});Hc.NodeRandomSource=void 0;var T5=fr(),_h=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof gp<"u"){let e=xh();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});Gc.SystemRandomSource=void 0;var M5=Rg(),R5=Pg(),Eh=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new M5.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new R5.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Gc.SystemRandomSource=Eh});var Cg=J(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});function P5(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Jt.mul=Math.imul||P5;function N5(r,e){return r+e|0}Jt.add=N5;function C5(r,e){return r-e|0}Jt.sub=C5;function D5(r,e){return r<>>32-e}Jt.rotl=D5;function O5(r,e){return r<<32-e|r>>>e}Jt.rotr=O5;function L5(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Jt.isInteger=Number.isInteger||L5;Jt.MAX_SAFE_INTEGER=9007199254740991;Jt.isSafeInteger=function(r){return Jt.isInteger(r)&&r>=-Jt.MAX_SAFE_INTEGER&&r<=Jt.MAX_SAFE_INTEGER}});var Ps=J(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});var Dg=Cg();function F5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Ue.readInt16BE=F5;function U5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Ue.readUint16BE=U5;function q5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Ue.readInt16LE=q5;function B5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Ue.readUint16LE=B5;function Og(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Ue.writeUint16BE=Og;Ue.writeInt16BE=Og;function Lg(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Ue.writeUint16LE=Lg;Ue.writeInt16LE=Lg;function Sh(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Ue.readInt32BE=Sh;function Ih(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Ue.readUint32BE=Ih;function Ah(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Ue.readInt32LE=Ah;function Th(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Ue.readUint32LE=Th;function Wc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Ue.writeUint32BE=Wc;Ue.writeInt32BE=Wc;function Jc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Ue.writeUint32LE=Jc;Ue.writeInt32LE=Jc;function k5(r,e){e===void 0&&(e=0);var t=Sh(r,e),i=Sh(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Ue.readInt64BE=k5;function z5(r,e){e===void 0&&(e=0);var t=Ih(r,e),i=Ih(r,e+4);return t*4294967296+i}Ue.readUint64BE=z5;function j5(r,e){e===void 0&&(e=0);var t=Ah(r,e),i=Ah(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Ue.readInt64LE=j5;function K5(r,e){e===void 0&&(e=0);var t=Th(r,e),i=Th(r,e+4);return i*4294967296+t}Ue.readUint64LE=K5;function Fg(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Wc(r/4294967296>>>0,e,t),Wc(r>>>0,e,t+4),e}Ue.writeUint64BE=Fg;Ue.writeInt64BE=Fg;function Ug(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Jc(r>>>0,e,t),Jc(r/4294967296>>>0,e,t+4),e}Ue.writeUint64LE=Ug;Ue.writeInt64LE=Ug;function V5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Ue.readUintBE=V5;function $5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Ue.writeUintBE=H5;function G5(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Dg.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.randomStringForEntropy=Mt.randomString=Mt.randomUint32=Mt.randomBytes=Mt.defaultRandomSource=void 0;var r4=Ng(),i4=Ps(),qg=fr();Mt.defaultRandomSource=new r4.SystemRandomSource;function Mh(r,e=Mt.defaultRandomSource){return e.randomBytes(r)}Mt.randomBytes=Mh;function n4(r=Mt.defaultRandomSource){let e=Mh(4,r),t=(0,i4.readUint32LE)(e);return(0,qg.wipe)(e),t}Mt.randomUint32=n4;var Bg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function kg(r,e=Bg,t=Mt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Mh(Math.ceil(r*256/s),t);for(let a=0;a0;a++){let f=o[a];f{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});var Cs=Ps(),Ns=fr();Ai.DIGEST_LENGTH=64;Ai.BLOCK_SIZE=128;var jg=function(){function r(){this.digestLength=Ai.DIGEST_LENGTH,this.blockSize=Ai.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Ns.wipe(this._buffer),Ns.wipe(this._tempHi),Ns.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(Rh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=Rh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Ns.wipe(e.stateHi),Ns.wipe(e.stateLo),e.buffer&&Ns.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Ai.SHA512=jg;var zg=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Rh(r,e,t,i,n,s,o){for(var a=t[0],f=t[1],u=t[2],g=t[3],y=t[4],S=t[5],I=t[6],A=t[7],R=i[0],O=i[1],N=i[2],U=i[3],k=i[4],B=i[5],j=i[6],V=i[7],L,D,W,P,l,w,p,c;o>=128;){for(var d=0;d<16;d++){var b=8*d+s;r[d]=Cs.readUint32BE(n,b),e[d]=Cs.readUint32BE(n,b+4)}for(var d=0;d<80;d++){var x=a,v=f,h=u,_=g,T=y,m=S,M=I,z=A,E=R,C=O,F=N,q=U,K=k,Y=B,H=j,$=V;if(L=A,D=V,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=(y>>>14|k<<18)^(y>>>18|k<<14)^(k>>>9|y<<23),D=(k>>>14|y<<18)^(k>>>18|y<<14)^(y>>>9|k<<23),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=y&S^~y&I,D=k&B^~k&j,l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=zg[d*2],D=zg[d*2+1],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=r[d%16],D=e[d%16],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,W=p&65535|c<<16,P=l&65535|w<<16,L=W,D=P,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=(a>>>28|R<<4)^(R>>>2|a<<30)^(R>>>7|a<<25),D=(R>>>28|a<<4)^(a>>>2|R<<30)^(a>>>7|R<<25),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,L=a&f^a&u^f&u,D=R&O^R&N^O&N,l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,z=p&65535|c<<16,$=l&65535|w<<16,L=_,D=q,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=W,D=P,l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,_=p&65535|c<<16,q=l&65535|w<<16,f=x,u=v,g=h,y=_,S=T,I=m,A=M,a=z,O=E,N=C,U=F,k=q,B=K,j=Y,V=H,R=$,d%16===15)for(var b=0;b<16;b++)L=r[b],D=e[b],l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=r[(b+9)%16],D=e[(b+9)%16],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,W=r[(b+1)%16],P=e[(b+1)%16],L=(W>>>1|P<<31)^(W>>>8|P<<24)^W>>>7,D=(P>>>1|W<<31)^(P>>>8|W<<24)^(P>>>7|W<<25),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,W=r[(b+14)%16],P=e[(b+14)%16],L=(W>>>19|P<<13)^(P>>>29|W<<3)^W>>>6,D=(P>>>19|W<<13)^(W>>>29|P<<3)^(P>>>6|W<<26),l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,r[b]=p&65535|c<<16,e[b]=l&65535|w<<16}L=a,D=R,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[0],D=i[0],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[0]=a=p&65535|c<<16,i[0]=R=l&65535|w<<16,L=f,D=O,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[1],D=i[1],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[1]=f=p&65535|c<<16,i[1]=O=l&65535|w<<16,L=u,D=N,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[2],D=i[2],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[2]=u=p&65535|c<<16,i[2]=N=l&65535|w<<16,L=g,D=U,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[3],D=i[3],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[3]=g=p&65535|c<<16,i[3]=U=l&65535|w<<16,L=y,D=k,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[4],D=i[4],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[4]=y=p&65535|c<<16,i[4]=k=l&65535|w<<16,L=S,D=B,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[5],D=i[5],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[5]=S=p&65535|c<<16,i[5]=B=l&65535|w<<16,L=I,D=j,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[6],D=i[6],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[6]=I=p&65535|c<<16,i[6]=j=l&65535|w<<16,L=A,D=V,l=D&65535,w=D>>>16,p=L&65535,c=L>>>16,L=t[7],D=i[7],l+=D&65535,w+=D>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[7]=A=p&65535|c<<16,i[7]=V=l&65535|w<<16,s+=128,o-=128}return s}function o4(r){var e=new jg;e.update(r);var t=e.digest();return e.clean(),t}Ai.hash=o4});var i1=J(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var a4=Yo(),Xo=Kg(),Wg=fr();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function ie(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,Jg(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function Yg(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function Hg(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Qo(t,r),Qo(i,e),Yg(t,i)}function Xg(r){let e=new Uint8Array(32);return Qo(e,r),e[0]&1}function d4(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Kn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function $n(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function He(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,R=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,D=0,W=0,P=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],T=t[1],m=t[2],M=t[3],z=t[4],E=t[5],C=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*T,a+=i*m,f+=i*M,u+=i*z,g+=i*E,y+=i*C,S+=i*F,I+=i*q,A+=i*K,R+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*T,f+=i*m,u+=i*M,g+=i*z,y+=i*E,S+=i*C,I+=i*F,A+=i*q,R+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*T,u+=i*m,g+=i*M,y+=i*z,S+=i*E,I+=i*C,A+=i*F,R+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*T,g+=i*m,y+=i*M,S+=i*z,I+=i*E,A+=i*C,R+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*T,y+=i*m,S+=i*M,I+=i*z,A+=i*E,R+=i*C,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,D+=i*X,i=e[5],g+=i*_,y+=i*T,S+=i*m,I+=i*M,A+=i*z,R+=i*E,O+=i*C,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,D+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*T,I+=i*m,A+=i*M,R+=i*z,O+=i*E,N+=i*C,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,D+=i*ee,W+=i*G,P+=i*X,i=e[7],S+=i*_,I+=i*T,A+=i*m,R+=i*M,O+=i*z,N+=i*E,U+=i*C,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,D+=i*$,W+=i*ee,P+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*T,R+=i*m,O+=i*M,N+=i*z,U+=i*E,k+=i*C,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,D+=i*H,W+=i*$,P+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,R+=i*T,O+=i*m,N+=i*M,U+=i*z,k+=i*E,B+=i*C,j+=i*F,V+=i*q,L+=i*K,D+=i*Y,W+=i*H,P+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],R+=i*_,O+=i*T,N+=i*m,U+=i*M,k+=i*z,B+=i*E,j+=i*C,V+=i*F,L+=i*q,D+=i*K,W+=i*Y,P+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*T,U+=i*m,k+=i*M,B+=i*z,j+=i*E,V+=i*C,L+=i*F,D+=i*q,W+=i*K,P+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*T,k+=i*m,B+=i*M,j+=i*z,V+=i*E,L+=i*C,D+=i*F,W+=i*q,P+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*T,B+=i*m,j+=i*M,V+=i*z,L+=i*E,D+=i*C,W+=i*F,P+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*T,j+=i*m,V+=i*M,L+=i*z,D+=i*E,W+=i*C,P+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*T,V+=i*m,L+=i*M,D+=i*z,W+=i*E,P+=i*C,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*D,u+=38*W,g+=38*P,y+=38*l,S+=38*w,I+=38*p,A+=38*c,R+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=R,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function Vn(r,e){He(r,e,e)}function Qg(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)Vn(t,t),i!==2&&i!==4&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function l4(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)Vn(t,t),i!==1&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Dh(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie(),u=ie(),g=ie();$n(t,r[1],r[0]),$n(g,e[1],e[0]),He(t,t,g),Kn(i,r[0],r[1]),Kn(g,e[0],e[1]),He(i,i,g),He(n,r[3],e[3]),He(n,n,u4),He(s,r[2],e[2]),Kn(s,s,s),$n(o,i,t),$n(a,s,n),Kn(f,s,n),Kn(u,i,t),He(r[0],o,a),He(r[1],u,f),He(r[2],f,a),He(r[3],o,u)}function Gg(r,e,t){for(let i=0;i<4;i++)Jg(r[i],e[i],t)}function Lh(r,e){let t=ie(),i=ie(),n=ie();Qg(n,e[2]),He(t,e[0],n),He(i,e[1],n),Qo(r,i),r[31]^=Xg(t)<<7}function Zg(r,e,t){Ji(r[0],Ch),Ji(r[1],Ds),Ji(r[2],Ds),Ji(r[3],Ch);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;Gg(r,e,n),Dh(e,r),Dh(r,r),Gg(r,e,n)}}function Fh(r,e){let t=[ie(),ie(),ie(),ie()];Ji(t[0],Vg),Ji(t[1],$g),Ji(t[2],Ds),He(t[3],Vg,$g),Zg(r,t,e)}function e1(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Xo.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[ie(),ie(),ie(),ie()];Fh(i,e),Lh(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=e1;function p4(r){let e=(0,a4.randomBytes)(32,r),t=e1(e);return(0,Wg.wipe)(e),t}ze.generateKeyPair=p4;function g4(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=g4;var Nh=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function t1(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*Nh[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*Nh[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Oh(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;t1(r,e)}function m4(r,e){let t=new Float64Array(64),i=[ie(),ie(),ie(),ie()],n=(0,Xo.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Xo.SHA512;o.update(s.subarray(32)),o.update(e);let a=o.digest();o.clean(),Oh(a),Fh(i,a),Lh(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let f=o.digest();Oh(f);for(let u=0;u<32;u++)t[u]=a[u];for(let u=0;u<32;u++)for(let g=0;g<32;g++)t[u+g]+=f[u]*n[g];return t1(s.subarray(32),t),s}ze.sign=m4;function r1(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie();return Ji(r[2],Ds),d4(r[1],e),Vn(n,r[1]),He(s,n,f4),$n(n,n,r[2]),Kn(s,r[2],s),Vn(o,s),Vn(a,o),He(f,a,o),He(t,f,n),He(t,t,s),l4(t,t),He(t,t,n),He(t,t,s),He(t,t,s),He(r[0],t,s),Vn(i,r[0]),He(i,i,s),Hg(i,n)&&He(r[0],r[0],h4),Vn(i,r[0]),He(i,i,s),Hg(i,n)?-1:(Xg(r[0])===e[31]>>7&&$n(r[0],Ch,r[0]),He(r[3],r[0],r[1]),0)}function b4(r,e,t){let i=new Uint8Array(32),n=[ie(),ie(),ie(),ie()],s=[ie(),ie(),ie(),ie()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(r1(s,r))return!1;let o=new Xo.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let a=o.digest();return Oh(a),Zg(n,s,a),Fh(s,t.subarray(32)),Dh(n,s),Lh(i,n),!Yg(t,i)}ze.verify=b4;function v4(r){let e=[ie(),ie(),ie(),ie()];if(r1(e,r))throw new Error("Ed25519: invalid public key");let t=ie(),i=ie(),n=e[1];Kn(t,Ds,n),$n(i,Ds,n),Qg(i,i),He(t,t,i);let s=new Uint8Array(32);return Qo(s,t),s}ze.convertPublicKeyToX25519=v4;function y4(r){let e=(0,Xo.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,Wg.wipe)(e),t}ze.convertSecretKeyToX25519=y4});var nf=J(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.getLocalStorage=Je.getLocalStorageOrThrow=Je.getCrypto=Je.getCryptoOrThrow=Je.getLocation=Je.getLocationOrThrow=Je.getNavigator=Je.getNavigatorOrThrow=Je.getDocument=Je.getDocumentOrThrow=Je.getFromWindowOrThrow=Je.getFromWindow=void 0;function Wn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Je.getFromWindow=Wn;function ks(r){let e=Wn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Je.getFromWindowOrThrow=ks;function Hx(){return ks("document")}Je.getDocumentOrThrow=Hx;function Gx(){return Wn("document")}Je.getDocument=Gx;function Wx(){return ks("navigator")}Je.getNavigatorOrThrow=Wx;function Jx(){return Wn("navigator")}Je.getNavigator=Jx;function Yx(){return ks("location")}Je.getLocationOrThrow=Yx;function Xx(){return Wn("location")}Je.getLocation=Xx;function Qx(){return ks("crypto")}Je.getCryptoOrThrow=Qx;function Zx(){return Wn("crypto")}Je.getCrypto=Zx;function e8(){return ks("localStorage")}Je.getLocalStorageOrThrow=e8;function t8(){return Wn("localStorage")}Je.getLocalStorage=t8});var K1=J(sf=>{"use strict";Object.defineProperty(sf,"__esModule",{value:!0});sf.getWindowMetadata=void 0;var j1=nf();function r8(){let r,e;try{r=j1.getDocumentOrThrow(),e=j1.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=A.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let N=e.protocol+"//"+e.host;if(O.indexOf("/")===0)N+=O;else{let U=e.pathname.split("/");U.pop();let k=U.join("/");N+=k+"/"+O}S.push(N)}else if(O.indexOf("//")===0){let N=e.protocol+O;S.push(N)}else S.push(O)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IA.getAttribute(O)).filter(O=>O?y.includes(O):!1);if(R.length&&R){let O=A.getAttribute("content");if(O)return O}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),a=s(),f=e.origin,u=t();return{description:a,url:f,icons:u,name:o}}sf.getWindowMetadata=r8});var $1=J((PN,V1)=>{"use strict";V1.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var Y1=J((NN,J1)=>{"use strict";var W1="%[a-f0-9]{2}",H1=new RegExp("("+W1+")|([^%]+?)","gi"),G1=new RegExp("("+W1+")+","gi");function cd(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],cd(t),cd(i))}function i8(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(H1)||[],t=1;t{"use strict";X1.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var em=J((DN,Z1)=>{"use strict";Z1.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var s8=$1(),o8=Y1(),rm=Q1(),a8=em(),c8=r=>r==null,fd=Symbol("encodeFragmentIdentifier");function f8(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[",n,"]"].join("")]:[...t,[ct(e,r),"[",ct(n,r),"]=",ct(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[]"].join("")]:[...t,[ct(e,r),"[]=",ct(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),":list="].join("")]:[...t,[ct(e,r),":list=",ct(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[ct(t,r),e,ct(n,r)].join("")]:[[i,ct(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,ct(e,r)]:[...t,[ct(e,r),"=",ct(i,r)].join("")]}}function u8(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&Mi(i,r).includes(r.arrayFormatSeparator);i=o?Mi(i,r):i;let a=s||o?i.split(r.arrayFormatSeparator).map(f=>Mi(f,r)):i===null?i:Mi(i,r);n[t]=a};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&Mi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(a=>Mi(a,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function im(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function ct(r,e){return e.encode?e.strict?s8(r):encodeURIComponent(r):r}function Mi(r,e){return e.decode?o8(r):r}function nm(r){return Array.isArray(r)?r.sort():typeof r=="object"?nm(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function sm(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function h8(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function om(r){r=sm(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function tm(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function am(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),im(e.arrayFormatSeparator);let t=u8(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=rm(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:Mi(o,e),t(Mi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=tm(s[o],e);else i[n]=tm(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=nm(o):n[s]=o,n},Object.create(null))}zt.extract=om;zt.parse=am;zt.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),im(e.arrayFormatSeparator);let t=o=>e.skipNull&&c8(r[o])||e.skipEmptyString&&r[o]==="",i=f8(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let a=r[o];return a===void 0?"":a===null?ct(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?ct(o,e)+"[]":a.reduce(i(o),[]).join("&"):ct(o,e)+"="+ct(a,e)}).filter(o=>o.length>0).join("&")};zt.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=rm(r,"#");return Object.assign({url:t.split("?")[0]||"",query:am(om(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:Mi(i,e)}:{})};zt.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[fd]:!0},e);let t=sm(r.url).split("?")[0]||"",i=zt.extract(r.url),n=zt.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=zt.stringify(s,e);o&&(o=`?${o}`);let a=h8(r.url);return r.fragmentIdentifier&&(a=`#${e[fd]?ct(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${a}`};zt.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[fd]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=zt.parseUrl(r,t);return zt.stringifyUrl({url:i,query:a8(n,e),fragmentIdentifier:s},t)};zt.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return zt.pick(r,i,t)}});var fm=J((LN,of)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=global:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof of=="object"&&of.exports,a=typeof define=="function"&&define.amd,f=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],A=[0,8,16,24],R=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],N=[128,256],U=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),f&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var B=function(E,C,F){return function(q){return new m(E,C,E).update(q)[F]()}},j=function(E,C,F){return function(q,K){return new m(E,C,K).update(q)[F]()}},V=function(E,C,F){return function(q,K,Y,H){return c["cshake"+E].update(q,K,Y,H)[F]()}},L=function(E,C,F){return function(q,K,Y,H){return c["kmac"+E].update(q,K,Y,H)[F]()}},D=function(E,C,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}m.prototype.update=function(E){if(this.finalized)throw new Error(e);var C,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}for(var q=this.blocks,K=this.byteCount,Y=E.length,H=this.blockCount,$=0,ee=this.s,G,X;$>2]|=E[$]<>2]|=X<>2]|=(192|X>>6)<>2]|=(128|X&63)<=57344?(q[G>>2]|=(224|X>>12)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<>2]|=(240|X>>18)<>2]|=(128|X>>12&63)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<=K){for(this.start=G-K,this.block=q[H],G=0;G>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return C?K.push(q):K.unshift(q),this.update(K),K.length},m.prototype.encodeString=function(E){var C,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}var q=0,K=E.length;if(C)q=K;else for(var Y=0;Y=57344?q+=3:(H=65536+((H&1023)<<10|E.charCodeAt(++Y)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},m.prototype.bytepad=function(E,C){for(var F=this.encode(C),q=0;q>2]|=this.padding[C&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],C=1;C>4&15]+u[$&15]+u[$>>12&15]+u[$>>8&15]+u[$>>20&15]+u[$>>16&15]+u[$>>28&15]+u[$>>24&15];Y%E===0&&(z(C),K=0)}return q&&($=C[K],H+=u[$>>4&15]+u[$&15],q>1&&(H+=u[$>>12&15]+u[$>>8&15]),q>2&&(H+=u[$>>20&15]+u[$>>16&15])),H},m.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,C=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,Y=0,H=this.outputBits>>3,$;q?$=new ArrayBuffer(F+1<<2):$=new ArrayBuffer(H);for(var ee=new Uint32Array($);Y>8&255,H[$+2]=ee>>16&255,H[$+3]=ee>>24&255;Y%E===0&&z(C)}return q&&($=Y<<2,ee=C[K],H[$]=ee&255,q>1&&(H[$+1]=ee>>8&255),q>2&&(H[$+2]=ee>>16&255)),H};function M(E,C,F){m.call(this,E,C,F)}M.prototype=new m,M.prototype.finalize=function(){return this.encode(this.outputBits,!0),m.prototype.finalize.call(this)};var z=function(E){var C,F,q,K,Y,H,$,ee,G,X,qr,se,oe,Br,ae,ce,kr,fe,ue,zr,he,de,jr,le,pe,Kr,ge,me,Vr,be,ve,$r,ye,we,Hr,xe,_e,Gr,Ee,Se,Wr,Ie,Ae,Jr,Te,Me,Yr,Re,Pe,Xr,Ne,Ce,Qr,De,Oe,yr,Ke,Ve,rr,ir,nr,sr,or;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],Y=E[1]^E[11]^E[21]^E[31]^E[41],H=E[2]^E[12]^E[22]^E[32]^E[42],$=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],X=E[6]^E[16]^E[26]^E[36]^E[46],qr=E[7]^E[17]^E[27]^E[37]^E[47],se=E[8]^E[18]^E[28]^E[38]^E[48],oe=E[9]^E[19]^E[29]^E[39]^E[49],C=se^(H<<1|$>>>31),F=oe^($<<1|H>>>31),E[0]^=C,E[1]^=F,E[10]^=C,E[11]^=F,E[20]^=C,E[21]^=F,E[30]^=C,E[31]^=F,E[40]^=C,E[41]^=F,C=K^(ee<<1|G>>>31),F=Y^(G<<1|ee>>>31),E[2]^=C,E[3]^=F,E[12]^=C,E[13]^=F,E[22]^=C,E[23]^=F,E[32]^=C,E[33]^=F,E[42]^=C,E[43]^=F,C=H^(X<<1|qr>>>31),F=$^(qr<<1|X>>>31),E[4]^=C,E[5]^=F,E[14]^=C,E[15]^=F,E[24]^=C,E[25]^=F,E[34]^=C,E[35]^=F,E[44]^=C,E[45]^=F,C=ee^(se<<1|oe>>>31),F=G^(oe<<1|se>>>31),E[6]^=C,E[7]^=F,E[16]^=C,E[17]^=F,E[26]^=C,E[27]^=F,E[36]^=C,E[37]^=F,E[46]^=C,E[47]^=F,C=X^(K<<1|Y>>>31),F=qr^(Y<<1|K>>>31),E[8]^=C,E[9]^=F,E[18]^=C,E[19]^=F,E[28]^=C,E[29]^=F,E[38]^=C,E[39]^=F,E[48]^=C,E[49]^=F,Br=E[0],ae=E[1],Me=E[11]<<4|E[10]>>>28,Yr=E[10]<<4|E[11]>>>28,me=E[20]<<3|E[21]>>>29,Vr=E[21]<<3|E[20]>>>29,ir=E[31]<<9|E[30]>>>23,nr=E[30]<<9|E[31]>>>23,Ie=E[40]<<18|E[41]>>>14,Ae=E[41]<<18|E[40]>>>14,we=E[2]<<1|E[3]>>>31,Hr=E[3]<<1|E[2]>>>31,ce=E[13]<<12|E[12]>>>20,kr=E[12]<<12|E[13]>>>20,Re=E[22]<<10|E[23]>>>22,Pe=E[23]<<10|E[22]>>>22,be=E[33]<<13|E[32]>>>19,ve=E[32]<<13|E[33]>>>19,sr=E[42]<<2|E[43]>>>30,or=E[43]<<2|E[42]>>>30,De=E[5]<<30|E[4]>>>2,Oe=E[4]<<30|E[5]>>>2,xe=E[14]<<6|E[15]>>>26,_e=E[15]<<6|E[14]>>>26,fe=E[25]<<11|E[24]>>>21,ue=E[24]<<11|E[25]>>>21,Xr=E[34]<<15|E[35]>>>17,Ne=E[35]<<15|E[34]>>>17,$r=E[45]<<29|E[44]>>>3,ye=E[44]<<29|E[45]>>>3,le=E[6]<<28|E[7]>>>4,pe=E[7]<<28|E[6]>>>4,yr=E[17]<<23|E[16]>>>9,Ke=E[16]<<23|E[17]>>>9,Gr=E[26]<<25|E[27]>>>7,Ee=E[27]<<25|E[26]>>>7,zr=E[36]<<21|E[37]>>>11,he=E[37]<<21|E[36]>>>11,Ce=E[47]<<24|E[46]>>>8,Qr=E[46]<<24|E[47]>>>8,Jr=E[8]<<27|E[9]>>>5,Te=E[9]<<27|E[8]>>>5,Kr=E[18]<<20|E[19]>>>12,ge=E[19]<<20|E[18]>>>12,Ve=E[29]<<7|E[28]>>>25,rr=E[28]<<7|E[29]>>>25,Se=E[38]<<8|E[39]>>>24,Wr=E[39]<<8|E[38]>>>24,de=E[48]<<14|E[49]>>>18,jr=E[49]<<14|E[48]>>>18,E[0]=Br^~ce&fe,E[1]=ae^~kr&ue,E[10]=le^~Kr&me,E[11]=pe^~ge&Vr,E[20]=we^~xe&Gr,E[21]=Hr^~_e&Ee,E[30]=Jr^~Me&Re,E[31]=Te^~Yr&Pe,E[40]=De^~yr&Ve,E[41]=Oe^~Ke&rr,E[2]=ce^~fe&zr,E[3]=kr^~ue&he,E[12]=Kr^~me&be,E[13]=ge^~Vr&ve,E[22]=xe^~Gr&Se,E[23]=_e^~Ee&Wr,E[32]=Me^~Re&Xr,E[33]=Yr^~Pe&Ne,E[42]=yr^~Ve&ir,E[43]=Ke^~rr&nr,E[4]=fe^~zr&de,E[5]=ue^~he&jr,E[14]=me^~be&$r,E[15]=Vr^~ve&ye,E[24]=Gr^~Se&Ie,E[25]=Ee^~Wr&Ae,E[34]=Re^~Xr&Ce,E[35]=Pe^~Ne&Qr,E[44]=Ve^~ir&sr,E[45]=rr^~nr&or,E[6]=zr^~de&Br,E[7]=he^~jr&ae,E[16]=be^~$r&le,E[17]=ve^~ye&pe,E[26]=Se^~Ie&we,E[27]=Wr^~Ae&Hr,E[36]=Xr^~Ce&Jr,E[37]=Ne^~Qr&Te,E[46]=ir^~sr&De,E[47]=nr^~or&Oe,E[8]=de^~Br&ce,E[9]=jr^~ae&kr,E[18]=$r^~le&Kr,E[19]=ye^~pe&ge,E[28]=Ie^~we&xe,E[29]=Ae^~Hr&_e,E[38]=Ce^~Jr&Me,E[39]=Qr^~Te&Yr,E[48]=sr^~De&yr,E[49]=or^~Oe&Ke,E[0]^=R[q],E[1]^=R[q+1]};if(o)of.exports=c;else{for(b=0;b{});var bd=J((xm,md)=>{(function(r,e){"use strict";function t(p,c){if(!p)throw new Error(c||"Assertion failed")}function i(p,c){p.super_=c;var d=function(){};d.prototype=c.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,c,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((c==="le"||c==="be")&&(d=c,c=10),this._init(p||0,c||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=gd().Buffer}catch{}n.isBN=function(c){return c instanceof n?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===n.wordSize&&Array.isArray(c.words)},n.max=function(c,d){return c.cmp(d)>0?c:d},n.min=function(c,d){return c.cmp(d)<0?c:d},n.prototype._init=function(c,d,b){if(typeof c=="number")return this._initNumber(c,d,b);if(typeof c=="object")return this._initArray(c,d,b);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),c=c.toString().replace(/\s+/g,"");var x=0;c[0]==="-"&&(x++,this.negative=1),x=0;x-=3)h=c[x]|c[x-1]<<8|c[x-2]<<16,this.words[v]|=h<<_&67108863,this.words[v+1]=h>>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);else if(b==="le")for(x=0,v=0;x>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);return this._strip()};function o(p,c){var d=p.charCodeAt(c);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function a(p,c,d){var b=o(p,d);return d-1>=c&&(b|=o(p,d-1)<<4),b}n.prototype._parseHex=function(c,d,b){this.length=Math.ceil((c.length-d)/6),this.words=new Array(this.length);for(var x=0;x=d;x-=2)_=a(c,d,x)<=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8;else{var T=c.length-d;for(x=T%2===0?d+1:d;x=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8}this._strip()};function f(p,c,d,b){for(var x=0,v=0,h=Math.min(p.length,d),_=c;_=49?v=T-49+10:T>=17?v=T-17+10:v=T,t(T>=0&&v1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{n.prototype.inspect=g}else n.prototype.inspect=g;function g(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(c,d){c=c||10,d=d|0||1;var b;if(c===16||c==="hex"){b="";for(var x=0,v=0,h=0;h>>24-x&16777215,x+=2,x>=26&&(x-=26,h--),v!==0||h!==this.length-1?b=y[6-T.length]+T+b:b=T+b}for(v!==0&&(b=v.toString(16)+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(c===(c|0)&&c>=2&&c<=36){var m=S[c],M=I[c];b="";var z=this.clone();for(z.negative=0;!z.isZero();){var E=z.modrn(M).toString(c);z=z.idivn(M),z.isZero()?b=E+b:b=y[m-E.length]+E+b}for(this.isZero()&&(b="0"+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(c,d){return this.toArrayLike(s,c,d)}),n.prototype.toArray=function(c,d){return this.toArrayLike(Array,c,d)};var A=function(c,d){return c.allocUnsafe?c.allocUnsafe(d):new c(d)};n.prototype.toArrayLike=function(c,d,b){this._strip();var x=this.byteLength(),v=b||Math.max(1,x);t(x<=v,"byte array longer than desired length"),t(v>0,"Requested array length <= 0");var h=A(c,v),_=d==="le"?"LE":"BE";return this["_toArrayLike"+_](h,x),h},n.prototype._toArrayLikeLE=function(c,d){for(var b=0,x=0,v=0,h=0;v>8&255),b>16&255),h===6?(b>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b=0&&(c[b--]=_>>8&255),b>=0&&(c[b--]=_>>16&255),h===6?(b>=0&&(c[b--]=_>>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b>=0)for(c[b--]=x;b>=0;)c[b--]=0},Math.clz32?n.prototype._countBits=function(c){return 32-Math.clz32(c)}:n.prototype._countBits=function(c){var d=c,b=0;return d>=4096&&(b+=13,d>>>=13),d>=64&&(b+=7,d>>>=7),d>=8&&(b+=4,d>>>=4),d>=2&&(b+=2,d>>>=2),b+d},n.prototype._zeroBits=function(c){if(c===0)return 26;var d=c,b=0;return d&8191||(b+=13,d>>>=13),d&127||(b+=7,d>>>=7),d&15||(b+=4,d>>>=4),d&3||(b+=2,d>>>=2),d&1||b++,b},n.prototype.bitLength=function(){var c=this.words[this.length-1],d=this._countBits(c);return(this.length-1)*26+d};function R(p){for(var c=new Array(p.bitLength()),d=0;d>>x&1}return c}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,d=0;dc.length?this.clone().ior(c):c.clone().ior(this)},n.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},n.prototype.iuand=function(c){var d;this.length>c.length?d=c:d=this;for(var b=0;bc.length?this.clone().iand(c):c.clone().iand(this)},n.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},n.prototype.iuxor=function(c){var d,b;this.length>c.length?(d=this,b=c):(d=c,b=this);for(var x=0;xc.length?this.clone().ixor(c):c.clone().ixor(this)},n.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},n.prototype.inotn=function(c){t(typeof c=="number"&&c>=0);var d=Math.ceil(c/26)|0,b=c%26;this._expand(d),b>0&&d--;for(var x=0;x0&&(this.words[x]=~this.words[x]&67108863>>26-b),this._strip()},n.prototype.notn=function(c){return this.clone().inotn(c)},n.prototype.setn=function(c,d){t(typeof c=="number"&&c>=0);var b=c/26|0,x=c%26;return this._expand(b+1),d?this.words[b]=this.words[b]|1<c.length?(b=this,x=c):(b=c,x=this);for(var v=0,h=0;h>>26;for(;v!==0&&h>>26;if(this.length=b.length,v!==0)this.words[this.length]=v,this.length++;else if(b!==this)for(;hc.length?this.clone().iadd(c):c.clone().iadd(this)},n.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var d=this.iadd(c);return c.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var b=this.cmp(c);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,v;b>0?(x=this,v=c):(x=c,v=this);for(var h=0,_=0;_>26,this.words[_]=d&67108863;for(;h!==0&&_>26,this.words[_]=d&67108863;if(h===0&&_>>26,z=T&67108863,E=Math.min(m,c.length-1),C=Math.max(0,m-p.length+1);C<=E;C++){var F=m-C|0;x=p.words[F]|0,v=c.words[C]|0,h=x*v+z,M+=h/67108864|0,z=h&67108863}d.words[m]=z|0,T=M|0}return T!==0?d.words[m]=T|0:d.length--,d._strip()}var N=function(c,d,b){var x=c.words,v=d.words,h=b.words,_=0,T,m,M,z=x[0]|0,E=z&8191,C=z>>>13,F=x[1]|0,q=F&8191,K=F>>>13,Y=x[2]|0,H=Y&8191,$=Y>>>13,ee=x[3]|0,G=ee&8191,X=ee>>>13,qr=x[4]|0,se=qr&8191,oe=qr>>>13,Br=x[5]|0,ae=Br&8191,ce=Br>>>13,kr=x[6]|0,fe=kr&8191,ue=kr>>>13,zr=x[7]|0,he=zr&8191,de=zr>>>13,jr=x[8]|0,le=jr&8191,pe=jr>>>13,Kr=x[9]|0,ge=Kr&8191,me=Kr>>>13,Vr=v[0]|0,be=Vr&8191,ve=Vr>>>13,$r=v[1]|0,ye=$r&8191,we=$r>>>13,Hr=v[2]|0,xe=Hr&8191,_e=Hr>>>13,Gr=v[3]|0,Ee=Gr&8191,Se=Gr>>>13,Wr=v[4]|0,Ie=Wr&8191,Ae=Wr>>>13,Jr=v[5]|0,Te=Jr&8191,Me=Jr>>>13,Yr=v[6]|0,Re=Yr&8191,Pe=Yr>>>13,Xr=v[7]|0,Ne=Xr&8191,Ce=Xr>>>13,Qr=v[8]|0,De=Qr&8191,Oe=Qr>>>13,yr=v[9]|0,Ke=yr&8191,Ve=yr>>>13;b.negative=c.negative^d.negative,b.length=19,T=Math.imul(E,be),m=Math.imul(E,ve),m=m+Math.imul(C,be)|0,M=Math.imul(C,ve);var rr=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(rr>>>26)|0,rr&=67108863,T=Math.imul(q,be),m=Math.imul(q,ve),m=m+Math.imul(K,be)|0,M=Math.imul(K,ve),T=T+Math.imul(E,ye)|0,m=m+Math.imul(E,we)|0,m=m+Math.imul(C,ye)|0,M=M+Math.imul(C,we)|0;var ir=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(ir>>>26)|0,ir&=67108863,T=Math.imul(H,be),m=Math.imul(H,ve),m=m+Math.imul($,be)|0,M=Math.imul($,ve),T=T+Math.imul(q,ye)|0,m=m+Math.imul(q,we)|0,m=m+Math.imul(K,ye)|0,M=M+Math.imul(K,we)|0,T=T+Math.imul(E,xe)|0,m=m+Math.imul(E,_e)|0,m=m+Math.imul(C,xe)|0,M=M+Math.imul(C,_e)|0;var nr=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(nr>>>26)|0,nr&=67108863,T=Math.imul(G,be),m=Math.imul(G,ve),m=m+Math.imul(X,be)|0,M=Math.imul(X,ve),T=T+Math.imul(H,ye)|0,m=m+Math.imul(H,we)|0,m=m+Math.imul($,ye)|0,M=M+Math.imul($,we)|0,T=T+Math.imul(q,xe)|0,m=m+Math.imul(q,_e)|0,m=m+Math.imul(K,xe)|0,M=M+Math.imul(K,_e)|0,T=T+Math.imul(E,Ee)|0,m=m+Math.imul(E,Se)|0,m=m+Math.imul(C,Ee)|0,M=M+Math.imul(C,Se)|0;var sr=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(sr>>>26)|0,sr&=67108863,T=Math.imul(se,be),m=Math.imul(se,ve),m=m+Math.imul(oe,be)|0,M=Math.imul(oe,ve),T=T+Math.imul(G,ye)|0,m=m+Math.imul(G,we)|0,m=m+Math.imul(X,ye)|0,M=M+Math.imul(X,we)|0,T=T+Math.imul(H,xe)|0,m=m+Math.imul(H,_e)|0,m=m+Math.imul($,xe)|0,M=M+Math.imul($,_e)|0,T=T+Math.imul(q,Ee)|0,m=m+Math.imul(q,Se)|0,m=m+Math.imul(K,Ee)|0,M=M+Math.imul(K,Se)|0,T=T+Math.imul(E,Ie)|0,m=m+Math.imul(E,Ae)|0,m=m+Math.imul(C,Ie)|0,M=M+Math.imul(C,Ae)|0;var or=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(or>>>26)|0,or&=67108863,T=Math.imul(ae,be),m=Math.imul(ae,ve),m=m+Math.imul(ce,be)|0,M=Math.imul(ce,ve),T=T+Math.imul(se,ye)|0,m=m+Math.imul(se,we)|0,m=m+Math.imul(oe,ye)|0,M=M+Math.imul(oe,we)|0,T=T+Math.imul(G,xe)|0,m=m+Math.imul(G,_e)|0,m=m+Math.imul(X,xe)|0,M=M+Math.imul(X,_e)|0,T=T+Math.imul(H,Ee)|0,m=m+Math.imul(H,Se)|0,m=m+Math.imul($,Ee)|0,M=M+Math.imul($,Se)|0,T=T+Math.imul(q,Ie)|0,m=m+Math.imul(q,Ae)|0,m=m+Math.imul(K,Ie)|0,M=M+Math.imul(K,Ae)|0,T=T+Math.imul(E,Te)|0,m=m+Math.imul(E,Me)|0,m=m+Math.imul(C,Te)|0,M=M+Math.imul(C,Me)|0;var Tn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,T=Math.imul(fe,be),m=Math.imul(fe,ve),m=m+Math.imul(ue,be)|0,M=Math.imul(ue,ve),T=T+Math.imul(ae,ye)|0,m=m+Math.imul(ae,we)|0,m=m+Math.imul(ce,ye)|0,M=M+Math.imul(ce,we)|0,T=T+Math.imul(se,xe)|0,m=m+Math.imul(se,_e)|0,m=m+Math.imul(oe,xe)|0,M=M+Math.imul(oe,_e)|0,T=T+Math.imul(G,Ee)|0,m=m+Math.imul(G,Se)|0,m=m+Math.imul(X,Ee)|0,M=M+Math.imul(X,Se)|0,T=T+Math.imul(H,Ie)|0,m=m+Math.imul(H,Ae)|0,m=m+Math.imul($,Ie)|0,M=M+Math.imul($,Ae)|0,T=T+Math.imul(q,Te)|0,m=m+Math.imul(q,Me)|0,m=m+Math.imul(K,Te)|0,M=M+Math.imul(K,Me)|0,T=T+Math.imul(E,Re)|0,m=m+Math.imul(E,Pe)|0,m=m+Math.imul(C,Re)|0,M=M+Math.imul(C,Pe)|0;var Mn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,T=Math.imul(he,be),m=Math.imul(he,ve),m=m+Math.imul(de,be)|0,M=Math.imul(de,ve),T=T+Math.imul(fe,ye)|0,m=m+Math.imul(fe,we)|0,m=m+Math.imul(ue,ye)|0,M=M+Math.imul(ue,we)|0,T=T+Math.imul(ae,xe)|0,m=m+Math.imul(ae,_e)|0,m=m+Math.imul(ce,xe)|0,M=M+Math.imul(ce,_e)|0,T=T+Math.imul(se,Ee)|0,m=m+Math.imul(se,Se)|0,m=m+Math.imul(oe,Ee)|0,M=M+Math.imul(oe,Se)|0,T=T+Math.imul(G,Ie)|0,m=m+Math.imul(G,Ae)|0,m=m+Math.imul(X,Ie)|0,M=M+Math.imul(X,Ae)|0,T=T+Math.imul(H,Te)|0,m=m+Math.imul(H,Me)|0,m=m+Math.imul($,Te)|0,M=M+Math.imul($,Me)|0,T=T+Math.imul(q,Re)|0,m=m+Math.imul(q,Pe)|0,m=m+Math.imul(K,Re)|0,M=M+Math.imul(K,Pe)|0,T=T+Math.imul(E,Ne)|0,m=m+Math.imul(E,Ce)|0,m=m+Math.imul(C,Ne)|0,M=M+Math.imul(C,Ce)|0;var Rn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,T=Math.imul(le,be),m=Math.imul(le,ve),m=m+Math.imul(pe,be)|0,M=Math.imul(pe,ve),T=T+Math.imul(he,ye)|0,m=m+Math.imul(he,we)|0,m=m+Math.imul(de,ye)|0,M=M+Math.imul(de,we)|0,T=T+Math.imul(fe,xe)|0,m=m+Math.imul(fe,_e)|0,m=m+Math.imul(ue,xe)|0,M=M+Math.imul(ue,_e)|0,T=T+Math.imul(ae,Ee)|0,m=m+Math.imul(ae,Se)|0,m=m+Math.imul(ce,Ee)|0,M=M+Math.imul(ce,Se)|0,T=T+Math.imul(se,Ie)|0,m=m+Math.imul(se,Ae)|0,m=m+Math.imul(oe,Ie)|0,M=M+Math.imul(oe,Ae)|0,T=T+Math.imul(G,Te)|0,m=m+Math.imul(G,Me)|0,m=m+Math.imul(X,Te)|0,M=M+Math.imul(X,Me)|0,T=T+Math.imul(H,Re)|0,m=m+Math.imul(H,Pe)|0,m=m+Math.imul($,Re)|0,M=M+Math.imul($,Pe)|0,T=T+Math.imul(q,Ne)|0,m=m+Math.imul(q,Ce)|0,m=m+Math.imul(K,Ne)|0,M=M+Math.imul(K,Ce)|0,T=T+Math.imul(E,De)|0,m=m+Math.imul(E,Oe)|0,m=m+Math.imul(C,De)|0,M=M+Math.imul(C,Oe)|0;var Pn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,T=Math.imul(ge,be),m=Math.imul(ge,ve),m=m+Math.imul(me,be)|0,M=Math.imul(me,ve),T=T+Math.imul(le,ye)|0,m=m+Math.imul(le,we)|0,m=m+Math.imul(pe,ye)|0,M=M+Math.imul(pe,we)|0,T=T+Math.imul(he,xe)|0,m=m+Math.imul(he,_e)|0,m=m+Math.imul(de,xe)|0,M=M+Math.imul(de,_e)|0,T=T+Math.imul(fe,Ee)|0,m=m+Math.imul(fe,Se)|0,m=m+Math.imul(ue,Ee)|0,M=M+Math.imul(ue,Se)|0,T=T+Math.imul(ae,Ie)|0,m=m+Math.imul(ae,Ae)|0,m=m+Math.imul(ce,Ie)|0,M=M+Math.imul(ce,Ae)|0,T=T+Math.imul(se,Te)|0,m=m+Math.imul(se,Me)|0,m=m+Math.imul(oe,Te)|0,M=M+Math.imul(oe,Me)|0,T=T+Math.imul(G,Re)|0,m=m+Math.imul(G,Pe)|0,m=m+Math.imul(X,Re)|0,M=M+Math.imul(X,Pe)|0,T=T+Math.imul(H,Ne)|0,m=m+Math.imul(H,Ce)|0,m=m+Math.imul($,Ne)|0,M=M+Math.imul($,Ce)|0,T=T+Math.imul(q,De)|0,m=m+Math.imul(q,Oe)|0,m=m+Math.imul(K,De)|0,M=M+Math.imul(K,Oe)|0,T=T+Math.imul(E,Ke)|0,m=m+Math.imul(E,Ve)|0,m=m+Math.imul(C,Ke)|0,M=M+Math.imul(C,Ve)|0;var Nn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,T=Math.imul(ge,ye),m=Math.imul(ge,we),m=m+Math.imul(me,ye)|0,M=Math.imul(me,we),T=T+Math.imul(le,xe)|0,m=m+Math.imul(le,_e)|0,m=m+Math.imul(pe,xe)|0,M=M+Math.imul(pe,_e)|0,T=T+Math.imul(he,Ee)|0,m=m+Math.imul(he,Se)|0,m=m+Math.imul(de,Ee)|0,M=M+Math.imul(de,Se)|0,T=T+Math.imul(fe,Ie)|0,m=m+Math.imul(fe,Ae)|0,m=m+Math.imul(ue,Ie)|0,M=M+Math.imul(ue,Ae)|0,T=T+Math.imul(ae,Te)|0,m=m+Math.imul(ae,Me)|0,m=m+Math.imul(ce,Te)|0,M=M+Math.imul(ce,Me)|0,T=T+Math.imul(se,Re)|0,m=m+Math.imul(se,Pe)|0,m=m+Math.imul(oe,Re)|0,M=M+Math.imul(oe,Pe)|0,T=T+Math.imul(G,Ne)|0,m=m+Math.imul(G,Ce)|0,m=m+Math.imul(X,Ne)|0,M=M+Math.imul(X,Ce)|0,T=T+Math.imul(H,De)|0,m=m+Math.imul(H,Oe)|0,m=m+Math.imul($,De)|0,M=M+Math.imul($,Oe)|0,T=T+Math.imul(q,Ke)|0,m=m+Math.imul(q,Ve)|0,m=m+Math.imul(K,Ke)|0,M=M+Math.imul(K,Ve)|0;var Cn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Cn>>>26)|0,Cn&=67108863,T=Math.imul(ge,xe),m=Math.imul(ge,_e),m=m+Math.imul(me,xe)|0,M=Math.imul(me,_e),T=T+Math.imul(le,Ee)|0,m=m+Math.imul(le,Se)|0,m=m+Math.imul(pe,Ee)|0,M=M+Math.imul(pe,Se)|0,T=T+Math.imul(he,Ie)|0,m=m+Math.imul(he,Ae)|0,m=m+Math.imul(de,Ie)|0,M=M+Math.imul(de,Ae)|0,T=T+Math.imul(fe,Te)|0,m=m+Math.imul(fe,Me)|0,m=m+Math.imul(ue,Te)|0,M=M+Math.imul(ue,Me)|0,T=T+Math.imul(ae,Re)|0,m=m+Math.imul(ae,Pe)|0,m=m+Math.imul(ce,Re)|0,M=M+Math.imul(ce,Pe)|0,T=T+Math.imul(se,Ne)|0,m=m+Math.imul(se,Ce)|0,m=m+Math.imul(oe,Ne)|0,M=M+Math.imul(oe,Ce)|0,T=T+Math.imul(G,De)|0,m=m+Math.imul(G,Oe)|0,m=m+Math.imul(X,De)|0,M=M+Math.imul(X,Oe)|0,T=T+Math.imul(H,Ke)|0,m=m+Math.imul(H,Ve)|0,m=m+Math.imul($,Ke)|0,M=M+Math.imul($,Ve)|0;var Dn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,T=Math.imul(ge,Ee),m=Math.imul(ge,Se),m=m+Math.imul(me,Ee)|0,M=Math.imul(me,Se),T=T+Math.imul(le,Ie)|0,m=m+Math.imul(le,Ae)|0,m=m+Math.imul(pe,Ie)|0,M=M+Math.imul(pe,Ae)|0,T=T+Math.imul(he,Te)|0,m=m+Math.imul(he,Me)|0,m=m+Math.imul(de,Te)|0,M=M+Math.imul(de,Me)|0,T=T+Math.imul(fe,Re)|0,m=m+Math.imul(fe,Pe)|0,m=m+Math.imul(ue,Re)|0,M=M+Math.imul(ue,Pe)|0,T=T+Math.imul(ae,Ne)|0,m=m+Math.imul(ae,Ce)|0,m=m+Math.imul(ce,Ne)|0,M=M+Math.imul(ce,Ce)|0,T=T+Math.imul(se,De)|0,m=m+Math.imul(se,Oe)|0,m=m+Math.imul(oe,De)|0,M=M+Math.imul(oe,Oe)|0,T=T+Math.imul(G,Ke)|0,m=m+Math.imul(G,Ve)|0,m=m+Math.imul(X,Ke)|0,M=M+Math.imul(X,Ve)|0;var On=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(On>>>26)|0,On&=67108863,T=Math.imul(ge,Ie),m=Math.imul(ge,Ae),m=m+Math.imul(me,Ie)|0,M=Math.imul(me,Ae),T=T+Math.imul(le,Te)|0,m=m+Math.imul(le,Me)|0,m=m+Math.imul(pe,Te)|0,M=M+Math.imul(pe,Me)|0,T=T+Math.imul(he,Re)|0,m=m+Math.imul(he,Pe)|0,m=m+Math.imul(de,Re)|0,M=M+Math.imul(de,Pe)|0,T=T+Math.imul(fe,Ne)|0,m=m+Math.imul(fe,Ce)|0,m=m+Math.imul(ue,Ne)|0,M=M+Math.imul(ue,Ce)|0,T=T+Math.imul(ae,De)|0,m=m+Math.imul(ae,Oe)|0,m=m+Math.imul(ce,De)|0,M=M+Math.imul(ce,Oe)|0,T=T+Math.imul(se,Ke)|0,m=m+Math.imul(se,Ve)|0,m=m+Math.imul(oe,Ke)|0,M=M+Math.imul(oe,Ve)|0;var Ln=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Ln>>>26)|0,Ln&=67108863,T=Math.imul(ge,Te),m=Math.imul(ge,Me),m=m+Math.imul(me,Te)|0,M=Math.imul(me,Me),T=T+Math.imul(le,Re)|0,m=m+Math.imul(le,Pe)|0,m=m+Math.imul(pe,Re)|0,M=M+Math.imul(pe,Pe)|0,T=T+Math.imul(he,Ne)|0,m=m+Math.imul(he,Ce)|0,m=m+Math.imul(de,Ne)|0,M=M+Math.imul(de,Ce)|0,T=T+Math.imul(fe,De)|0,m=m+Math.imul(fe,Oe)|0,m=m+Math.imul(ue,De)|0,M=M+Math.imul(ue,Oe)|0,T=T+Math.imul(ae,Ke)|0,m=m+Math.imul(ae,Ve)|0,m=m+Math.imul(ce,Ke)|0,M=M+Math.imul(ce,Ve)|0;var Fn=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Fn>>>26)|0,Fn&=67108863,T=Math.imul(ge,Re),m=Math.imul(ge,Pe),m=m+Math.imul(me,Re)|0,M=Math.imul(me,Pe),T=T+Math.imul(le,Ne)|0,m=m+Math.imul(le,Ce)|0,m=m+Math.imul(pe,Ne)|0,M=M+Math.imul(pe,Ce)|0,T=T+Math.imul(he,De)|0,m=m+Math.imul(he,Oe)|0,m=m+Math.imul(de,De)|0,M=M+Math.imul(de,Oe)|0,T=T+Math.imul(fe,Ke)|0,m=m+Math.imul(fe,Ve)|0,m=m+Math.imul(ue,Ke)|0,M=M+Math.imul(ue,Ve)|0;var Un=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Un>>>26)|0,Un&=67108863,T=Math.imul(ge,Ne),m=Math.imul(ge,Ce),m=m+Math.imul(me,Ne)|0,M=Math.imul(me,Ce),T=T+Math.imul(le,De)|0,m=m+Math.imul(le,Oe)|0,m=m+Math.imul(pe,De)|0,M=M+Math.imul(pe,Oe)|0,T=T+Math.imul(he,Ke)|0,m=m+Math.imul(he,Ve)|0,m=m+Math.imul(de,Ke)|0,M=M+Math.imul(de,Ve)|0;var Ku=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Ku>>>26)|0,Ku&=67108863,T=Math.imul(ge,De),m=Math.imul(ge,Oe),m=m+Math.imul(me,De)|0,M=Math.imul(me,Oe),T=T+Math.imul(le,Ke)|0,m=m+Math.imul(le,Ve)|0,m=m+Math.imul(pe,Ke)|0,M=M+Math.imul(pe,Ve)|0;var Vu=(_+T|0)+((m&8191)<<13)|0;_=(M+(m>>>13)|0)+(Vu>>>26)|0,Vu&=67108863,T=Math.imul(ge,Ke),m=Math.imul(ge,Ve),m=m+Math.imul(me,Ke)|0,M=Math.imul(me,Ve);var $u=(_+T|0)+((m&8191)<<13)|0;return _=(M+(m>>>13)|0)+($u>>>26)|0,$u&=67108863,h[0]=rr,h[1]=ir,h[2]=nr,h[3]=sr,h[4]=or,h[5]=Tn,h[6]=Mn,h[7]=Rn,h[8]=Pn,h[9]=Nn,h[10]=Cn,h[11]=Dn,h[12]=On,h[13]=Ln,h[14]=Fn,h[15]=Un,h[16]=Ku,h[17]=Vu,h[18]=$u,_!==0&&(h[19]=_,b.length++),b};Math.imul||(N=O);function U(p,c,d){d.negative=c.negative^p.negative,d.length=p.length+c.length;for(var b=0,x=0,v=0;v>>26)|0,x+=h>>>26,h&=67108863}d.words[v]=_,b=h,h=x}return b!==0?d.words[v]=b:d.length--,d._strip()}function k(p,c,d){return U(p,c,d)}n.prototype.mulTo=function(c,d){var b,x=this.length+c.length;return this.length===10&&c.length===10?b=N(this,c,d):x<63?b=O(this,c,d):x<1024?b=U(this,c,d):b=k(this,c,d),b};function B(p,c){this.x=p,this.y=c}B.prototype.makeRBT=function(c){for(var d=new Array(c),b=n.prototype._countBits(c)-1,x=0;x>=1;return x},B.prototype.permute=function(c,d,b,x,v,h){for(var _=0;_>>1)v++;return 1<>>13,b[2*h+1]=v&8191,v=v>>>13;for(h=2*d;h>=26,b+=v/67108864|0,b+=h>>>26,this.words[x]=h&67108863}return b!==0&&(this.words[x]=b,this.length++),d?this.ineg():this},n.prototype.muln=function(c){return this.clone().imuln(c)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(c){var d=R(c);if(d.length===0)return new n(1);for(var b=this,x=0;x=0);var d=c%26,b=(c-d)/26,x=67108863>>>26-d<<26-d,v;if(d!==0){var h=0;for(v=0;v>>26-d}h&&(this.words[v]=h,this.length++)}if(b!==0){for(v=this.length-1;v>=0;v--)this.words[v+b]=this.words[v];for(v=0;v=0);var x;d?x=(d-d%26)/26:x=0;var v=c%26,h=Math.min((c-v)/26,this.length),_=67108863^67108863>>>v<h)for(this.length-=h,m=0;m=0&&(M!==0||m>=x);m--){var z=this.words[m]|0;this.words[m]=M<<26-v|z>>>v,M=z&_}return T&&M!==0&&(T.words[T.length++]=M),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(c,d,b){return t(this.negative===0),this.iushrn(c,d,b)},n.prototype.shln=function(c){return this.clone().ishln(c)},n.prototype.ushln=function(c){return this.clone().iushln(c)},n.prototype.shrn=function(c){return this.clone().ishrn(c)},n.prototype.ushrn=function(c){return this.clone().iushrn(c)},n.prototype.testn=function(c){t(typeof c=="number"&&c>=0);var d=c%26,b=(c-d)/26,x=1<=0);var d=c%26,b=(c-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(d!==0&&b++,this.length=Math.min(b,this.length),d!==0){var x=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(c){if(t(typeof c=="number"),t(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(T/67108864|0),this.words[v+b]=h&67108863}for(;v>26,this.words[v+b]=h&67108863;if(_===0)return this._strip();for(t(_===-1),_=0,v=0;v>26,this.words[v]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(c,d){var b=this.length-c.length,x=this.clone(),v=c,h=v.words[v.length-1]|0,_=this._countBits(h);b=26-_,b!==0&&(v=v.ushln(b),x.iushln(b),h=v.words[v.length-1]|0);var T=x.length-v.length,m;if(d!=="mod"){m=new n(null),m.length=T+1,m.words=new Array(m.length);for(var M=0;M=0;E--){var C=(x.words[v.length+E]|0)*67108864+(x.words[v.length+E-1]|0);for(C=Math.min(C/h|0,67108863),x._ishlnsubmul(v,C,E);x.negative!==0;)C--,x.negative=0,x._ishlnsubmul(v,1,E),x.isZero()||(x.negative^=1);m&&(m.words[E]=C)}return m&&m._strip(),x._strip(),d!=="div"&&b!==0&&x.iushrn(b),{div:m||null,mod:x}},n.prototype.divmod=function(c,d,b){if(t(!c.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var x,v,h;return this.negative!==0&&c.negative===0?(h=this.neg().divmod(c,d),d!=="mod"&&(x=h.div.neg()),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.iadd(c)),{div:x,mod:v}):this.negative===0&&c.negative!==0?(h=this.divmod(c.neg(),d),d!=="mod"&&(x=h.div.neg()),{div:x,mod:h.mod}):this.negative&c.negative?(h=this.neg().divmod(c.neg(),d),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.isub(c)),{div:h.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new n(0),mod:this}:c.length===1?d==="div"?{div:this.divn(c.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new n(this.modrn(c.words[0]))}:this._wordDiv(c,d)},n.prototype.div=function(c){return this.divmod(c,"div",!1).div},n.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},n.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},n.prototype.divRound=function(c){var d=this.divmod(c);if(d.mod.isZero())return d.div;var b=d.div.negative!==0?d.mod.isub(c):d.mod,x=c.ushrn(1),v=c.andln(1),h=b.cmp(x);return h<0||v===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=(1<<26)%c,x=0,v=this.length-1;v>=0;v--)x=(b*x+(this.words[v]|0))%c;return d?-x:x},n.prototype.modn=function(c){return this.modrn(c)},n.prototype.idivn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=0,x=this.length-1;x>=0;x--){var v=(this.words[x]|0)+b*67108864;this.words[x]=v/c|0,b=v%c}return this._strip(),d?this.ineg():this},n.prototype.divn=function(c){return this.clone().idivn(c)},n.prototype.egcd=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=new n(0),_=new n(1),T=0;d.isEven()&&b.isEven();)d.iushrn(1),b.iushrn(1),++T;for(var m=b.clone(),M=d.clone();!d.isZero();){for(var z=0,E=1;!(d.words[0]&E)&&z<26;++z,E<<=1);if(z>0)for(d.iushrn(z);z-- >0;)(x.isOdd()||v.isOdd())&&(x.iadd(m),v.isub(M)),x.iushrn(1),v.iushrn(1);for(var C=0,F=1;!(b.words[0]&F)&&C<26;++C,F<<=1);if(C>0)for(b.iushrn(C);C-- >0;)(h.isOdd()||_.isOdd())&&(h.iadd(m),_.isub(M)),h.iushrn(1),_.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(h),v.isub(_)):(b.isub(d),h.isub(x),_.isub(v))}return{a:h,b:_,gcd:b.iushln(T)}},n.prototype._invmp=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=b.clone();d.cmpn(1)>0&&b.cmpn(1)>0;){for(var _=0,T=1;!(d.words[0]&T)&&_<26;++_,T<<=1);if(_>0)for(d.iushrn(_);_-- >0;)x.isOdd()&&x.iadd(h),x.iushrn(1);for(var m=0,M=1;!(b.words[0]&M)&&m<26;++m,M<<=1);if(m>0)for(b.iushrn(m);m-- >0;)v.isOdd()&&v.iadd(h),v.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(v)):(b.isub(d),v.isub(x))}var z;return d.cmpn(1)===0?z=x:z=v,z.cmpn(0)<0&&z.iadd(c),z},n.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var d=this.clone(),b=c.clone();d.negative=0,b.negative=0;for(var x=0;d.isEven()&&b.isEven();x++)d.iushrn(1),b.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;b.isEven();)b.iushrn(1);var v=d.cmp(b);if(v<0){var h=d;d=b,b=h}else if(v===0||b.cmpn(1)===0)break;d.isub(b)}while(!0);return b.iushln(x)},n.prototype.invm=function(c){return this.egcd(c).a.umod(c)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(c){return this.words[0]&c},n.prototype.bincn=function(c){t(typeof c=="number");var d=c%26,b=(c-d)/26,x=1<>>26,_&=67108863,this.words[h]=_}return v!==0&&(this.words[h]=v,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(c){var d=c<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var b;if(this.length>1)b=1;else{d&&(c=-c),t(c<=67108863,"Number is too big");var x=this.words[0]|0;b=x===c?0:xc.length)return 1;if(this.length=0;b--){var x=this.words[b]|0,v=c.words[b]|0;if(x!==v){xv&&(d=1);break}}return d},n.prototype.gtn=function(c){return this.cmpn(c)===1},n.prototype.gt=function(c){return this.cmp(c)===1},n.prototype.gten=function(c){return this.cmpn(c)>=0},n.prototype.gte=function(c){return this.cmp(c)>=0},n.prototype.ltn=function(c){return this.cmpn(c)===-1},n.prototype.lt=function(c){return this.cmp(c)===-1},n.prototype.lten=function(c){return this.cmpn(c)<=0},n.prototype.lte=function(c){return this.cmp(c)<=0},n.prototype.eqn=function(c){return this.cmpn(c)===0},n.prototype.eq=function(c){return this.cmp(c)===0},n.red=function(c){return new l(c)},n.prototype.toRed=function(c){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(c){return this.red=c,this},n.prototype.forceRed=function(c){return t(!this.red,"Already a number in reduction context"),this._forceRed(c)},n.prototype.redAdd=function(c){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},n.prototype.redIAdd=function(c){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},n.prototype.redSub=function(c){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},n.prototype.redISub=function(c){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},n.prototype.redShl=function(c){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},n.prototype.redMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},n.prototype.redIMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(c){return t(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var j={k256:null,p224:null,p192:null,p25519:null};function V(p,c){this.name=p,this.p=new n(c,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var c=new n(null);return c.words=new Array(Math.ceil(this.n/13)),c},V.prototype.ireduce=function(c){var d=c,b;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),b=d.bitLength();while(b>this.n);var x=b0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},V.prototype.split=function(c,d){c.iushrn(this.n,0,d)},V.prototype.imulK=function(c){return c.imul(this.k)};function L(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,V),L.prototype.split=function(c,d){for(var b=4194303,x=Math.min(c.length,9),v=0;v>>22,h=_}h>>>=22,c.words[v-10]=h,h===0&&c.length>10?c.length-=10:c.length-=9},L.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var d=0,b=0;b>>=26,c.words[b]=v,d=x}return d!==0&&(c.words[c.length++]=d),c},n._prime=function(c){if(j[c])return j[c];var d;if(c==="k256")d=new L;else if(c==="p224")d=new D;else if(c==="p192")d=new W;else if(c==="p25519")d=new P;else throw new Error("Unknown prime "+c);return j[c]=d,d};function l(p){if(typeof p=="string"){var c=n._prime(p);this.m=c.p,this.prime=c}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(c){t(c.negative===0,"red works only with positives"),t(c.red,"red works only with red numbers")},l.prototype._verify2=function(c,d){t((c.negative|d.negative)===0,"red works only with positives"),t(c.red&&c.red===d.red,"red works only with red numbers")},l.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(u(c,c.umod(this.m)._forceRed(this)),c)},l.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},l.prototype.add=function(c,d){this._verify2(c,d);var b=c.add(d);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},l.prototype.iadd=function(c,d){this._verify2(c,d);var b=c.iadd(d);return b.cmp(this.m)>=0&&b.isub(this.m),b},l.prototype.sub=function(c,d){this._verify2(c,d);var b=c.sub(d);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},l.prototype.isub=function(c,d){this._verify2(c,d);var b=c.isub(d);return b.cmpn(0)<0&&b.iadd(this.m),b},l.prototype.shl=function(c,d){return this._verify1(c),this.imod(c.ushln(d))},l.prototype.imul=function(c,d){return this._verify2(c,d),this.imod(c.imul(d))},l.prototype.mul=function(c,d){return this._verify2(c,d),this.imod(c.mul(d))},l.prototype.isqr=function(c){return this.imul(c,c.clone())},l.prototype.sqr=function(c){return this.mul(c,c)},l.prototype.sqrt=function(c){if(c.isZero())return c.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var b=this.m.add(new n(1)).iushrn(2);return this.pow(c,b)}for(var x=this.m.subn(1),v=0;!x.isZero()&&x.andln(1)===0;)v++,x.iushrn(1);t(!x.isZero());var h=new n(1).toRed(this),_=h.redNeg(),T=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new n(2*m*m).toRed(this);this.pow(m,T).cmp(_)!==0;)m.redIAdd(_);for(var M=this.pow(m,x),z=this.pow(c,x.addn(1).iushrn(1)),E=this.pow(c,x),C=v;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;v--){for(var M=d.words[v],z=m-1;z>=0;z--){var E=M>>z&1;if(h!==x[0]&&(h=this.sqr(h)),E===0&&_===0){T=0;continue}_<<=1,_|=E,T++,!(T!==b&&(v!==0||z!==0))&&(h=this.mul(h,x[_]),T=0,_=0)}m=26}return h},l.prototype.convertTo=function(c){var d=c.umod(this.m);return d===c?d.clone():d},l.prototype.convertFrom=function(c){var d=c.clone();return d.red=null,d},n.mont=function(c){return new w(c)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},w.prototype.convertFrom=function(c){var d=this.imod(c.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(c,d){if(c.isZero()||d.isZero())return c.words[0]=0,c.length=1,c;var b=c.imul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(c,d){if(c.isZero()||d.isZero())return new n(0)._forceRed(this);var b=c.mul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(c){var d=this.imod(c._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof md>"u"||md,xm)});var Qi=J((RC,Om)=>{Om.exports=Dm;function Dm(r,e){if(!r)throw new Error(e||"Assertion failed")}Dm.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var ua=J((PC,wd)=>{typeof Object.create=="function"?wd.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:wd.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var Ir=J(Ge=>{"use strict";var E8=Qi(),S8=ua();Ge.inherits=S8;function I8(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function A8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):I8(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ge.htonl=Lm;function M8(r,e){for(var t="",i=0;i>>0}return s}Ge.join32=R8;function P8(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ge.split32=P8;function N8(r,e){return r>>>e|r<<32-e}Ge.rotr32=N8;function C8(r,e){return r<>>32-e}Ge.rotl32=C8;function D8(r,e){return r+e>>>0}Ge.sum32=D8;function O8(r,e,t){return r+e+t>>>0}Ge.sum32_3=O8;function L8(r,e,t,i){return r+e+t+i>>>0}Ge.sum32_4=L8;function F8(r,e,t,i,n){return r+e+t+i+n>>>0}Ge.sum32_5=F8;function U8(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,a=(o>>0,r[e+1]=o}Ge.sum64=U8;function q8(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ge.sum64_hi=q8;function B8(r,e,t,i){var n=e+i;return n>>>0}Ge.sum64_lo=B8;function k8(r,e,t,i,n,s,o,a){var f=0,u=e;u=u+i>>>0,f+=u>>0,f+=u>>0,f+=u>>0}Ge.sum64_4_hi=k8;function z8(r,e,t,i,n,s,o,a){var f=e+i+s+a;return f>>>0}Ge.sum64_4_lo=z8;function j8(r,e,t,i,n,s,o,a,f,u){var g=0,y=e;y=y+i>>>0,g+=y>>0,g+=y>>0,g+=y>>0,g+=y>>0}Ge.sum64_5_hi=j8;function K8(r,e,t,i,n,s,o,a,f,u){var g=e+i+s+a+u;return g>>>0}Ge.sum64_5_lo=K8;function V8(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ge.rotr64_hi=V8;function $8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.rotr64_lo=$8;function H8(r,e,t){return r>>>t}Ge.shr64_hi=H8;function G8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.shr64_lo=G8});var Vs=J(Bm=>{"use strict";var qm=Ir(),W8=Qi();function df(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Bm.BlockHash=df;df.prototype.update=function(e,t){if(e=qm.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=qm.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var J8=Ir(),ii=J8.rotr32;function Y8(r,e,t,i){if(r===0)return km(e,t,i);if(r===1||r===3)return jm(e,t,i);if(r===2)return zm(e,t,i)}Ri.ft_1=Y8;function km(r,e,t){return r&e^~r&t}Ri.ch32=km;function zm(r,e,t){return r&e^r&t^e&t}Ri.maj32=zm;function jm(r,e,t){return r^e^t}Ri.p32=jm;function X8(r){return ii(r,2)^ii(r,13)^ii(r,22)}Ri.s0_256=X8;function Q8(r){return ii(r,6)^ii(r,11)^ii(r,25)}Ri.s1_256=Q8;function Z8(r){return ii(r,7)^ii(r,18)^r>>>3}Ri.g0_256=Z8;function e_(r){return ii(r,17)^ii(r,19)^r>>>10}Ri.g1_256=e_});var $m=J((OC,Vm)=>{"use strict";var $s=Ir(),t_=Vs(),r_=xd(),_d=$s.rotl32,ha=$s.sum32,i_=$s.sum32_5,n_=r_.ft_1,Km=t_.BlockHash,s_=[1518500249,1859775393,2400959708,3395469782];function ni(){if(!(this instanceof ni))return new ni;Km.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}$s.inherits(ni,Km);Vm.exports=ni;ni.blockSize=512;ni.outSize=160;ni.hmacStrength=80;ni.padLength=64;ni.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Hs=Ir(),o_=Vs(),Gs=xd(),a_=Qi(),Ar=Hs.sum32,c_=Hs.sum32_4,f_=Hs.sum32_5,u_=Gs.ch32,h_=Gs.maj32,d_=Gs.s0_256,l_=Gs.s1_256,p_=Gs.g0_256,g_=Gs.g1_256,Hm=o_.BlockHash,m_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function si(){if(!(this instanceof si))return new si;Hm.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m_,this.W=new Array(64)}Hs.inherits(si,Hm);Gm.exports=si;si.blockSize=512;si.outSize=256;si.hmacStrength=192;si.padLength=64;si.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Sd=Ir(),Wm=Ed();function Pi(){if(!(this instanceof Pi))return new Pi;Wm.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Sd.inherits(Pi,Wm);Jm.exports=Pi;Pi.blockSize=512;Pi.outSize=224;Pi.hmacStrength=192;Pi.padLength=64;Pi.prototype._digest=function(e){return e==="hex"?Sd.toHex32(this.h.slice(0,7),"big"):Sd.split32(this.h.slice(0,7),"big")}});var Td=J((UC,eb)=>{"use strict";var jt=Ir(),b_=Vs(),v_=Qi(),oi=jt.rotr64_hi,ai=jt.rotr64_lo,Xm=jt.shr64_hi,Qm=jt.shr64_lo,Zi=jt.sum64,Id=jt.sum64_hi,Ad=jt.sum64_lo,y_=jt.sum64_4_hi,w_=jt.sum64_4_lo,x_=jt.sum64_5_hi,__=jt.sum64_5_lo,Zm=b_.BlockHash,E_=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Tr(){if(!(this instanceof Tr))return new Tr;Zm.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=E_,this.W=new Array(160)}jt.inherits(Tr,Zm);eb.exports=Tr;Tr.blockSize=1024;Tr.outSize=512;Tr.hmacStrength=192;Tr.padLength=128;Tr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Md=Ir(),tb=Td();function Ni(){if(!(this instanceof Ni))return new Ni;tb.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Md.inherits(Ni,tb);rb.exports=Ni;Ni.blockSize=1024;Ni.outSize=384;Ni.hmacStrength=192;Ni.padLength=128;Ni.prototype._digest=function(e){return e==="hex"?Md.toHex32(this.h.slice(0,12),"big"):Md.split32(this.h.slice(0,12),"big")}});var nb=J(Ws=>{"use strict";Ws.sha1=$m();Ws.sha224=Ym();Ws.sha256=Ed();Ws.sha384=ib();Ws.sha512=Td()});var ub=J(fb=>{"use strict";var Yn=Ir(),F_=Vs(),lf=Yn.rotl32,sb=Yn.sum32,da=Yn.sum32_3,ob=Yn.sum32_4,cb=F_.BlockHash;function ci(){if(!(this instanceof ci))return new ci;cb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Yn.inherits(ci,cb);fb.ripemd160=ci;ci.blockSize=512;ci.outSize=160;ci.hmacStrength=192;ci.padLength=64;ci.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],f=i,u=n,g=s,y=o,S=a,I=0;I<80;I++){var A=sb(lf(ob(i,ab(I,n,s,o),e[B_[I]+t],U_(I)),z_[I]),a);i=a,a=o,o=lf(s,10),s=n,n=A,A=sb(lf(ob(f,ab(79-I,u,g,y),e[k_[I]+t],q_(I)),j_[I]),S),f=S,S=y,y=lf(g,10),g=u,u=A}A=da(this.h[1],s,y),this.h[1]=da(this.h[2],o,S),this.h[2]=da(this.h[3],a,f),this.h[3]=da(this.h[4],i,u),this.h[4]=da(this.h[0],n,g),this.h[0]=A};ci.prototype._digest=function(e){return e==="hex"?Yn.toHex32(this.h,"little"):Yn.split32(this.h,"little")};function ab(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function U_(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function q_(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var B_=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],k_=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],z_=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],j_=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var db=J((zC,hb)=>{"use strict";var K_=Ir(),V_=Qi();function Js(r,e,t){if(!(this instanceof Js))return new Js(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(K_.toArray(e,t))}hb.exports=Js;Js.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),V_(e.length<=this.blockSize);for(var t=e.length;t{var xt=lb;xt.utils=Ir();xt.common=Vs();xt.sha=nb();xt.ripemd=ub();xt.hmac=db();xt.sha1=xt.sha.sha1;xt.sha256=xt.sha.sha256;xt.sha224=xt.sha.sha224;xt.sha384=xt.sha.sha384;xt.sha512=xt.sha.sha512;xt.ripemd160=xt.ripemd.ripemd160});var Ib=J(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});var Nt=Ps(),Bd=fr(),tE=20;function rE(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,a=t[3]<<24|t[2]<<16|t[1]<<8|t[0],f=t[7]<<24|t[6]<<16|t[5]<<8|t[4],u=t[11]<<24|t[10]<<16|t[9]<<8|t[8],g=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],A=t[31]<<24|t[30]<<16|t[29]<<8|t[28],R=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],N=e[11]<<24|e[10]<<16|e[9]<<8|e[8],U=e[15]<<24|e[14]<<16|e[13]<<8|e[12],k=i,B=n,j=s,V=o,L=a,D=f,W=u,P=g,l=y,w=S,p=I,c=A,d=R,b=O,x=N,v=U,h=0;h>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,B=B+D|0,b^=B,b=b>>>16|b<<16,w=w+b|0,D^=w,D=D>>>20|D<<12,j=j+W|0,x^=j,x=x>>>16|x<<16,p=p+x|0,W^=p,W=W>>>20|W<<12,V=V+P|0,v^=V,v=v>>>16|v<<16,c=c+v|0,P^=c,P=P>>>20|P<<12,j=j+W|0,x^=j,x=x>>>24|x<<8,p=p+x|0,W^=p,W=W>>>25|W<<7,V=V+P|0,v^=V,v=v>>>24|v<<8,c=c+v|0,P^=c,P=P>>>25|P<<7,B=B+D|0,b^=B,b=b>>>24|b<<8,w=w+b|0,D^=w,D=D>>>25|D<<7,k=k+L|0,d^=k,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,k=k+D|0,v^=k,v=v>>>16|v<<16,p=p+v|0,D^=p,D=D>>>20|D<<12,B=B+W|0,d^=B,d=d>>>16|d<<16,c=c+d|0,W^=c,W=W>>>20|W<<12,j=j+P|0,b^=j,b=b>>>16|b<<16,l=l+b|0,P^=l,P=P>>>20|P<<12,V=V+L|0,x^=V,x=x>>>16|x<<16,w=w+x|0,L^=w,L=L>>>20|L<<12,j=j+P|0,b^=j,b=b>>>24|b<<8,l=l+b|0,P^=l,P=P>>>25|P<<7,V=V+L|0,x^=V,x=x>>>24|x<<8,w=w+x|0,L^=w,L=L>>>25|L<<7,B=B+W|0,d^=B,d=d>>>24|d<<8,c=c+d|0,W^=c,W=W>>>25|W<<7,k=k+D|0,v^=k,v=v>>>24|v<<8,p=p+v|0,D^=p,D=D>>>25|D<<7;Nt.writeUint32LE(k+i|0,r,0),Nt.writeUint32LE(B+n|0,r,4),Nt.writeUint32LE(j+s|0,r,8),Nt.writeUint32LE(V+o|0,r,12),Nt.writeUint32LE(L+a|0,r,16),Nt.writeUint32LE(D+f|0,r,20),Nt.writeUint32LE(W+u|0,r,24),Nt.writeUint32LE(P+g|0,r,28),Nt.writeUint32LE(l+y|0,r,32),Nt.writeUint32LE(w+S|0,r,36),Nt.writeUint32LE(p+I|0,r,40),Nt.writeUint32LE(c+A|0,r,44),Nt.writeUint32LE(d+R|0,r,48),Nt.writeUint32LE(b+O|0,r,52),Nt.writeUint32LE(x+N|0,r,56),Nt.writeUint32LE(v+U|0,r,60)}function Sb(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var xf=J(Xs=>{"use strict";Object.defineProperty(Xs,"__esModule",{value:!0});function sE(r,e,t){return~(r-1)&e|r-1&t}Xs.select=sE;function oE(r,e){return(r|0)-(e|0)-1>>>31&1}Xs.lessOrEqual=oE;function Ab(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Xs.compare=Ab;function aE(r,e){return r.length===0||e.length===0?!1:Ab(r,e)!==0}Xs.equal=aE});var Mb=J(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});var cE=xf(),_f=fr();Ci.DIGEST_LENGTH=16;var Tb=function(){function r(e){this.digestLength=Ci.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=(o>>>14|a<<2)&8191;var f=e[12]|e[13]<<8;this._r[7]=(a>>>11|f<<5)&8065;var u=e[14]|e[15]<<8;this._r[8]=(f>>>8|u<<8)&8191,this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],a=this._h[2],f=this._h[3],u=this._h[4],g=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],A=this._h[9],R=this._r[0],O=this._r[1],N=this._r[2],U=this._r[3],k=this._r[4],B=this._r[5],j=this._r[6],V=this._r[7],L=this._r[8],D=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var P=e[t+2]|e[t+3]<<8;o+=(W>>>13|P<<3)&8191;var l=e[t+4]|e[t+5]<<8;a+=(P>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;f+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;u+=(w>>>4|p<<12)&8191,g+=p>>>1&8191;var c=e[t+10]|e[t+11]<<8;y+=(p>>>14|c<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(c>>>11|d<<5)&8191;var b=e[t+14]|e[t+15]<<8;I+=(d>>>8|b<<8)&8191,A+=b>>>5|n;var x=0,v=x;v+=s*R,v+=o*(5*D),v+=a*(5*L),v+=f*(5*V),v+=u*(5*j),x=v>>>13,v&=8191,v+=g*(5*B),v+=y*(5*k),v+=S*(5*U),v+=I*(5*N),v+=A*(5*O),x+=v>>>13,v&=8191;var h=x;h+=s*O,h+=o*R,h+=a*(5*D),h+=f*(5*L),h+=u*(5*V),x=h>>>13,h&=8191,h+=g*(5*j),h+=y*(5*B),h+=S*(5*k),h+=I*(5*U),h+=A*(5*N),x+=h>>>13,h&=8191;var _=x;_+=s*N,_+=o*O,_+=a*R,_+=f*(5*D),_+=u*(5*L),x=_>>>13,_&=8191,_+=g*(5*V),_+=y*(5*j),_+=S*(5*B),_+=I*(5*k),_+=A*(5*U),x+=_>>>13,_&=8191;var T=x;T+=s*U,T+=o*N,T+=a*O,T+=f*R,T+=u*(5*D),x=T>>>13,T&=8191,T+=g*(5*L),T+=y*(5*V),T+=S*(5*j),T+=I*(5*B),T+=A*(5*k),x+=T>>>13,T&=8191;var m=x;m+=s*k,m+=o*U,m+=a*N,m+=f*O,m+=u*R,x=m>>>13,m&=8191,m+=g*(5*D),m+=y*(5*L),m+=S*(5*V),m+=I*(5*j),m+=A*(5*B),x+=m>>>13,m&=8191;var M=x;M+=s*B,M+=o*k,M+=a*U,M+=f*N,M+=u*O,x=M>>>13,M&=8191,M+=g*R,M+=y*(5*D),M+=S*(5*L),M+=I*(5*V),M+=A*(5*j),x+=M>>>13,M&=8191;var z=x;z+=s*j,z+=o*B,z+=a*k,z+=f*U,z+=u*N,x=z>>>13,z&=8191,z+=g*O,z+=y*R,z+=S*(5*D),z+=I*(5*L),z+=A*(5*V),x+=z>>>13,z&=8191;var E=x;E+=s*V,E+=o*j,E+=a*B,E+=f*k,E+=u*U,x=E>>>13,E&=8191,E+=g*N,E+=y*O,E+=S*R,E+=I*(5*D),E+=A*(5*L),x+=E>>>13,E&=8191;var C=x;C+=s*L,C+=o*V,C+=a*j,C+=f*B,C+=u*k,x=C>>>13,C&=8191,C+=g*U,C+=y*N,C+=S*O,C+=I*R,C+=A*(5*D),x+=C>>>13,C&=8191;var F=x;F+=s*D,F+=o*L,F+=a*V,F+=f*j,F+=u*B,x=F>>>13,F&=8191,F+=g*k,F+=y*U,F+=S*N,F+=I*O,F+=A*R,x+=F>>>13,F&=8191,x=(x<<2)+x|0,x=x+v|0,v=x&8191,x=x>>>13,h+=x,s=v,o=h,a=_,f=T,u=m,g=M,y=z,S=E,I=C,A=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=a,this._h[3]=f,this._h[4]=u,this._h[5]=g,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=A},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,a;if(this._leftover){for(a=this._leftover,this._buffer[a++]=1;a<16;a++)this._buffer[a]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,a=2;a<10;a++)this._h[a]+=n,n=this._h[a]>>>13,this._h[a]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,a=1;a<10;a++)i[a]=this._h[a]+n,n=i[a]>>>13,i[a]&=8191;for(i[9]-=8192,s=(n^1)-1,a=0;a<10;a++)i[a]&=s;for(s=~s,a=0;a<10;a++)this._h[a]=this._h[a]&s|i[a];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,a=1;a<8;a++)o=(this._h[a]+this._pad[a]|0)+(o>>>16)|0,this._h[a]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});var Ef=Ib(),hE=Mb(),pa=fr(),Rb=Ps(),dE=xf();Di.KEY_LENGTH=32;Di.NONCE_LENGTH=12;Di.TAG_LENGTH=16;var Pb=new Uint8Array(16),lE=function(){function r(e){if(this.nonceLength=Di.NONCE_LENGTH,this.tagLength=Di.TAG_LENGTH,e.length!==Di.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);Ef.stream(this._key,s,o,4);var a=t.length+this.tagLength,f;if(n){if(n.length!==a)throw new Error("ChaCha20Poly1305: incorrect destination length");f=n}else f=new Uint8Array(a);return Ef.streamXOR(this._key,s,t,f,4),this._authenticate(f.subarray(f.length-this.tagLength,f.length),o,f.subarray(0,f.length-this.tagLength),i),pa.wipe(s),f},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(Pb.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(Pb.subarray(i.length%16));var o=new Uint8Array(8);n&&Rb.writeUint64LE(n.length,o),s.update(o),Rb.writeUint64LE(i.length,o),s.update(o);for(var a=s.digest(),f=0;f{"use strict";Object.defineProperty(kd,"__esModule",{value:!0});function pE(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}kd.isSerializableHash=pE});var Ob=J(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});var hi=Cb(),gE=xf(),mE=fr(),Db=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(zd,"__esModule",{value:!0});var Lb=Ob(),Fb=fr(),vE=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Lb.hmac(this._hash,i,t);this._hmac=new Lb.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});var If=Ps(),Sf=fr();rn.DIGEST_LENGTH=32;rn.BLOCK_SIZE=64;var qb=function(){function r(){this.digestLength=rn.DIGEST_LENGTH,this.blockSize=rn.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Sf.wipe(this._buffer),Sf.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jd(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jd(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Sf.wipe(e.state),e.buffer&&Sf.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();rn.SHA256=qb;var yE=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function jd(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],a=e[2],f=e[3],u=e[4],g=e[5],y=e[6],S=e[7],I=0;I<16;I++){var A=i+I*4;r[I]=If.readUint32BE(t,A)}for(var I=16;I<64;I++){var R=r[I-2],O=(R>>>17|R<<15)^(R>>>19|R<<13)^R>>>10;R=r[I-15];var N=(R>>>7|R<<25)^(R>>>18|R<<14)^R>>>3;r[I]=(O+r[I-7]|0)+(N+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&g^~u&y)|0)+(S+(yE[I]+r[I]|0)|0)|0,N=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&a^o&a)|0;S=y,y=g,g=u,u=f+O|0,f=a,a=o,o=s,s=O+N|0}e[0]+=s,e[1]+=o,e[2]+=a,e[3]+=f,e[4]+=u,e[5]+=g,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function wE(r){var e=new qb;e.update(r);var t=e.digest();return e.clean(),t}rn.hash=wE});var Kb=J(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.sharedKey=it.generateKeyPair=it.generateKeyPairFromSeed=it.scalarMultBase=it.scalarMult=it.SHARED_KEY_LENGTH=it.SECRET_KEY_LENGTH=it.PUBLIC_KEY_LENGTH=void 0;var xE=Yo(),_E=fr();it.PUBLIC_KEY_LENGTH=32;it.SECRET_KEY_LENGTH=32;it.SHARED_KEY_LENGTH=32;function di(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,ma(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function IE(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Af(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function Tf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function Oi(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,R=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,D=0,W=0,P=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],T=t[1],m=t[2],M=t[3],z=t[4],E=t[5],C=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*T,a+=i*m,f+=i*M,u+=i*z,g+=i*E,y+=i*C,S+=i*F,I+=i*q,A+=i*K,R+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*T,f+=i*m,u+=i*M,g+=i*z,y+=i*E,S+=i*C,I+=i*F,A+=i*q,R+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*T,u+=i*m,g+=i*M,y+=i*z,S+=i*E,I+=i*C,A+=i*F,R+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*T,g+=i*m,y+=i*M,S+=i*z,I+=i*E,A+=i*C,R+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*T,y+=i*m,S+=i*M,I+=i*z,A+=i*E,R+=i*C,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,D+=i*X,i=e[5],g+=i*_,y+=i*T,S+=i*m,I+=i*M,A+=i*z,R+=i*E,O+=i*C,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,D+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*T,I+=i*m,A+=i*M,R+=i*z,O+=i*E,N+=i*C,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,D+=i*ee,W+=i*G,P+=i*X,i=e[7],S+=i*_,I+=i*T,A+=i*m,R+=i*M,O+=i*z,N+=i*E,U+=i*C,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,D+=i*$,W+=i*ee,P+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*T,R+=i*m,O+=i*M,N+=i*z,U+=i*E,k+=i*C,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,D+=i*H,W+=i*$,P+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,R+=i*T,O+=i*m,N+=i*M,U+=i*z,k+=i*E,B+=i*C,j+=i*F,V+=i*q,L+=i*K,D+=i*Y,W+=i*H,P+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],R+=i*_,O+=i*T,N+=i*m,U+=i*M,k+=i*z,B+=i*E,j+=i*C,V+=i*F,L+=i*q,D+=i*K,W+=i*Y,P+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*T,U+=i*m,k+=i*M,B+=i*z,j+=i*E,V+=i*C,L+=i*F,D+=i*q,W+=i*K,P+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*T,k+=i*m,B+=i*M,j+=i*z,V+=i*E,L+=i*C,D+=i*F,W+=i*q,P+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*T,B+=i*m,j+=i*M,V+=i*z,L+=i*E,D+=i*C,W+=i*F,P+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*T,j+=i*m,V+=i*M,L+=i*z,D+=i*E,W+=i*C,P+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*T,V+=i*m,L+=i*M,D+=i*z,W+=i*E,P+=i*C,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*D,u+=38*W,g+=38*P,y+=38*l,S+=38*w,I+=38*p,A+=38*c,R+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=R+n+65535,n=Math.floor(i/65536),R=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=R,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function ba(r,e){Oi(r,e,e)}function AE(r,e){let t=di();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)ba(t,t),i!==2&&i!==4&&Oi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function Vd(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=di(),s=di(),o=di(),a=di(),f=di(),u=di();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,IE(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=a[0]=1;for(let I=254;I>=0;--I){let A=t[I>>>3]>>>(I&7)&1;ma(n,s,A),ma(o,a,A),Af(f,n,o),Tf(n,n,o),Af(o,s,a),Tf(s,s,a),ba(a,f),ba(u,n),Oi(n,o,n),Oi(o,s,f),Af(f,n,o),Tf(n,n,o),ba(s,n),Tf(o,a,u),Oi(n,o,EE),Af(n,n,a),Oi(o,o,n),Oi(n,a,u),Oi(a,s,i),ba(s,f),ma(n,s,A),ma(o,a,A)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=a[I];let g=i.subarray(32),y=i.subarray(16);AE(g,g),Oi(y,y,g);let S=new Uint8Array(32);return SE(S,y),S}it.scalarMult=Vd;function zb(r){return Vd(r,kb)}it.scalarMultBase=zb;function jb(r){if(r.length!==it.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${it.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:zb(e),secretKey:e}}it.generateKeyPairFromSeed=jb;function TE(r){let e=(0,xE.randomBytes)(32,r),t=jb(e);return(0,_E.wipe)(e),t}it.generateKeyPair=TE;function ME(r,e,t=!1){if(r.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=Vd(r,e);if(t){let n=0;for(let s=0;s{RE.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var li=J(($b,$d)=>{(function(r,e){"use strict";function t(P,l){if(!P)throw new Error(l||"Assertion failed")}function i(P,l){P.super_=l;var w=function(){};w.prototype=l.prototype,P.prototype=new w,P.prototype.constructor=P}function n(P,l,w){if(n.isBN(P))return P;this.negative=0,this.words=null,this.length=0,this.red=null,P!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(P||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=gd().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var c=0;l[0]==="-"&&(c++,this.negative=1),c=0;c-=3)b=l[c]|l[c-1]<<8|l[c-2]<<16,this.words[d]|=b<>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);else if(p==="le")for(c=0,d=0;c>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);return this.strip()};function o(P,l){var w=P.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function a(P,l,w){var p=o(P,w);return w-1>=l&&(p|=o(P,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var c=0;c=w;c-=2)x=a(l,w,c)<=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8;else{var v=l.length-w;for(c=v%2===0?w+1:w;c=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8}this.strip()};function f(P,l,w,p){for(var c=0,d=Math.min(P.length,w),b=l;b=49?c+=x-49+10:x>=17?c+=x-17+10:c+=x}return c}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var c=0,d=1;d<=67108863;d*=w)c++;c--,d=d/w|0;for(var b=l.length-p,x=b%c,v=Math.min(b,b-x)+p,h=0,_=p;_1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var c=0,d=0,b=0;b>>24-c&16777215,d!==0||b!==this.length-1?p=u[6-v.length]+v+p:p=v+p,c+=2,c>=26&&(c-=26,b--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=g[l],_=y[l];p="";var T=this.clone();for(T.negative=0;!T.isZero();){var m=T.modn(_).toString(l);T=T.idivn(_),T.isZero()?p=m+p:p=u[h-m.length]+m+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var c=this.byteLength(),d=p||Math.max(1,c);t(c<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var b=w==="le",x=new l(d),v,h,_=this.clone();if(b){for(h=0;!_.isZero();h++)v=_.andln(255),_.iushrn(8),x[h]=v;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(P){for(var l=new Array(P.bitLength()),w=0;w>>c}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var c=0;cl.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var c=0;c0&&(this.words[c]=~this.words[c]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,c=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,c=l):(p=l,c=this);for(var d=0,b=0;b>>26;for(;d!==0&&b>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;bl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var c,d;p>0?(c=this,d=l):(c=l,d=this);for(var b=0,x=0;x>26,this.words[x]=w&67108863;for(;b!==0&&x>26,this.words[x]=w&67108863;if(b===0&&x>>26,T=v&67108863,m=Math.min(h,l.length-1),M=Math.max(0,h-P.length+1);M<=m;M++){var z=h-M|0;c=P.words[z]|0,d=l.words[M]|0,b=c*d+T,_+=b/67108864|0,T=b&67108863}w.words[h]=T|0,v=_|0}return v!==0?w.words[h]=v|0:w.length--,w.strip()}var A=function(l,w,p){var c=l.words,d=w.words,b=p.words,x=0,v,h,_,T=c[0]|0,m=T&8191,M=T>>>13,z=c[1]|0,E=z&8191,C=z>>>13,F=c[2]|0,q=F&8191,K=F>>>13,Y=c[3]|0,H=Y&8191,$=Y>>>13,ee=c[4]|0,G=ee&8191,X=ee>>>13,qr=c[5]|0,se=qr&8191,oe=qr>>>13,Br=c[6]|0,ae=Br&8191,ce=Br>>>13,kr=c[7]|0,fe=kr&8191,ue=kr>>>13,zr=c[8]|0,he=zr&8191,de=zr>>>13,jr=c[9]|0,le=jr&8191,pe=jr>>>13,Kr=d[0]|0,ge=Kr&8191,me=Kr>>>13,Vr=d[1]|0,be=Vr&8191,ve=Vr>>>13,$r=d[2]|0,ye=$r&8191,we=$r>>>13,Hr=d[3]|0,xe=Hr&8191,_e=Hr>>>13,Gr=d[4]|0,Ee=Gr&8191,Se=Gr>>>13,Wr=d[5]|0,Ie=Wr&8191,Ae=Wr>>>13,Jr=d[6]|0,Te=Jr&8191,Me=Jr>>>13,Yr=d[7]|0,Re=Yr&8191,Pe=Yr>>>13,Xr=d[8]|0,Ne=Xr&8191,Ce=Xr>>>13,Qr=d[9]|0,De=Qr&8191,Oe=Qr>>>13;p.negative=l.negative^w.negative,p.length=19,v=Math.imul(m,ge),h=Math.imul(m,me),h=h+Math.imul(M,ge)|0,_=Math.imul(M,me);var yr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(yr>>>26)|0,yr&=67108863,v=Math.imul(E,ge),h=Math.imul(E,me),h=h+Math.imul(C,ge)|0,_=Math.imul(C,me),v=v+Math.imul(m,be)|0,h=h+Math.imul(m,ve)|0,h=h+Math.imul(M,be)|0,_=_+Math.imul(M,ve)|0;var Ke=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,v=Math.imul(q,ge),h=Math.imul(q,me),h=h+Math.imul(K,ge)|0,_=Math.imul(K,me),v=v+Math.imul(E,be)|0,h=h+Math.imul(E,ve)|0,h=h+Math.imul(C,be)|0,_=_+Math.imul(C,ve)|0,v=v+Math.imul(m,ye)|0,h=h+Math.imul(m,we)|0,h=h+Math.imul(M,ye)|0,_=_+Math.imul(M,we)|0;var Ve=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,v=Math.imul(H,ge),h=Math.imul(H,me),h=h+Math.imul($,ge)|0,_=Math.imul($,me),v=v+Math.imul(q,be)|0,h=h+Math.imul(q,ve)|0,h=h+Math.imul(K,be)|0,_=_+Math.imul(K,ve)|0,v=v+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(C,ye)|0,_=_+Math.imul(C,we)|0,v=v+Math.imul(m,xe)|0,h=h+Math.imul(m,_e)|0,h=h+Math.imul(M,xe)|0,_=_+Math.imul(M,_e)|0;var rr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(rr>>>26)|0,rr&=67108863,v=Math.imul(G,ge),h=Math.imul(G,me),h=h+Math.imul(X,ge)|0,_=Math.imul(X,me),v=v+Math.imul(H,be)|0,h=h+Math.imul(H,ve)|0,h=h+Math.imul($,be)|0,_=_+Math.imul($,ve)|0,v=v+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,_=_+Math.imul(K,we)|0,v=v+Math.imul(E,xe)|0,h=h+Math.imul(E,_e)|0,h=h+Math.imul(C,xe)|0,_=_+Math.imul(C,_e)|0,v=v+Math.imul(m,Ee)|0,h=h+Math.imul(m,Se)|0,h=h+Math.imul(M,Ee)|0,_=_+Math.imul(M,Se)|0;var ir=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(ir>>>26)|0,ir&=67108863,v=Math.imul(se,ge),h=Math.imul(se,me),h=h+Math.imul(oe,ge)|0,_=Math.imul(oe,me),v=v+Math.imul(G,be)|0,h=h+Math.imul(G,ve)|0,h=h+Math.imul(X,be)|0,_=_+Math.imul(X,ve)|0,v=v+Math.imul(H,ye)|0,h=h+Math.imul(H,we)|0,h=h+Math.imul($,ye)|0,_=_+Math.imul($,we)|0,v=v+Math.imul(q,xe)|0,h=h+Math.imul(q,_e)|0,h=h+Math.imul(K,xe)|0,_=_+Math.imul(K,_e)|0,v=v+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(C,Ee)|0,_=_+Math.imul(C,Se)|0,v=v+Math.imul(m,Ie)|0,h=h+Math.imul(m,Ae)|0,h=h+Math.imul(M,Ie)|0,_=_+Math.imul(M,Ae)|0;var nr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,v=Math.imul(ae,ge),h=Math.imul(ae,me),h=h+Math.imul(ce,ge)|0,_=Math.imul(ce,me),v=v+Math.imul(se,be)|0,h=h+Math.imul(se,ve)|0,h=h+Math.imul(oe,be)|0,_=_+Math.imul(oe,ve)|0,v=v+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(X,ye)|0,_=_+Math.imul(X,we)|0,v=v+Math.imul(H,xe)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul($,xe)|0,_=_+Math.imul($,_e)|0,v=v+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,_=_+Math.imul(K,Se)|0,v=v+Math.imul(E,Ie)|0,h=h+Math.imul(E,Ae)|0,h=h+Math.imul(C,Ie)|0,_=_+Math.imul(C,Ae)|0,v=v+Math.imul(m,Te)|0,h=h+Math.imul(m,Me)|0,h=h+Math.imul(M,Te)|0,_=_+Math.imul(M,Me)|0;var sr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(sr>>>26)|0,sr&=67108863,v=Math.imul(fe,ge),h=Math.imul(fe,me),h=h+Math.imul(ue,ge)|0,_=Math.imul(ue,me),v=v+Math.imul(ae,be)|0,h=h+Math.imul(ae,ve)|0,h=h+Math.imul(ce,be)|0,_=_+Math.imul(ce,ve)|0,v=v+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,_=_+Math.imul(oe,we)|0,v=v+Math.imul(G,xe)|0,h=h+Math.imul(G,_e)|0,h=h+Math.imul(X,xe)|0,_=_+Math.imul(X,_e)|0,v=v+Math.imul(H,Ee)|0,h=h+Math.imul(H,Se)|0,h=h+Math.imul($,Ee)|0,_=_+Math.imul($,Se)|0,v=v+Math.imul(q,Ie)|0,h=h+Math.imul(q,Ae)|0,h=h+Math.imul(K,Ie)|0,_=_+Math.imul(K,Ae)|0,v=v+Math.imul(E,Te)|0,h=h+Math.imul(E,Me)|0,h=h+Math.imul(C,Te)|0,_=_+Math.imul(C,Me)|0,v=v+Math.imul(m,Re)|0,h=h+Math.imul(m,Pe)|0,h=h+Math.imul(M,Re)|0,_=_+Math.imul(M,Pe)|0;var or=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(or>>>26)|0,or&=67108863,v=Math.imul(he,ge),h=Math.imul(he,me),h=h+Math.imul(de,ge)|0,_=Math.imul(de,me),v=v+Math.imul(fe,be)|0,h=h+Math.imul(fe,ve)|0,h=h+Math.imul(ue,be)|0,_=_+Math.imul(ue,ve)|0,v=v+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(ce,ye)|0,_=_+Math.imul(ce,we)|0,v=v+Math.imul(se,xe)|0,h=h+Math.imul(se,_e)|0,h=h+Math.imul(oe,xe)|0,_=_+Math.imul(oe,_e)|0,v=v+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(X,Ee)|0,_=_+Math.imul(X,Se)|0,v=v+Math.imul(H,Ie)|0,h=h+Math.imul(H,Ae)|0,h=h+Math.imul($,Ie)|0,_=_+Math.imul($,Ae)|0,v=v+Math.imul(q,Te)|0,h=h+Math.imul(q,Me)|0,h=h+Math.imul(K,Te)|0,_=_+Math.imul(K,Me)|0,v=v+Math.imul(E,Re)|0,h=h+Math.imul(E,Pe)|0,h=h+Math.imul(C,Re)|0,_=_+Math.imul(C,Pe)|0,v=v+Math.imul(m,Ne)|0,h=h+Math.imul(m,Ce)|0,h=h+Math.imul(M,Ne)|0,_=_+Math.imul(M,Ce)|0;var Tn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,v=Math.imul(le,ge),h=Math.imul(le,me),h=h+Math.imul(pe,ge)|0,_=Math.imul(pe,me),v=v+Math.imul(he,be)|0,h=h+Math.imul(he,ve)|0,h=h+Math.imul(de,be)|0,_=_+Math.imul(de,ve)|0,v=v+Math.imul(fe,ye)|0,h=h+Math.imul(fe,we)|0,h=h+Math.imul(ue,ye)|0,_=_+Math.imul(ue,we)|0,v=v+Math.imul(ae,xe)|0,h=h+Math.imul(ae,_e)|0,h=h+Math.imul(ce,xe)|0,_=_+Math.imul(ce,_e)|0,v=v+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,_=_+Math.imul(oe,Se)|0,v=v+Math.imul(G,Ie)|0,h=h+Math.imul(G,Ae)|0,h=h+Math.imul(X,Ie)|0,_=_+Math.imul(X,Ae)|0,v=v+Math.imul(H,Te)|0,h=h+Math.imul(H,Me)|0,h=h+Math.imul($,Te)|0,_=_+Math.imul($,Me)|0,v=v+Math.imul(q,Re)|0,h=h+Math.imul(q,Pe)|0,h=h+Math.imul(K,Re)|0,_=_+Math.imul(K,Pe)|0,v=v+Math.imul(E,Ne)|0,h=h+Math.imul(E,Ce)|0,h=h+Math.imul(C,Ne)|0,_=_+Math.imul(C,Ce)|0,v=v+Math.imul(m,De)|0,h=h+Math.imul(m,Oe)|0,h=h+Math.imul(M,De)|0,_=_+Math.imul(M,Oe)|0;var Mn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,v=Math.imul(le,be),h=Math.imul(le,ve),h=h+Math.imul(pe,be)|0,_=Math.imul(pe,ve),v=v+Math.imul(he,ye)|0,h=h+Math.imul(he,we)|0,h=h+Math.imul(de,ye)|0,_=_+Math.imul(de,we)|0,v=v+Math.imul(fe,xe)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(ue,xe)|0,_=_+Math.imul(ue,_e)|0,v=v+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(ce,Ee)|0,_=_+Math.imul(ce,Se)|0,v=v+Math.imul(se,Ie)|0,h=h+Math.imul(se,Ae)|0,h=h+Math.imul(oe,Ie)|0,_=_+Math.imul(oe,Ae)|0,v=v+Math.imul(G,Te)|0,h=h+Math.imul(G,Me)|0,h=h+Math.imul(X,Te)|0,_=_+Math.imul(X,Me)|0,v=v+Math.imul(H,Re)|0,h=h+Math.imul(H,Pe)|0,h=h+Math.imul($,Re)|0,_=_+Math.imul($,Pe)|0,v=v+Math.imul(q,Ne)|0,h=h+Math.imul(q,Ce)|0,h=h+Math.imul(K,Ne)|0,_=_+Math.imul(K,Ce)|0,v=v+Math.imul(E,De)|0,h=h+Math.imul(E,Oe)|0,h=h+Math.imul(C,De)|0,_=_+Math.imul(C,Oe)|0;var Rn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,v=Math.imul(le,ye),h=Math.imul(le,we),h=h+Math.imul(pe,ye)|0,_=Math.imul(pe,we),v=v+Math.imul(he,xe)|0,h=h+Math.imul(he,_e)|0,h=h+Math.imul(de,xe)|0,_=_+Math.imul(de,_e)|0,v=v+Math.imul(fe,Ee)|0,h=h+Math.imul(fe,Se)|0,h=h+Math.imul(ue,Ee)|0,_=_+Math.imul(ue,Se)|0,v=v+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Ae)|0,h=h+Math.imul(ce,Ie)|0,_=_+Math.imul(ce,Ae)|0,v=v+Math.imul(se,Te)|0,h=h+Math.imul(se,Me)|0,h=h+Math.imul(oe,Te)|0,_=_+Math.imul(oe,Me)|0,v=v+Math.imul(G,Re)|0,h=h+Math.imul(G,Pe)|0,h=h+Math.imul(X,Re)|0,_=_+Math.imul(X,Pe)|0,v=v+Math.imul(H,Ne)|0,h=h+Math.imul(H,Ce)|0,h=h+Math.imul($,Ne)|0,_=_+Math.imul($,Ce)|0,v=v+Math.imul(q,De)|0,h=h+Math.imul(q,Oe)|0,h=h+Math.imul(K,De)|0,_=_+Math.imul(K,Oe)|0;var Pn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,v=Math.imul(le,xe),h=Math.imul(le,_e),h=h+Math.imul(pe,xe)|0,_=Math.imul(pe,_e),v=v+Math.imul(he,Ee)|0,h=h+Math.imul(he,Se)|0,h=h+Math.imul(de,Ee)|0,_=_+Math.imul(de,Se)|0,v=v+Math.imul(fe,Ie)|0,h=h+Math.imul(fe,Ae)|0,h=h+Math.imul(ue,Ie)|0,_=_+Math.imul(ue,Ae)|0,v=v+Math.imul(ae,Te)|0,h=h+Math.imul(ae,Me)|0,h=h+Math.imul(ce,Te)|0,_=_+Math.imul(ce,Me)|0,v=v+Math.imul(se,Re)|0,h=h+Math.imul(se,Pe)|0,h=h+Math.imul(oe,Re)|0,_=_+Math.imul(oe,Pe)|0,v=v+Math.imul(G,Ne)|0,h=h+Math.imul(G,Ce)|0,h=h+Math.imul(X,Ne)|0,_=_+Math.imul(X,Ce)|0,v=v+Math.imul(H,De)|0,h=h+Math.imul(H,Oe)|0,h=h+Math.imul($,De)|0,_=_+Math.imul($,Oe)|0;var Nn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,v=Math.imul(le,Ee),h=Math.imul(le,Se),h=h+Math.imul(pe,Ee)|0,_=Math.imul(pe,Se),v=v+Math.imul(he,Ie)|0,h=h+Math.imul(he,Ae)|0,h=h+Math.imul(de,Ie)|0,_=_+Math.imul(de,Ae)|0,v=v+Math.imul(fe,Te)|0,h=h+Math.imul(fe,Me)|0,h=h+Math.imul(ue,Te)|0,_=_+Math.imul(ue,Me)|0,v=v+Math.imul(ae,Re)|0,h=h+Math.imul(ae,Pe)|0,h=h+Math.imul(ce,Re)|0,_=_+Math.imul(ce,Pe)|0,v=v+Math.imul(se,Ne)|0,h=h+Math.imul(se,Ce)|0,h=h+Math.imul(oe,Ne)|0,_=_+Math.imul(oe,Ce)|0,v=v+Math.imul(G,De)|0,h=h+Math.imul(G,Oe)|0,h=h+Math.imul(X,De)|0,_=_+Math.imul(X,Oe)|0;var Cn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Cn>>>26)|0,Cn&=67108863,v=Math.imul(le,Ie),h=Math.imul(le,Ae),h=h+Math.imul(pe,Ie)|0,_=Math.imul(pe,Ae),v=v+Math.imul(he,Te)|0,h=h+Math.imul(he,Me)|0,h=h+Math.imul(de,Te)|0,_=_+Math.imul(de,Me)|0,v=v+Math.imul(fe,Re)|0,h=h+Math.imul(fe,Pe)|0,h=h+Math.imul(ue,Re)|0,_=_+Math.imul(ue,Pe)|0,v=v+Math.imul(ae,Ne)|0,h=h+Math.imul(ae,Ce)|0,h=h+Math.imul(ce,Ne)|0,_=_+Math.imul(ce,Ce)|0,v=v+Math.imul(se,De)|0,h=h+Math.imul(se,Oe)|0,h=h+Math.imul(oe,De)|0,_=_+Math.imul(oe,Oe)|0;var Dn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,v=Math.imul(le,Te),h=Math.imul(le,Me),h=h+Math.imul(pe,Te)|0,_=Math.imul(pe,Me),v=v+Math.imul(he,Re)|0,h=h+Math.imul(he,Pe)|0,h=h+Math.imul(de,Re)|0,_=_+Math.imul(de,Pe)|0,v=v+Math.imul(fe,Ne)|0,h=h+Math.imul(fe,Ce)|0,h=h+Math.imul(ue,Ne)|0,_=_+Math.imul(ue,Ce)|0,v=v+Math.imul(ae,De)|0,h=h+Math.imul(ae,Oe)|0,h=h+Math.imul(ce,De)|0,_=_+Math.imul(ce,Oe)|0;var On=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(On>>>26)|0,On&=67108863,v=Math.imul(le,Re),h=Math.imul(le,Pe),h=h+Math.imul(pe,Re)|0,_=Math.imul(pe,Pe),v=v+Math.imul(he,Ne)|0,h=h+Math.imul(he,Ce)|0,h=h+Math.imul(de,Ne)|0,_=_+Math.imul(de,Ce)|0,v=v+Math.imul(fe,De)|0,h=h+Math.imul(fe,Oe)|0,h=h+Math.imul(ue,De)|0,_=_+Math.imul(ue,Oe)|0;var Ln=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ln>>>26)|0,Ln&=67108863,v=Math.imul(le,Ne),h=Math.imul(le,Ce),h=h+Math.imul(pe,Ne)|0,_=Math.imul(pe,Ce),v=v+Math.imul(he,De)|0,h=h+Math.imul(he,Oe)|0,h=h+Math.imul(de,De)|0,_=_+Math.imul(de,Oe)|0;var Fn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Fn>>>26)|0,Fn&=67108863,v=Math.imul(le,De),h=Math.imul(le,Oe),h=h+Math.imul(pe,De)|0,_=Math.imul(pe,Oe);var Un=(x+v|0)+((h&8191)<<13)|0;return x=(_+(h>>>13)|0)+(Un>>>26)|0,Un&=67108863,b[0]=yr,b[1]=Ke,b[2]=Ve,b[3]=rr,b[4]=ir,b[5]=nr,b[6]=sr,b[7]=or,b[8]=Tn,b[9]=Mn,b[10]=Rn,b[11]=Pn,b[12]=Nn,b[13]=Cn,b[14]=Dn,b[15]=On,b[16]=Ln,b[17]=Fn,b[18]=Un,x!==0&&(b[19]=x,p.length++),p};Math.imul||(A=I);function R(P,l,w){w.negative=l.negative^P.negative,w.length=P.length+l.length;for(var p=0,c=0,d=0;d>>26)|0,c+=b>>>26,b&=67108863}w.words[d]=x,p=b,b=c}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(P,l,w){var p=new N;return p.mulp(P,l,w)}n.prototype.mulTo=function(l,w){var p,c=this.length+l.length;return this.length===10&&l.length===10?p=A(this,l,w):c<63?p=I(this,l,w):c<1024?p=R(this,l,w):p=O(this,l,w),p};function N(P,l){this.x=P,this.y=l}N.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,c=0;c>=1;return c},N.prototype.permute=function(l,w,p,c,d,b){for(var x=0;x>>1)d++;return 1<>>13,p[2*b+1]=d&8191,d=d>>>13;for(b=2*w;b>=26,w+=c/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,c=0;c=0);var w=l%26,p=(l-w)/26,c=67108863>>>26-w<<26-w,d;if(w!==0){var b=0;for(d=0;d>>26-w}b&&(this.words[d]=b,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var c;w?c=(w-w%26)/26:c=0;var d=l%26,b=Math.min((l-d)/26,this.length),x=67108863^67108863>>>d<b)for(this.length-=b,h=0;h=0&&(_!==0||h>=c);h--){var T=this.words[h]|0;this.words[h]=_<<26-d|T>>>d,_=T&x}return v&&_!==0&&(v.words[v.length++]=_),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,c=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var c=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(v/67108864|0),this.words[d+p]=b&67108863}for(;d>26,this.words[d+p]=b&67108863;if(x===0)return this.strip();for(t(x===-1),x=0,d=0;d>26,this.words[d]=b&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,c=this.clone(),d=l,b=d.words[d.length-1]|0,x=this._countBits(b);p=26-x,p!==0&&(d=d.ushln(p),c.iushln(p),b=d.words[d.length-1]|0);var v=c.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=v+1,h.words=new Array(h.length);for(var _=0;_=0;m--){var M=(c.words[d.length+m]|0)*67108864+(c.words[d.length+m-1]|0);for(M=Math.min(M/b|0,67108863),c._ishlnsubmul(d,M,m);c.negative!==0;)M--,c.negative=0,c._ishlnsubmul(d,1,m),c.isZero()||(c.negative^=1);h&&(h.words[m]=M)}return h&&h.strip(),c.strip(),w!=="div"&&p!==0&&c.iushrn(p),{div:h||null,mod:c}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var c,d,b;return this.negative!==0&&l.negative===0?(b=this.neg().divmod(l,w),w!=="mod"&&(c=b.div.neg()),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:c,mod:d}):this.negative===0&&l.negative!==0?(b=this.divmod(l.neg(),w),w!=="mod"&&(c=b.div.neg()),{div:c,mod:b.mod}):this.negative&l.negative?(b=this.neg().divmod(l.neg(),w),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:b.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,c=l.ushrn(1),d=l.andln(1),b=p.cmp(c);return b<0||d===1&&b===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,c=this.length-1;c>=0;c--)p=(w*p+(this.words[c]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var c=(this.words[p]|0)+w*67108864;this.words[p]=c/l|0,w=c%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=new n(0),x=new n(1),v=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++v;for(var h=p.clone(),_=w.clone();!w.isZero();){for(var T=0,m=1;!(w.words[0]&m)&&T<26;++T,m<<=1);if(T>0)for(w.iushrn(T);T-- >0;)(c.isOdd()||d.isOdd())&&(c.iadd(h),d.isub(_)),c.iushrn(1),d.iushrn(1);for(var M=0,z=1;!(p.words[0]&z)&&M<26;++M,z<<=1);if(M>0)for(p.iushrn(M);M-- >0;)(b.isOdd()||x.isOdd())&&(b.iadd(h),x.isub(_)),b.iushrn(1),x.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(b),d.isub(x)):(p.isub(w),b.isub(c),x.isub(d))}return{a:b,b:x,gcd:p.iushln(v)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var x=0,v=1;!(w.words[0]&v)&&x<26;++x,v<<=1);if(x>0)for(w.iushrn(x);x-- >0;)c.isOdd()&&c.iadd(b),c.iushrn(1);for(var h=0,_=1;!(p.words[0]&_)&&h<26;++h,_<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(b),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(d)):(p.isub(w),d.isub(c))}var T;return w.cmpn(1)===0?T=c:T=d,T.cmpn(0)<0&&T.iadd(l),T},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var c=0;w.isEven()&&p.isEven();c++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var b=w;w=p,p=b}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(c)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,c=1<>>26,x&=67108863,this.words[b]=x}return d!==0&&(this.words[b]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var c=this.words[0]|0;p=c===l?0:cl.length)return 1;if(this.length=0;p--){var c=this.words[p]|0,d=l.words[p]|0;if(c!==d){cd&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new D(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var U={k256:null,p224:null,p192:null,p25519:null};function k(P,l){this.name=P,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}k.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},k.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var c=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},k.prototype.split=function(l,w){l.iushrn(this.n,0,w)},k.prototype.imulK=function(l){return l.imul(this.k)};function B(){k.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(B,k),B.prototype.split=function(l,w){for(var p=4194303,c=Math.min(l.length,9),d=0;d>>22,b=x}b>>>=22,l.words[d-10]=b,b===0&&l.length>10?l.length-=10:l.length-=9},B.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=c}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(U[l])return U[l];var w;if(l==="k256")w=new B;else if(l==="p224")w=new j;else if(l==="p192")w=new V;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return U[l]=w,w};function D(P){if(typeof P=="string"){var l=n._prime(P);this.m=l.p,this.prime=l}else t(P.gtn(1),"modulus must be greater than 1"),this.m=P,this.prime=null}D.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},D.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},D.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},D.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},D.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},D.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},D.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},D.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},D.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},D.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},D.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},D.prototype.isqr=function(l){return this.imul(l,l.clone())},D.prototype.sqr=function(l){return this.mul(l,l)},D.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var c=this.m.subn(1),d=0;!c.isZero()&&c.andln(1)===0;)d++,c.iushrn(1);t(!c.isZero());var b=new n(1).toRed(this),x=b.redNeg(),v=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,v).cmp(x)!==0;)h.redIAdd(x);for(var _=this.pow(h,c),T=this.pow(l,c.addn(1).iushrn(1)),m=this.pow(l,c),M=d;m.cmp(b)!==0;){for(var z=m,E=0;z.cmp(b)!==0;E++)z=z.redSqr();t(E=0;d--){for(var _=w.words[d],T=h-1;T>=0;T--){var m=_>>T&1;if(b!==c[0]&&(b=this.sqr(b)),m===0&&x===0){v=0;continue}x<<=1,x|=m,v++,!(v!==p&&(d!==0||T!==0))&&(b=this.mul(b,c[x]),v=0,x=0)}h=26}return b},D.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},D.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(P){D.call(this,P),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,D),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof $d>"u"||$d,$b)});var Hd=J(Wb=>{"use strict";var Mf=Wb;function PE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}Mf.toArray=PE;function Hb(r){return r.length===1?"0"+r:r}Mf.zero2=Hb;function Gb(r){for(var e="",t=0;t{"use strict";var Rr=Jb,NE=li(),CE=Qi(),Rf=Hd();Rr.assert=CE;Rr.toArray=Rf.toArray;Rr.zero2=Rf.zero2;Rr.toHex=Rf.toHex;Rr.encode=Rf.encode;function DE(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?a=(s>>1)-f:a=f,o.isubn(a)):a=0,i[n]=a,o.iushrn(1)}return i}Rr.getNAF=DE;function OE(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,a=e.andln(3)+n&3;o===3&&(o=-1),a===3&&(a=-1);var f;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&a===2?f=-o:f=o):f=0,t[0].push(f);var u;a&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?u=-a:u=a):u=0,t[1].push(u),2*i===f+1&&(i=1-i),2*n===u+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}Rr.getJSF=OE;function LE(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}Rr.cachedProperty=LE;function FE(r){return typeof r=="string"?Rr.toArray(r,"hex"):r}Rr.parseBytes=FE;function UE(r){return new NE(r,"hex","le")}Rr.intFromLE=UE});var Yd=J((DD,Jd)=>{var Gd;Jd.exports=function(e){return Gd||(Gd=new nn(null)),Gd.generate(e)};function nn(r){this.rand=r}Jd.exports.Rand=nn;nn.prototype.generate=function(e){return this._rand(e)};nn.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var Qn=li(),va=Xt(),Pf=va.getNAF,qE=va.getJSF,Nf=va.assert;function sn(r,e){this.type=r,this.p=new Qn(e.p,16),this.red=e.prime?Qn.red(e.prime):Qn.mont(this.p),this.zero=new Qn(0).toRed(this.red),this.one=new Qn(1).toRed(this.red),this.two=new Qn(2).toRed(this.red),this.n=e.n&&new Qn(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Yb.exports=sn;sn.prototype.point=function(){throw new Error("Not implemented")};sn.prototype.validate=function(){throw new Error("Not implemented")};sn.prototype._fixedNafMul=function(e,t){Nf(e.precomputed);var i=e._getDoubles(),n=Pf(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];Nf(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};sn.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,R=g;if(o[A]!==1||o[R]!==1){f[A]=Pf(i[A],o[A],this._bitLength),f[R]=Pf(i[R],o[R],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[R].length,u);continue}var O=[t[A],null,null,t[R]];t[A].y.cmp(t[R].y)===0?(O[1]=t[A].add(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg())):t[A].y.cmp(t[R].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].add(t[R].neg())):(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=qE(i[A],i[R]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[R]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var D=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};lr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var BE=Xt(),nt=li(),Xd=ua(),Qs=ya(),kE=BE.assert;function pr(r){Qs.call(this,"short",r),this.a=new nt(r.a,16).toRed(this.red),this.b=new nt(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Xd(pr,Qs);Xb.exports=pr;pr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new nt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new nt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],kE(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new nt(a.a,16),b:new nt(a.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};pr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:nt.mont(e),i=new nt(2).toRed(t).redInvm(),n=i.redNeg(),s=new nt(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]};pr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new nt(1),o=new nt(0),a=new nt(0),f=new nt(1),u,g,y,S,I,A,R,O=0,N,U;i.cmpn(0)!==0;){var k=n.div(i);N=n.sub(k.mul(i)),U=a.sub(k.mul(s));var B=f.sub(k.mul(o));if(!y&&N.cmp(t)<0)u=R.neg(),g=s,y=N.neg(),S=U;else if(y&&++O===2)break;R=N,n=i,i=N,a=s,s=U,f=o,o=B}I=N.neg(),A=U;var j=y.sqr().add(S.sqr()),V=I.sqr().add(A.sqr());return V.cmp(j)>=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};pr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};pr.prototype.pointFromX=function(e,t){e=new nt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};pr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};pr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};gt.prototype.isInfinity=function(){return this.inf};gt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};gt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};gt.prototype.getX=function(){return this.x.fromRed()};gt.prototype.getY=function(){return this.y.fromRed()};gt.prototype.mul=function(e){return e=new nt(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};gt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};gt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};gt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};gt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};gt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function Et(r,e,t,i){Qs.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nt(0)):(this.x=new nt(e,16),this.y=new nt(t,16),this.z=new nt(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Xd(Et,Qs.BasePoint);pr.prototype.jpoint=function(e,t,i){return new Et(this,e,t,i)};Et.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};Et.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Et.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),R=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,R)};Et.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};Et.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};Et.prototype.inspect=function(){return this.isInfinity()?"":""};Et.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var tv=J((FD,ev)=>{"use strict";var Zs=li(),Zb=ua(),Cf=ya(),zE=Xt();function eo(r){Cf.call(this,"mont",r),this.a=new Zs(r.a,16).toRed(this.red),this.b=new Zs(r.b,16).toRed(this.red),this.i4=new Zs(4).toRed(this.red).redInvm(),this.two=new Zs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Zb(eo,Cf);ev.exports=eo;eo.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function mt(r,e,t){Cf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Zs(e,16),this.z=new Zs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Zb(mt,Cf.BasePoint);eo.prototype.decodePoint=function(e,t){return this.point(zE.toArray(e,t),1)};eo.prototype.point=function(e,t){return new mt(this,e,t)};eo.prototype.pointFromJSON=function(e){return mt.fromJSON(this,e)};mt.prototype.precompute=function(){};mt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};mt.fromJSON=function(e,t){return new mt(e,t[0],t[1]||e.one)};mt.prototype.inspect=function(){return this.isInfinity()?"":""};mt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};mt.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)};mt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),f=s.redMul(n),u=t.z.redMul(a.redAdd(f).redSqr()),g=t.x.redMul(a.redISub(f).redSqr());return this.curve.point(u,g)};mt.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};mt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};mt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};mt.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var nv=J((UD,iv)=>{"use strict";var jE=Xt(),Li=li(),rv=ua(),Df=ya(),KE=jE.assert;function pi(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,Df.call(this,"edwards",r),this.a=new Li(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Li(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Li(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),KE(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}rv(pi,Df);iv.exports=pi;pi.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};pi.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};pi.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};pi.prototype.pointFromX=function(e,t){e=new Li(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var f=a.fromRed().isOdd();return(t&&!f||!t&&f)&&(a=a.redNeg()),this.point(e,a)};pi.prototype.pointFromY=function(e,t){e=new Li(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)};pi.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ye(r,e,t,i,n){Df.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Li(e,16),this.y=new Li(t,16),this.z=i?new Li(i,16):this.curve.one,this.t=n&&new Li(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}rv(Ye,Df.BasePoint);pi.prototype.pointFromJSON=function(e){return Ye.fromJSON(this,e)};pi.prototype.point=function(e,t,i,n){return new Ye(this,e,t,i,n)};Ye.fromJSON=function(e,t){return new Ye(e,t[0],t[1],t[2])};Ye.prototype.inspect=function(){return this.isInfinity()?"":""};Ye.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ye.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(i),f=n.redSub(t),u=s.redMul(a),g=o.redMul(f),y=s.redMul(f),S=a.redMul(o);return this.curve.point(u,g,S,y)};Ye.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,f,u;if(this.curve.twisted){a=this.curve._mulA(t);var g=a.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(g.redSub(this.curve.two)),s=g.redMul(a.redSub(i)),o=g.redSqr().redSub(g).redSub(g)):(f=this.z.redSqr(),u=g.redSub(f).redISub(f),n=e.redSub(t).redISub(i).redMul(u),s=g.redMul(a.redSub(i)),o=g.redMul(u))}else a=t.redAdd(i),f=this.curve._mulC(this.z).redSqr(),u=a.redSub(f).redSub(f),n=this.curve._mulC(e.redISub(a)).redMul(u),s=this.curve._mulC(a).redMul(t.redISub(i)),o=a.redMul(u);return this.curve.point(n,s,o)};Ye.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ye.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),a=s.redSub(n),f=s.redAdd(n),u=i.redAdd(t),g=o.redMul(a),y=f.redMul(u),S=o.redMul(u),I=a.redMul(f);return this.curve.point(g,y,I,S)};Ye.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),f=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),g=t.redMul(a).redMul(u),y,S;return this.curve.twisted?(y=t.redMul(f).redMul(s.redSub(this.curve._mulA(n))),S=a.redMul(f)):(y=t.redMul(f).redMul(s.redSub(n)),S=this.curve._mulC(a).redMul(f)),this.curve.point(g,y,S)};Ye.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ye.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ye.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ye.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ye.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ye.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ye.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ye.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ye.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ye.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ye.prototype.toP=Ye.prototype.normalize;Ye.prototype.mixedAdd=Ye.prototype.add});var Qd=J(sv=>{"use strict";var Of=sv;Of.base=ya();Of.short=Qb();Of.mont=tv();Of.edwards=nv()});var av=J((BD,ov)=>{ov.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var Lf=J(uv=>{"use strict";var el=uv,on=la(),Zd=Qd(),VE=Xt(),cv=VE.assert;function fv(r){r.type==="short"?this.curve=new Zd.short(r):r.type==="edwards"?this.curve=new Zd.edwards(r):this.curve=new Zd.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,cv(this.g.validate(),"Invalid curve"),cv(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}el.PresetCurve=fv;function an(r,e){Object.defineProperty(el,r,{configurable:!0,enumerable:!0,get:function(){var t=new fv(e);return Object.defineProperty(el,r,{configurable:!0,enumerable:!0,value:t}),t}})}an("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:on.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});an("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:on.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});an("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:on.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});an("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:on.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});an("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:on.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});an("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:on.sha256,gRed:!1,g:["9"]});an("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:on.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var tl;try{tl=av()}catch{tl=void 0}an("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:on.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",tl]})});var lv=J((zD,dv)=>{"use strict";var $E=la(),Zn=Hd(),hv=Qi();function cn(r){if(!(this instanceof cn))return new cn(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Zn.toArray(r.entropy,r.entropyEnc||"hex"),t=Zn.toArray(r.nonce,r.nonceEnc||"hex"),i=Zn.toArray(r.pers,r.persEnc||"hex");hv(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}dv.exports=cn;cn.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};cn.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Zn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var HE=li(),GE=Xt(),rl=GE.assert;function Ct(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}pv.exports=Ct;Ct.fromPublic=function(e,t,i){return t instanceof Ct?t:new Ct(e,{pub:t,pubEnc:i})};Ct.fromPrivate=function(e,t,i){return t instanceof Ct?t:new Ct(e,{priv:t,privEnc:i})};Ct.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Ct.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};Ct.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Ct.prototype._importPrivate=function(e,t){this.priv=new HE(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};Ct.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?rl(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&rl(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};Ct.prototype.derive=function(e){return e.validate()||rl(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Ct.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};Ct.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};Ct.prototype.inspect=function(){return""}});var vv=J((KD,bv)=>{"use strict";var Ff=li(),sl=Xt(),WE=sl.assert;function Uf(r,e){if(r instanceof Uf)return r;this._importDER(r,e)||(WE(r.r&&r.s,"Signature without r or s"),this.r=new Ff(r.r,16),this.s=new Ff(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}bv.exports=Uf;function JE(){this.place=0}function il(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function mv(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Uf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=mv(t),i=mv(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];nl(n,t.length),n=n.concat(t),n.push(2),nl(n,i.length);var s=n.concat(i),o=[48];return nl(o,s.length),o=o.concat(s),sl.encode(o,e)}});var _v=J((VD,xv)=>{"use strict";var es=li(),yv=lv(),YE=Xt(),ol=Lf(),XE=Yd(),wv=YE.assert,al=gv(),qf=vv();function gr(r){if(!(this instanceof gr))return new gr(r);typeof r=="string"&&(wv(Object.prototype.hasOwnProperty.call(ol,r),"Unknown curve "+r),r=ol[r]),r instanceof ol.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}xv.exports=gr;gr.prototype.keyPair=function(e){return new al(this,e)};gr.prototype.keyFromPrivate=function(e,t){return al.fromPrivate(this,e,t)};gr.prototype.keyFromPublic=function(e,t){return al.fromPublic(this,e,t)};gr.prototype.genKeyPair=function(e){e||(e={});for(var t=new yv({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||XE(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new es(2));;){var s=new es(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};gr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};gr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new es(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new yv({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new es(1)),g=0;;g++){var y=n.k?n.k(g):new es(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var R=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(R=R.umod(this.n),R.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),O^=1),new qf({r:A,s:R,recoveryParam:O})}}}}}};gr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new es(e,16)),i=this.keyFromPublic(i,n),t=new qf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};gr.prototype.recoverPubKey=function(r,e,t,i){wv((3&t)===t,"The recovery param is more than two bits"),e=new qf(e,i);var n=this.n,s=new es(r),o=e.r,a=e.s,f=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};gr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new qf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Av=J(($D,Iv)=>{"use strict";var wa=Xt(),Sv=wa.assert,Ev=wa.parseBytes,to=wa.cachedProperty;function bt(r,e){this.eddsa=r,this._secret=Ev(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Ev(e.pub)}bt.fromPublic=function(e,t){return t instanceof bt?t:new bt(e,{pub:t})};bt.fromSecret=function(e,t){return t instanceof bt?t:new bt(e,{secret:t})};bt.prototype.secret=function(){return this._secret};to(bt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});to(bt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});to(bt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});to(bt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});to(bt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});to(bt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});bt.prototype.sign=function(e){return Sv(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};bt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};bt.prototype.getSecret=function(e){return Sv(this._secret,"KeyPair is public only"),wa.encode(this.secret(),e)};bt.prototype.getPublic=function(e){return wa.encode(this.pubBytes(),e)};Iv.exports=bt});var Rv=J((HD,Mv)=>{"use strict";var QE=li(),Bf=Xt(),Tv=Bf.assert,kf=Bf.cachedProperty,ZE=Bf.parseBytes;function ts(r,e){this.eddsa=r,typeof e!="object"&&(e=ZE(e)),Array.isArray(e)&&(Tv(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Tv(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof QE&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}kf(ts,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});kf(ts,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});kf(ts,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});kf(ts,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});ts.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};ts.prototype.toHex=function(){return Bf.encode(this.toBytes(),"hex").toUpperCase()};Mv.exports=ts});var Ov=J((GD,Dv)=>{"use strict";var e7=la(),t7=Lf(),ro=Xt(),r7=ro.assert,Nv=ro.parseBytes,Cv=Av(),Pv=Rv();function Kt(r){if(r7(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Kt))return new Kt(r);r=t7[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=e7.sha512}Dv.exports=Kt;Kt.prototype.sign=function(e,t){e=Nv(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),f=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:f,Rencoded:o})};Kt.prototype.verify=function(e,t,i){if(e=Nv(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),a=t.R().add(n.pub().mul(s));return a.eq(o)};Kt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var rs=Lv;rs.version=Vb().version;rs.utils=Xt();rs.rand=Yd();rs.curve=Qd();rs.curves=Lf();rs.ec=_v();rs.eddsa=Ov()});var $y=J(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});ln.isBrowserCryptoAvailable=ln.getSubtleCrypto=ln.getBrowerCrypto=void 0;function Ol(){return(global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}ln.getBrowerCrypto=Ol;function Vy(){let r=Ol();return r.subtle||r.webkitSubtle}ln.getSubtleCrypto=Vy;function v9(){return!!Ol()&&!!Vy()}ln.isBrowserCryptoAvailable=v9});var Wy=J(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});pn.isBrowser=pn.isNode=pn.isReactNative=void 0;function Hy(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}pn.isReactNative=Hy;function Gy(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}pn.isNode=Gy;function y9(){return!Hy()&&!Gy()}pn.isBrowser=y9});var Ll=J(Zf=>{"use strict";Object.defineProperty(Zf,"__esModule",{value:!0});var Jy=(Es(),No(_s));Jy.__exportStar($y(),Zf);Jy.__exportStar(Wy(),Zf)});var r2=J((RO,t2)=>{"use strict";t2.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var k2=J((Ua,bo)=>{var N9=200,Jl="__lodash_hash_undefined__",lu=1,b2=2,v2=9007199254740991,ou="[object Arguments]",jl="[object Array]",C9="[object AsyncFunction]",y2="[object Boolean]",w2="[object Date]",x2="[object Error]",_2="[object Function]",D9="[object GeneratorFunction]",au="[object Map]",E2="[object Number]",O9="[object Null]",mo="[object Object]",o2="[object Promise]",L9="[object Proxy]",S2="[object RegExp]",cu="[object Set]",I2="[object String]",F9="[object Symbol]",U9="[object Undefined]",Kl="[object WeakMap]",A2="[object ArrayBuffer]",fu="[object DataView]",q9="[object Float32Array]",B9="[object Float64Array]",k9="[object Int8Array]",z9="[object Int16Array]",j9="[object Int32Array]",K9="[object Uint8Array]",V9="[object Uint8ClampedArray]",$9="[object Uint16Array]",H9="[object Uint32Array]",G9=/[\\^$.*+?()[\]{}|]/g,W9=/^\[object .+?Constructor\]$/,J9=/^(?:0|[1-9]\d*)$/,Ze={};Ze[q9]=Ze[B9]=Ze[k9]=Ze[z9]=Ze[j9]=Ze[K9]=Ze[V9]=Ze[$9]=Ze[H9]=!0;Ze[ou]=Ze[jl]=Ze[A2]=Ze[y2]=Ze[fu]=Ze[w2]=Ze[x2]=Ze[_2]=Ze[au]=Ze[E2]=Ze[mo]=Ze[S2]=Ze[cu]=Ze[I2]=Ze[Kl]=!1;var T2=typeof global=="object"&&global&&global.Object===Object&&global,Y9=typeof self=="object"&&self&&self.Object===Object&&self,Bi=T2||Y9||Function("return this")(),M2=typeof Ua=="object"&&Ua&&!Ua.nodeType&&Ua,a2=M2&&typeof bo=="object"&&bo&&!bo.nodeType&&bo,R2=a2&&a2.exports===M2,Bl=R2&&T2.process,c2=function(){try{return Bl&&Bl.binding&&Bl.binding("util")}catch{}}(),f2=c2&&c2.isTypedArray;function X9(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function TS(r,e){var t=this.__data__,i=gu(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}ki.prototype.clear=ES;ki.prototype.delete=SS;ki.prototype.get=IS;ki.prototype.has=AS;ki.prototype.set=TS;function us(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ea))return!1;var u=s.get(r);if(u&&s.get(e))return u==e;var g=-1,y=!0,S=t&b2?new hu:void 0;for(s.set(r,e),s.set(e,r);++g-1&&r%1==0&&r-1&&r%1==0&&r<=v2}function q2(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function ka(r){return r!=null&&typeof r=="object"}var B2=f2?tS(f2):VS;function nI(r){return rI(r)?kS(r):$S(r)}function sI(){return[]}function oI(){return!1}bo.exports=iI});var Uw=J((_F,Fw)=>{Fw.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var En=J(ls=>{var K0,kT=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];ls.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};ls.getSymbolTotalCodewords=function(e){return kT[e]};ls.getBCHDigit=function(r){let e=0;for(;r!==0;)e++,r>>>=1;return e};ls.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');K0=e};ls.isKanjiModeEnabled=function(){return typeof K0<"u"};ls.toSJIS=function(e){return K0(e)}});var Tu=J(vr=>{vr.L={bit:1};vr.M={bit:0};vr.Q={bit:3};vr.H={bit:2};function zT(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return vr.L;case"m":case"medium":return vr.M;case"q":case"quartile":return vr.Q;case"h":case"high":return vr.H;default:throw new Error("Unknown EC Level: "+r)}}vr.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4};vr.from=function(e,t){if(vr.isValid(e))return e;try{return zT(e)}catch{return t}}});var kw=J((IF,Bw)=>{function qw(){this.buffer=[],this.length=0}qw.prototype={get:function(r){let e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(let t=0;t>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};Bw.exports=qw});var jw=J((AF,zw)=>{function Ha(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}Ha.prototype.set=function(r,e,t,i){let n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};Ha.prototype.get=function(r,e){return this.data[r*this.size+e]};Ha.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};Ha.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};zw.exports=Ha});var Kw=J(Mu=>{var jT=En().getSymbolSize;Mu.getRowColCoords=function(e){if(e===1)return[];let t=Math.floor(e/7)+2,i=jT(e),n=i===145?26:Math.ceil((i-13)/(2*t-2))*2,s=[i-7];for(let o=1;o{var KT=En().getSymbolSize,Vw=7;$w.getPositions=function(e){let t=KT(e);return[[0,0],[t-Vw,0],[0,t-Vw]]}});var Gw=J(Xe=>{Xe.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var ps={N1:3,N2:3,N3:40,N4:10};Xe.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7};Xe.from=function(e){return Xe.isValid(e)?parseInt(e,10):void 0};Xe.getPenaltyN1=function(e){let t=e.size,i=0,n=0,s=0,o=null,a=null;for(let f=0;f=5&&(i+=ps.N1+(n-5)),o=g,n=1),g=e.get(u,f),g===a?s++:(s>=5&&(i+=ps.N1+(s-5)),a=g,s=1)}n>=5&&(i+=ps.N1+(n-5)),s>=5&&(i+=ps.N1+(s-5))}return i};Xe.getPenaltyN2=function(e){let t=e.size,i=0;for(let n=0;n=10&&(n===1488||n===93)&&i++,s=s<<1&2047|e.get(a,o),a>=10&&(s===1488||s===93)&&i++}return i*ps.N3};Xe.getPenaltyN4=function(e){let t=0,i=e.data.length;for(let s=0;s{var Sn=Tu(),Ru=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Pu=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];V0.getBlocksCount=function(e,t){switch(t){case Sn.L:return Ru[(e-1)*4+0];case Sn.M:return Ru[(e-1)*4+1];case Sn.Q:return Ru[(e-1)*4+2];case Sn.H:return Ru[(e-1)*4+3];default:return}};V0.getTotalCodewordsCount=function(e,t){switch(t){case Sn.L:return Pu[(e-1)*4+0];case Sn.M:return Pu[(e-1)*4+1];case Sn.Q:return Pu[(e-1)*4+2];case Sn.H:return Pu[(e-1)*4+3];default:return}}});var Ww=J(Cu=>{var Ga=new Uint8Array(512),Nu=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)Ga[t]=e,Nu[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)Ga[t]=Ga[t-255]})();Cu.log=function(e){if(e<1)throw new Error("log("+e+")");return Nu[e]};Cu.exp=function(e){return Ga[e]};Cu.mul=function(e,t){return e===0||t===0?0:Ga[Nu[e]+Nu[t]]}});var Jw=J(Wa=>{var H0=Ww();Wa.mul=function(e,t){let i=new Uint8Array(e.length+t.length-1);for(let n=0;n=0;){let n=i[0];for(let o=0;o{var Yw=Jw();function G0(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}G0.prototype.initialize=function(e){this.degree=e,this.genPoly=Yw.generateECPolynomial(this.degree)};G0.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let i=Yw.mod(t,this.genPoly),n=this.degree-i.length;if(n>0){let s=new Uint8Array(this.degree);return s.set(i,n),s}return i};Xw.exports=G0});var W0=J(Zw=>{Zw.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}});var J0=J(Ki=>{var e3="[0-9]+",$T="[A-Z $%*+\\-./:]+",Ja="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ja=Ja.replace(/u/g,"\\u");var HT="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ja+`)(?:.|[\r -]))+`;Ki.KANJI=new RegExp(Ja,"g");Ki.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Ki.BYTE=new RegExp(HT,"g");Ki.NUMERIC=new RegExp(e3,"g");Ki.ALPHANUMERIC=new RegExp($T,"g");var GT=new RegExp("^"+Ja+"$"),WT=new RegExp("^"+e3+"$"),JT=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Ki.testKanji=function(e){return GT.test(e)};Ki.testNumeric=function(e){return WT.test(e)};Ki.testAlphanumeric=function(e){return JT.test(e)}});var In=J(ht=>{var YT=W0(),Y0=J0();ht.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};ht.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};ht.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};ht.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};ht.MIXED={bit:-1};ht.getCharCountIndicator=function(e,t){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!YT.isValid(t))throw new Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]};ht.getBestModeForData=function(e){return Y0.testNumeric(e)?ht.NUMERIC:Y0.testAlphanumeric(e)?ht.ALPHANUMERIC:Y0.testKanji(e)?ht.KANJI:ht.BYTE};ht.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")};ht.isValid=function(e){return e&&e.bit&&e.ccBits};function XT(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return ht.NUMERIC;case"alphanumeric":return ht.ALPHANUMERIC;case"kanji":return ht.KANJI;case"byte":return ht.BYTE;default:throw new Error("Unknown mode: "+r)}}ht.from=function(e,t){if(ht.isValid(e))return e;try{return XT(e)}catch{return t}}});var s3=J(gs=>{var Du=En(),QT=$0(),t3=Tu(),An=In(),X0=W0(),i3=7973,r3=Du.getBCHDigit(i3);function ZT(r,e,t){for(let i=1;i<=40;i++)if(e<=gs.getCapacity(i,t,r))return i}function n3(r,e){return An.getCharCountIndicator(r,e)+4}function eM(r,e){let t=0;return r.forEach(function(i){let n=n3(i.mode,e);t+=n+i.getBitsLength()}),t}function tM(r,e){for(let t=1;t<=40;t++)if(eM(r,t)<=gs.getCapacity(t,e,An.MIXED))return t}gs.from=function(e,t){return X0.isValid(e)?parseInt(e,10):t};gs.getCapacity=function(e,t,i){if(!X0.isValid(e))throw new Error("Invalid QR Code version");typeof i>"u"&&(i=An.BYTE);let n=Du.getSymbolTotalCodewords(e),s=QT.getTotalCodewordsCount(e,t),o=(n-s)*8;if(i===An.MIXED)return o;let a=o-n3(i,e);switch(i){case An.NUMERIC:return Math.floor(a/10*3);case An.ALPHANUMERIC:return Math.floor(a/11*2);case An.KANJI:return Math.floor(a/13);case An.BYTE:default:return Math.floor(a/8)}};gs.getBestVersionForData=function(e,t){let i,n=t3.from(t,t3.M);if(Array.isArray(e)){if(e.length>1)return tM(e,n);if(e.length===0)return 1;i=e[0]}else i=e;return ZT(i.mode,i.getLength(),n)};gs.getEncodedBits=function(e){if(!X0.isValid(e)||e<7)throw new Error("Invalid QR Code version");let t=e<<12;for(;Du.getBCHDigit(t)-r3>=0;)t^=i3<{var Q0=En(),a3=1335,rM=21522,o3=Q0.getBCHDigit(a3);c3.getEncodedBits=function(e,t){let i=e.bit<<3|t,n=i<<10;for(;Q0.getBCHDigit(n)-o3>=0;)n^=a3<{var iM=In();function Io(r){this.mode=iM.NUMERIC,this.data=r.toString()}Io.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};Io.prototype.getLength=function(){return this.data.length};Io.prototype.getBitsLength=function(){return Io.getBitsLength(this.data.length)};Io.prototype.write=function(e){let t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);let s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};u3.exports=Io});var l3=J((kF,d3)=>{var nM=In(),Z0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ao(r){this.mode=nM.ALPHANUMERIC,this.data=r}Ao.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};Ao.prototype.getLength=function(){return this.data.length};Ao.prototype.getBitsLength=function(){return Ao.getBitsLength(this.data.length)};Ao.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let i=Z0.indexOf(this.data[t])*45;i+=Z0.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(Z0.indexOf(this.data[t]),6)};d3.exports=Ao});var g3=J((zF,p3)=>{var sM=In();function To(r){this.mode=sM.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}To.getBitsLength=function(e){return e*8};To.prototype.getLength=function(){return this.data.length};To.prototype.getBitsLength=function(){return To.getBitsLength(this.data.length)};To.prototype.write=function(r){for(let e=0,t=this.data.length;e{var oM=In(),aM=En();function Mo(r){this.mode=oM.KANJI,this.data=r}Mo.getBitsLength=function(e){return e*13};Mo.prototype.getLength=function(){return this.data.length};Mo.prototype.getBitsLength=function(){return Mo.getBitsLength(this.data.length)};Mo.prototype.write=function(r){let e;for(e=0;e=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` -Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};m3.exports=Mo});var v3=J((KF,ep)=>{"use strict";var Ya={single_source_shortest_paths:function(r,e,t){var i={},n={};n[e]=0;var s=Ya.PriorityQueue.make();s.push(e,0);for(var o,a,f,u,g,y,S,I,A;!s.empty();){o=s.pop(),a=o.value,u=o.cost,g=r[a]||{};for(f in g)g.hasOwnProperty(f)&&(y=g[f],S=u+y,I=n[f],A=typeof n[f]>"u",(A||I>S)&&(n[f]=S,s.push(f,S),i[f]=a))}if(typeof t<"u"&&typeof n[t]>"u"){var R=["Could not find a path from ",e," to ",t,"."].join("");throw new Error(R)}return i},extract_shortest_path_from_predecessor_list:function(r,e){for(var t=[],i=e,n;i;)t.push(i),n=r[i],i=r[i];return t.reverse(),t},find_path:function(r,e,t){var i=Ya.single_source_shortest_paths(r,e,t);return Ya.extract_shortest_path_from_predecessor_list(i,t)},PriorityQueue:{make:function(r){var e=Ya.PriorityQueue,t={},i;r=r||{};for(i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.queue=[],t.sorter=r.sorter||e.default_sorter,t},default_sorter:function(r,e){return r.cost-e.cost},push:function(r,e){var t={value:r,cost:e};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof ep<"u"&&(ep.exports=Ya)});var A3=J(Ro=>{var je=In(),x3=h3(),_3=l3(),E3=g3(),S3=b3(),Xa=J0(),Ou=En(),cM=v3();function y3(r){return unescape(encodeURIComponent(r)).length}function Qa(r,e,t){let i=[],n;for(;(n=r.exec(t))!==null;)i.push({data:n[0],index:n.index,mode:e,length:n[0].length});return i}function I3(r){let e=Qa(Xa.NUMERIC,je.NUMERIC,r),t=Qa(Xa.ALPHANUMERIC,je.ALPHANUMERIC,r),i,n;return Ou.isKanjiModeEnabled()?(i=Qa(Xa.BYTE,je.BYTE,r),n=Qa(Xa.KANJI,je.KANJI,r)):(i=Qa(Xa.BYTE_KANJI,je.BYTE,r),n=[]),e.concat(t,i,n).sort(function(o,a){return o.index-a.index}).map(function(o){return{data:o.data,mode:o.mode,length:o.length}})}function tp(r,e){switch(e){case je.NUMERIC:return x3.getBitsLength(r);case je.ALPHANUMERIC:return _3.getBitsLength(r);case je.KANJI:return S3.getBitsLength(r);case je.BYTE:return E3.getBitsLength(r)}}function fM(r){return r.reduce(function(e,t){let i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function uM(r){let e=[];for(let t=0;t{var Fu=En(),rp=Tu(),dM=kw(),lM=jw(),pM=Kw(),gM=Hw(),sp=Gw(),op=$0(),mM=Qw(),Lu=s3(),bM=f3(),vM=In(),ip=A3();function yM(r,e){let t=r.size,i=gM.getPositions(e);for(let n=0;n=0&&a<=6&&(f===0||f===6)||f>=0&&f<=6&&(a===0||a===6)||a>=2&&a<=4&&f>=2&&f<=4?r.set(s+a,o+f,!0,!0):r.set(s+a,o+f,!1,!0))}}function wM(r){let e=r.size;for(let t=8;t>a&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function np(r,e,t){let i=r.size,n=bM.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function EM(r,e){let t=r.size,i=-1,n=t-1,s=7,o=0;for(let a=t-1;a>0;a-=2)for(a===6&&a--;;){for(let f=0;f<2;f++)if(!r.isReserved(n,a-f)){let u=!1;o>>s&1)===1),r.set(n,a-f,u),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function SM(r,e,t){let i=new dM;t.forEach(function(f){i.put(f.mode.bit,4),i.put(f.getLength(),vM.getCharCountIndicator(f.mode,r)),f.write(i)});let n=Fu.getSymbolTotalCodewords(r),s=op.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);let a=(o-i.getLengthInBits())/8;for(let f=0;f=7&&_M(f,e),EM(f,o),isNaN(i)&&(i=sp.getBestMask(f,np.bind(null,f,t))),sp.applyMask(i,f),np(f,t,i),{modules:f,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}T3.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");let i=rp.M,n,s;return typeof t<"u"&&(i=rp.from(t.errorCorrectionLevel,rp.M),n=Lu.from(t.version),s=sp.from(t.maskPattern),t.toSJISFunc&&Fu.setToSJISFunction(t.toSJISFunc)),AM(e,n,i,s)}});var ap=J(ms=>{function R3(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let e=r.slice().replace("#","").split("");if(e.length<3||e.length===5||e.length>8)throw new Error("Invalid hex color: "+r);(e.length===3||e.length===4)&&(e=Array.prototype.concat.apply([],e.map(function(i){return[i,i]}))),e.length===6&&e.push("F","F");let t=parseInt(e.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+e.slice(0,6).join("")}}ms.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=typeof e.margin>"u"||e.margin===null||e.margin<0?4:e.margin,i=e.width&&e.width>=21?e.width:void 0,n=e.scale||4;return{width:i,scale:i?4:n,margin:t,color:{dark:R3(e.color.dark||"#000000ff"),light:R3(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}};ms.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale};ms.getImageWidth=function(e,t){let i=ms.getScale(e,t);return Math.floor((e+t.margin*2)*i)};ms.qrToImageData=function(e,t,i){let n=t.modules.size,s=t.modules.data,o=ms.getScale(n,i),a=Math.floor((n+i.margin*2)*o),f=i.margin*o,u=[i.color.light,i.color.dark];for(let g=0;g=f&&y>=f&&g{var cp=ap();function TM(r,e,t){r.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=t,e.width=t,e.style.height=t+"px",e.style.width=t+"px"}function MM(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}Uu.render=function(e,t,i){let n=i,s=t;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),t||(s=MM()),n=cp.getOptions(n);let o=cp.getImageWidth(e.modules.size,n),a=s.getContext("2d"),f=a.createImageData(o,o);return cp.qrToImageData(f.data,e,n),TM(a,s,o),a.putImageData(f,0,0),s};Uu.renderToDataURL=function(e,t,i){let n=i;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),n||(n={});let s=Uu.render(e,t,n),o=n.type||"image/png",a=n.rendererOpts||{};return s.toDataURL(o,a.quality)}});var D3=J(C3=>{var RM=ap();function N3(r,e){let t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function fp(r,e,t){let i=r+e;return typeof t<"u"&&(i+=" "+t),i}function PM(r,e,t){let i="",n=0,s=!1,o=0;for(let a=0;a0&&f>0&&r[a-1]||(i+=s?fp("M",f+t,.5+u+t):fp("m",n,0),n=0,s=!1),f+1':"",u="',g='viewBox="0 0 '+a+" "+a+'"',S=''+f+u+` -`;return typeof i=="function"&&i(null,S),S}});var L3=J(Za=>{var NM=Uw(),up=M3(),O3=P3(),CM=D3();function hp(r,e,t,i,n){let s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!NM())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(f,u){try{let g=up.create(t,i);f(r(g,e,i))}catch(g){u(g)}})}try{let f=up.create(t,i);n(null,r(f,e,i))}catch(f){n(f)}}Za.create=up.create;Za.toCanvas=hp.bind(null,O3.render);Za.toDataURL=hp.bind(null,O3.renderToDataURL);Za.toString=hp.bind(null,function(r,e,t){return CM.render(r,t)})});var vs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mp=new Uint8Array(256);for(let r=0;r/^[0-9a-fA-F]{64}$/.test(r),Vi=r=>t6.encode(r),$i=r=>r6.decode(r),Gt=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;tArray.from(r).map(e=>e.toString(16).padStart(2,"0")).join(""),rc=r=>ar(Vi(r)),qn=r=>{r=r.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;r.endsWith("==")?e=2:r.endsWith("=")&&(e=1);let t=Math.floor(r.length*6/8-e),i=new Uint8Array(t),n=0,s=0,o=0;for(let a=0;a=8&&(s-=8,i[o++]=n>>s&255)}return i},i6=r=>{let e="",t=r.length;for(let i=0;i>18&63,u=a>>12&63,g=a>>6&63,y=a&63;e+=vs.charAt(f),e+=vs.charAt(u),e+=i+1$i(qn(r)),Hi=r=>{let e=typeof r=="string"?Vi(r):r;return i6(e)};function n6(r){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,i;for(;(i=t.exec(r))!==null;)i[1]!==void 0?e.push(i[1]):i[2]!==void 0&&(i[2]===""?e.push(""):/^\d+$/.test(i[2])?e.push(Number(i[2])):e.push(i[2]));return e}function s6(r,e,t){let i=r;for(let n=0;n{Hu([...r,""],i,t)});else for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&Hu([...r,i],e[i],t);else{let i=r.map((n,s)=>s===0?encodeURIComponent(String(n)):n===""?"[]":`[${encodeURIComponent(String(n))}]`).join("");t.push(`${i}=${encodeURIComponent(e)}`)}}function Gu(r){let e=new URLSearchParams(r),t={};for(let[i,n]of e.entries()){let s=n6(i);s6(t,s,n)}return t}function vp(r){let e=[];return Hu([],r,e),e.join("&")}var o6=()=>typeof window<"u"&&typeof window.location<"u",Do=()=>{if(o6()){let r=window.location.ancestorOrigins;return r?.[r.length-1]??"*"}return"*"},Wu=()=>{let r=window;return!!(r?.ReactNativeWebView||r?.webkit)};var Si=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";bp(e)&&(this.address=Gt(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:ar(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return ar(this.address)}};var wp=1e9,xp=0,ic=2,_p=2,Ju=64,Ep=1;var Sp="sdk-js";var Ip="hook/login",Ap="hook/logout";var Tp="hook/sign",Mp="hook/2fa",Rp="hook/sign-message",Oo="walletProviderStatus",nc="transactionsSigned",Pp=500,wr="mvx",Np=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],Cp={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var Lo=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||wp),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||ic),this.options=Number(e.options?.valueOf()||xp),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var xr=class extends Error{constructor(t,i){super(t);this.inner=void 0;this.inner=i}summary(){let t=[];t.push({name:this.name,message:this.message});let i=this.inner;for(;i;)t.push({name:i.name,message:i.message}),i=i.inner;return t}};var sc=class extends xr{constructor(){super("Async timer already running")}},oc=class extends xr{constructor(){super("Async timer aborted")}};var ys=class extends xr{constructor(){super("Expected transaction status not reached")}},Fo=class extends xr{constructor(){super("Expected transaction events not found")}};var ac=class extends xr{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var cc=class extends xr{constructor(){super("Cannot sign single transaction.")}},fc=class extends xr{constructor(){super("Account is not connected.")}},Uo=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},uc=class extends Error{constructor(){super("Cannot get signed message")}};var ws=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new sc;return this.correlationTag++,new Promise((t,i)=>{this.rejectionFunc=i;let n=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(n,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new oc),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var Yu=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Zr=class Zr{constructor(e,t={}){this.fetcher=new Yu(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||Zr.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||Zr.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||Zr.DefaultPatience}async awaitPending(e){let t=s=>s.status.isPending(),i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ys;return this.awaitConditionally(t,i,n)}async awaitCompleted(e){let t=s=>{if(s.isCompleted===void 0)throw new ac;return s.isCompleted},i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ys;return this.awaitConditionally(t,i,n)}async awaitAllEvents(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.every(u=>a.includes(u))},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new Fo;return this.awaitConditionally(i,n,s)}async awaitAnyEvent(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new Fo;return this.awaitConditionally(i,n,s)}async awaitOnCondition(e,t){let i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ys;return this.awaitConditionally(t,i,n)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==Ju)throw new xr(`Invalid transaction hash length. The length of a hex encoded hash should be ${Ju}.`);return t}async awaitConditionally(e,t,i){let n=new ws("watcher:periodic"),s=new ws("watcher:patience"),o=new ws("watcher:timeout"),a=!1,f,u=!1;for(o.start(this.timeoutMilliseconds).finally(()=>{o.stop(),a=!0});!a&&(await n.start(this.pollingIntervalMilliseconds),f=await t(),u=e(f),!(u||a)););if(u&&await s.start(this.patienceMilliseconds),o.isStopped()||o.stop(),!f||!u)throw i();return f}getAllTransactionEvents(e){let t=[...e.logs.events];for(let i of e.contractResults.items)t.push(...i.logs.events);return t}};Zr.DefaultPollingInterval=6e3,Zr.DefaultTimeout=Zr.DefaultPollingInterval*15,Zr.DefaultPatience=0,Zr.NoopOnStatusReceived=()=>{};var qo=Zr;var Wt=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ep,this.signer=e.signer||Sp}};var yt=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?Hi(e.senderUsername):void 0,receiverUsername:e.receiverUsername?Hi(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?Hi(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?ar(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?ar(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new Lo({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:Co(e.receiverUsername||""),sender:e.sender,senderUsername:Co(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?qn(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?Gt(e.signature):void 0,guardianSignature:e.guardianSignature?Gt(e.guardianSignature):void 0})}};var Gi=class Gi{constructor(){this.account={address:""};this.initialized=!1;if(Gi._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");Gi._instance=this}static getInstance(){return Gi._instance}setAddress(e){return this.account.address=e,Gi._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,i=t||"";return await this.startBgrMsgChannel("connect",i),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new cc;return t[0]}ensureConnected(){if(!this.account.address)throw new fc}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(i=>yt.transactionToPlainObject(i))});try{return t.map(n=>yt.plainObjectToTransaction(n))}catch(i){throw new Error(`Transaction canceled: ${i.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:$i(e.data)},n=(await this.startBgrMsgChannel("signMessage",t)).signature,s=Gt(n);return new Wt({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:s})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(i=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let n=s=>{s.isTrusted&&s.data.target==="erdw-contentScript"&&(s.data.type==="connectResponse"?(s.data.data&&s.data.data.address&&(this.account=s.data.data),window.removeEventListener("message",n),i(s.data.data)):(window.removeEventListener("message",n),i(s.data.data)))};window.addEventListener("message",n,!1)})}};Gi._instance=new Gi;var Bn=Gi;var hc="elvenjs_state",Dp="https://devnet-api.multiversx.com";var Wi="/dapp/init",dc="devnet",Op="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Lp=["wss://relay.walletconnect.com"],At={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var re={get(r){let e=localStorage.getItem(hc);if(!e)return{};let t=JSON.parse(e);return r?t[r]:t},set(r,e){let t=this.get();t[r]=e,localStorage.setItem(hc,JSON.stringify(t))},clear(){localStorage.removeItem(hc)}};var lc=async()=>{let r=Bn.getInstance();try{let e=await r.init(),t=re.get();return t?.address&&r.setAddress(t.address),e?r:void 0}catch{}};var zi=Be(kn());var sg=Be(kn()),Ec=Be(Ts());var _r=class{};var nh=class extends _r{constructor(e){super()}},ng=Ec.FIVE_SECONDS,zn={pulse:"heartbeat_pulse"},_c=class r extends nh{constructor(e){super(e),this.events=new sg.EventEmitter,this.interval=ng,this.interval=e?.interval||ng}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,Ec.toMiliseconds)(this.interval))}pulse(){this.events.emit(zn.pulse)}};var F6=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,U6=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,q6=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function B6(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){k6(r);return}return e}function k6(r){`${r}`}function zo(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!q6.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(F6.test(r)||U6.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,B6)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function z6(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function dt(r,...e){try{return z6(r(...e))}catch(t){return Promise.reject(t)}}function j6(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function K6(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function jo(r){if(j6(r))return String(r);if(K6(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return jo(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function og(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var sh="base64:";function ag(r){if(typeof r=="string")return r;og();let e=Buffer.from(r).toString("base64");return sh+e}function cg(r){return typeof r!="string"||!r.startsWith(sh)?r:(og(),Buffer.from(r.slice(sh.length),"base64"))}function Bt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function fg(...r){return Bt(r.join(":"))}function Ko(r){return r=Bt(r),r?r+":":""}var V6="memory",$6=()=>{let r=new Map;return{name:V6,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function dg(r={}){let e={mounts:{"":r.driver||$6()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=u=>{for(let g of e.mountpoints)if(u.startsWith(g))return{base:g,relativeKey:u.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,g)=>e.mountpoints.filter(y=>y.startsWith(u)||g&&u.startsWith(y)).map(y=>({relativeBase:u.length>y.length?u.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(u,g)=>{if(e.watching){g=Bt(g);for(let y of e.watchListeners)y(u,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(let u in e.mounts)e.unwatch[u]=await ug(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(let u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,g,y)=>{let S=new Map,I=A=>{let R=S.get(A.base);return R||(R={driver:A.driver,base:A.base,items:[]},S.set(A.base,R)),R};for(let A of u){let R=typeof A=="string",O=Bt(R?A:A.key),N=R?void 0:A.value,U=R||!A.options?g:{...g,...A.options},k=t(O);I(k).items.push({key:O,value:N,relativeKey:k.relativeKey,options:U})}return Promise.all([...S.values()].map(A=>y(A))).then(A=>A.flat())},f={hasItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.hasItem,y,g)},getItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.getItem,y,g).then(I=>zo(I))},getItems(u,g){return a(u,g,y=>y.driver.getItems?dt(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),g).then(S=>S.map(I=>({key:fg(y.base,I.key),value:zo(I.value)}))):Promise.all(y.items.map(S=>dt(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:zo(I)})))))},getItemRaw(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return S.getItemRaw?dt(S.getItemRaw,y,g):dt(S.getItem,y,g).then(I=>cg(I))},async setItem(u,g,y={}){if(g===void 0)return f.removeItem(u);u=Bt(u);let{relativeKey:S,driver:I}=t(u);I.setItem&&(await dt(I.setItem,S,jo(g),y),I.watch||n("update",u))},async setItems(u,g){await a(u,g,async y=>{if(y.driver.setItems)return dt(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:jo(S.value),options:S.options})),g);y.driver.setItem&&await Promise.all(y.items.map(S=>dt(y.driver.setItem,S.relativeKey,jo(S.value),S.options)))})},async setItemRaw(u,g,y={}){if(g===void 0)return f.removeItem(u,y);u=Bt(u);let{relativeKey:S,driver:I}=t(u);if(I.setItemRaw)await dt(I.setItemRaw,S,g,y);else if(I.setItem)await dt(I.setItem,S,ag(g),y);else return;I.watch||n("update",u)},async removeItem(u,g={}){typeof g=="boolean"&&(g={removeMeta:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u);S.removeItem&&(await dt(S.removeItem,y,g),(g.removeMeta||g.removeMata)&&await dt(S.removeItem,y+"$",g),S.watch||n("remove",u))},async getMeta(u,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u),I=Object.create(null);if(S.getMeta&&Object.assign(I,await dt(S.getMeta,y,g)),!g.nativeOnly){let A=await dt(S.getItem,y+"$",g).then(R=>zo(R));A&&typeof A=="object"&&(typeof A.atime=="string"&&(A.atime=new Date(A.atime)),typeof A.mtime=="string"&&(A.mtime=new Date(A.mtime)),Object.assign(I,A))}return I},setMeta(u,g,y={}){return this.setItem(u+"$",g,y)},removeMeta(u,g={}){return this.removeItem(u+"$",g)},async getKeys(u,g={}){u=Ko(u);let y=i(u,!0),S=[],I=[];for(let A of y){let R=await dt(A.driver.getKeys,A.relativeBase,g);for(let O of R){let N=A.mountpoint+Bt(O);S.some(U=>N.startsWith(U))||I.push(N)}S=[A.mountpoint,...S.filter(O=>!O.startsWith(A.mountpoint))]}return u?I.filter(A=>A.startsWith(u)&&A[A.length-1]!=="$"):I.filter(A=>A[A.length-1]!=="$")},async clear(u,g={}){u=Ko(u),await Promise.all(i(u,!1).map(async y=>{if(y.driver.clear)return dt(y.driver.clear,y.relativeBase,g);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",g);return Promise.all(S.map(I=>y.driver.removeItem(I,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>hg(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,g){if(u=Ko(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[u]=g,e.watching&&Promise.resolve(ug(g,n,u)).then(y=>{e.unwatch[u]=y}).catch(console.error),f},async unmount(u,g=!0){u=Ko(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),g&&await hg(e.mounts[u]),e.mountpoints=e.mountpoints.filter(y=>y!==u),delete e.mounts[u])},getMount(u=""){u=Bt(u)+":";let g=t(u);return{driver:g.driver,base:g.base}},getMounts(u="",g={}){return u=Bt(u),i(u,g.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(u,g={})=>f.getKeys(u,g),get:(u,g={})=>f.getItem(u,g),set:(u,g,y={})=>f.setItem(u,g,y),has:(u,g={})=>f.hasItem(u,g),del:(u,g={})=>f.removeItem(u,g),remove:(u,g={})=>f.removeItem(u,g)};return f}function ug(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function hg(r){typeof r.dispose=="function"&&await dt(r.dispose)}function jn(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function ah(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=jn(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var oh;function Vo(){return oh||(oh=ah("keyval-store","keyval")),oh}function ch(r,e=Vo()){return e("readonly",t=>jn(t.get(r)))}function lg(r,e,t=Vo()){return t("readwrite",i=>(i.put(e,r),jn(i.transaction)))}function pg(r,e=Vo()){return e("readwrite",t=>(t.delete(r),jn(t.transaction)))}function gg(r=Vo()){return r("readwrite",e=>(e.clear(),jn(e.transaction)))}function H6(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},jn(r.transaction)}function mg(r=Vo()){return r("readonly",e=>{if(e.getAllKeys)return jn(e.getAllKeys());let t=[];return H6(e,i=>t.push(i.key)).then(()=>t)})}var G6=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),W6=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function ei(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return W6(r)}catch{return r}}function cr(r){return typeof r=="string"?r:G6(r)||""}var J6="idb-keyval",Y6=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=ah(r.dbName,r.storeName)),{name:J6,options:r,async hasItem(n){return!(typeof await ch(t(n),i)>"u")},async getItem(n){return await ch(t(n),i)??null},setItem(n,s){return lg(t(n),s,i)},removeItem(n){return pg(t(n),i)},getKeys(){return mg(i)},clear(){return gg(i)}}},X6="WALLET_CONNECT_V2_INDEXED_DB",Q6="keyvaluestorage",uh=class{constructor(){this.indexedDb=dg({driver:Y6({dbName:X6,storeName:Q6})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,cr(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},fh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Sc={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof fh<"u"&&fh.localStorage?Sc.exports=fh.localStorage:typeof window<"u"&&window.localStorage?Sc.exports=window.localStorage:Sc.exports=new e})();function Z6(r){var e;return[r[0],ei((e=r[1])!=null?e:"")]}var hh=class{constructor(){this.localStorage=Sc.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Z6)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return ei(t)}async setItem(e,t){this.localStorage.setItem(e,cr(t))}async removeItem(e){this.localStorage.removeItem(e)}},e5="wc_storage_version",bg=1,t5=async(r,e,t)=>{let i=e5,n=await e.getItem(i);if(n&&n>=bg){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let a=s.shift();if(!a)continue;let f=a.toLowerCase();if(f.includes("wc@")||f.includes("walletconnect")||f.includes("wc_")||f.includes("wallet_connect")){let u=await r.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(i,bg),t(e),r5(r,o)},r5=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},Ic=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new hh;this.storage=e;try{let t=new uh;t5(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var Ii=Be(ph()),Go=Be(ph());var g5={level:"info"},Wo="custom_context",vh=1e3*1024,gh=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Mc=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new gh(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},Rc=class{constructor(e,t=vh){this.level=e??"error",this.levelValue=Ii.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Mc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Ii.levels.values.error?console.error(e):t===Ii.levels.values.warn||t===Ii.levels.values.debug||t===Ii.levels.values.trace&&console.trace(e)}appendToLogs(e){this.logs.append(cr({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Mc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(cr({extraMetadata:e})),new Blob(t,{type:"application/json"})}},mh=class{constructor(e,t=vh){this.baseChunkLogger=new Rc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},bh=class{constructor(e,t=vh){this.baseChunkLogger=new Rc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},m5=Object.defineProperty,b5=Object.defineProperties,v5=Object.getOwnPropertyDescriptors,Sg=Object.getOwnPropertySymbols,y5=Object.prototype.hasOwnProperty,w5=Object.prototype.propertyIsEnumerable,Ig=(r,e,t)=>e in r?m5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Pc=(r,e)=>{for(var t in e||(e={}))y5.call(e,t)&&Ig(r,t,e[t]);if(Sg)for(var t of Sg(e))w5.call(e,t)&&Ig(r,t,e[t]);return r},Nc=(r,e)=>b5(r,v5(e));function Jo(r){return Nc(Pc({},r),{level:r?.level||g5.level})}function x5(r,e=Wo){return r[e]||""}function _5(r,e,t=Wo){return r[t]=e,r}function Tt(r,e=Wo){let t="";return typeof r.bindings>"u"?t=x5(r,e):t=r.bindings().context||"",t}function E5(r,e,t=Wo){let i=Tt(r,t);return i.trim()?`${i}/${e}`:e}function wt(r,e,t=Wo){let i=E5(r,e,t),n=r.child({context:i});return _5(n,i,t)}function S5(r){var e,t;let i=new mh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ii.default)(Nc(Pc({},r.opts),{level:"trace",browser:Nc(Pc({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function I5(r){var e;let t=new bh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ii.default)(Nc(Pc({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Ag(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?S5(r):I5(r)}var Tg=Be(kn()),Cc=class extends _r{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var Dc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},Oc=class{constructor(e,t){this.logger=e,this.core=t}},Lc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}},Fc=class extends _r{constructor(e){super()}},Uc=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var qc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}};var Bc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t}};var kc=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},zc=class{constructor(e,t){this.projectId=e,this.logger=t}},jc=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Kc=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Vc=class{constructor(e){this.client=e}};var ne=Be(Ts());var oa=Be(i1()),O1=Be(Yo()),L1=Be(Ts());var n1="EdDSA",s1="JWT",Zo=".",ea="base64url",Uh="utf8",qh="utf8",o1=":",a1="did",c1="key",Bh="base58btc",f1="z",u1="K36";function ta(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Hn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=ta(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var Vh={};qt(Vh,{identity:()=>I4});function w4(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var D=k-O;D!==k&&B[D]===0;)D++;for(var W=f.repeat(R);D>>0,k=new Uint8Array(U);A[R];){var B=t[A.charCodeAt(R)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,R++}if(A[R]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var D=new Uint8Array(O+(U-L)),W=O;L!==U;)D[W++]=k[L++];return D}}}function I(A){var R=S(A);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var x4=w4,_4=x4,h1=_4;var TP=new Uint8Array(0);var d1=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var l1=r=>new TextEncoder().encode(r),p1=r=>new TextDecoder().decode(r);var kh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},zh=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return m1(this,e)}},jh=class{constructor(e){this.decoders=e}or(e){return m1(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},m1=(r,e)=>new jh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Kh=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new kh(e,t,i),this.decoder=new zh(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Os=({name:r,prefix:e,encode:t,decode:i})=>new Kh(r,e,t,i),Yi=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=h1(t,e);return Os({prefix:r,name:e,encode:i,decode:s=>Ti(n(s))})},E4=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},S4=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<Os({prefix:e,name:r,encode(n){return S4(n,i,t)},decode(n){return E4(n,i,t,r)}});var I4=Os({prefix:"\0",name:"identity",encode:r=>p1(r),decode:r=>l1(r)});var $h={};qt($h,{base2:()=>A4});var A4=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Hh={};qt(Hh,{base8:()=>T4});var T4=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gh={};qt(Gh,{base10:()=>M4});var M4=Yi({prefix:"9",name:"base10",alphabet:"0123456789"});var Wh={};qt(Wh,{base16:()=>R4,base16upper:()=>P4});var R4=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),P4=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Jh={};qt(Jh,{base32:()=>Ls,base32hex:()=>O4,base32hexpad:()=>F4,base32hexpadupper:()=>U4,base32hexupper:()=>L4,base32pad:()=>C4,base32padupper:()=>D4,base32upper:()=>N4,base32z:()=>q4});var Ls=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),N4=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),C4=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),D4=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),O4=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),L4=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),F4=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),U4=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),q4=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yh={};qt(Yh,{base36:()=>B4,base36upper:()=>k4});var B4=Yi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),k4=Yi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xh={};qt(Xh,{base58btc:()=>ri,base58flickr:()=>z4});var ri=Yi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),z4=Yi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qh={};qt(Qh,{base64:()=>j4,base64pad:()=>K4,base64url:()=>V4,base64urlpad:()=>$4});var j4=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),K4=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V4=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$4=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zh={};qt(Zh,{base256emoji:()=>Y4});var b1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),H4=b1.reduce((r,e,t)=>(r[t]=e,r),[]),G4=b1.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function W4(r){return r.reduce((e,t)=>(e+=H4[t],e),"")}function J4(r){let e=[];for(let t of r){let i=G4[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Y4=Os({prefix:"\u{1F680}",name:"base256emoji",encode:W4,decode:J4});var id={};qt(id,{sha256:()=>gx,sha512:()=>mx});var X4=w1,v1=128,Q4=127,Z4=~Q4,ex=Math.pow(2,31);function w1(r,e,t){e=e||[],t=t||0;for(var i=t;r>=ex;)e[t++]=r&255|v1,r/=128;for(;r&Z4;)e[t++]=r&255|v1,r>>>=7;return e[t]=r|0,w1.bytes=t-i+1,e}var tx=ed,rx=128,y1=127;function ed(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw ed.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&y1)<=rx);return ed.bytes=s-i,t}var ix=Math.pow(2,7),nx=Math.pow(2,14),sx=Math.pow(2,21),ox=Math.pow(2,28),ax=Math.pow(2,35),cx=Math.pow(2,42),fx=Math.pow(2,49),ux=Math.pow(2,56),hx=Math.pow(2,63),dx=function(r){return r[ra.decode(r,e),ra.decode.bytes],Fs=(r,e,t=0)=>(ra.encode(r,e,t),e),Us=r=>ra.encodingLength(r);var Gn=(r,e)=>{let t=e.byteLength,i=Us(r),n=i+Us(t),s=new Uint8Array(n+t);return Fs(r,s,0),Fs(t,s,i),s.set(e,n),new qs(r,t,e,s)},x1=r=>{let e=Ti(r),[t,i]=ia(e),[n,s]=ia(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new qs(t,n,o,e)},_1=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&d1(r.bytes,e.bytes),qs=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var rd=({name:r,code:e,encode:t})=>new td(r,e,t),td=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Gn(this.code,t):t.then(i=>Gn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var S1=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),gx=rd({name:"sha2-256",code:18,encode:S1("SHA-256")}),mx=rd({name:"sha2-512",code:19,encode:S1("SHA-512")});var nd={};qt(nd,{identity:()=>yx});var I1=0,bx="identity",A1=Ti,vx=r=>Gn(I1,A1(r)),yx={code:I1,name:bx,encode:A1,digest:vx};var WP=new TextEncoder,JP=new TextDecoder;var Zc=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Qc,byteLength:Qc,code:Xc,version:Xc,multihash:Xc,bytes:Xc,_baseCache:Qc,asCID:Qc})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==sa)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ix)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=Gn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&_1(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return Ex(t,n,e||ri.encoder);default:return Sx(t,n,e||Ls.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Tx(/^0\.0/,Mx),!!(e&&(e[M1]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||T1(t,i,n.bytes))}else if(e!=null&&e[M1]===!0){let{version:t,multihash:i,code:n}=e,s=x1(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==sa)throw new Error(`Version 0 CID must use dag-pb (code: ${sa}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=T1(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,sa,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=Ti(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new qs(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=ia(e.subarray(t));return t+=S,y},n=i(),s=sa;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,a=i(),f=i(),u=t+f,g=u-o;return{version:n,codec:s,multihashCode:a,digestSize:f,multihashSize:g,size:u}}static parse(e,t){let[i,n]=_x(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},_x=(r,e)=>{switch(r[0]){case"Q":{let t=e||ri;return[ri.prefix,t.decode(`${ri.prefix}${r}`)]}case ri.prefix:{let t=e||ri;return[ri.prefix,t.decode(r)]}case Ls.prefix:{let t=e||Ls;return[Ls.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Ex=(r,e,t)=>{let{prefix:i}=t;if(i!==ri.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},Sx=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},sa=112,Ix=18,T1=(r,e,t)=>{let i=Us(r),n=i+Us(e),s=new Uint8Array(n+t.byteLength);return Fs(r,s,0),Fs(e,s,i),s.set(t,n),s},M1=Symbol.for("@ipld/js-cid/CID"),Xc={writable:!1,configurable:!1,enumerable:!0},Qc={writable:!1,enumerable:!1,configurable:!1},Ax="0.0.0-dev",Tx=(r,e)=>{if(!r.test(Ax))throw new Error(e)},Mx=`CID.isCID(v) is deprecated and will be removed in the next major release. -Following code pattern: - -if (CID.isCID(value)) { - doSomethingWithCID(value) -} - -Is replaced with: - -const cid = CID.asCID(value) -if (cid) { - // Make sure to use cid instead of value - doSomethingWithCID(cid) -} -`;var sd={...Vh,...$h,...Hh,...Gh,...Wh,...Jh,...Yh,...Xh,...Qh,...Zh},iN={...id,...nd};function P1(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var R1=P1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),od=P1("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=ta(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new qx:typeof navigator<"u"?k1(navigator.userAgent):Vx()}function jx(r){return r!==""&&zx.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function k1(r){var e=jx(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new Ux;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var pm=d8(),hd;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(hd||(hd={}));var Er;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Er||(Er={}));var gm="0123456789abcdef",lt=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();af[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(lm>af[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(dm)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(f=>{let u=i[f];try{if(u instanceof Uint8Array){let g="";for(let y=0;y>4],g+=gm[u[y]&15];n.push(f+"=Uint8Array(0x"+g+")")}else n.push(f+"="+JSON.stringify(u))}catch{n.push(f+"="+JSON.stringify(i[f].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case Er.NUMERIC_FAULT:{o="NUMERIC_FAULT";let f=e;switch(f){case"overflow":case"underflow":case"division-by-zero":o+="-"+f;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Er.CALL_EXCEPTION:case Er.INSUFFICIENT_FUNDS:case Er.MISSING_NEW:case Er.NONCE_EXPIRED:case Er.REPLACEMENT_UNDERPRICED:case Er.TRANSACTION_REPLACED:case Er.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let a=new Error(e);return a.reason=s,a.code=t,Object.keys(i).forEach(function(f){a[f]=i[f]}),a}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),pm&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:pm})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return ud||(ud=new r(um)),ud}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),hm){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}dm=!!e,hm=!!t}static setLogLevel(e){let t=af[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}lm=t}static from(e){return new r(e)}};lt.errors=Er;lt.levels=hd;var mm="bytes/5.7.0";var ft=new lt(mm);function vm(r){return!!r.toHexString}function zs(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return zs(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function ym(r){return Sr(r)&&!(r.length%2)||ld(r)}function bm(r){return typeof r=="number"&&r==r&&r%1===0}function ld(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!bm(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Qe(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),zs(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),vm(r)&&(r=r.toHexString()),Sr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":ft.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nQe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),zs(i)}function l8(r,e){r=Qe(r),r.length>e&&ft.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),zs(t)}function Sr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var dd="0123456789abcdef";function Rt(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=dd[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),vm(r))return r.toHexString();if(Sr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":ft.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(ld(r)){let t="0x";for(let i=0;i>4]+dd[n&15]}return t}return ft.throwArgumentError("invalid hexlify value","value",r)}function cf(r){if(typeof r!="string")r=Rt(r);else if(!Sr(r)||r.length%2)return null;return(r.length-2)/2}function ff(r,e,t){return typeof r!="string"?r=Rt(r):(!Sr(r)||r.length%2)&&ft.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Xi(r,e){for(typeof r!="string"?r=Rt(r):Sr(r)||ft.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&ft.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function uf(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(ym(r)){let t=Qe(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Rt(t.slice(0,32)),e.s=Rt(t.slice(32,64))):t.length===65?(e.r=Rt(t.slice(0,32)),e.s=Rt(t.slice(32,64)),e.v=t[64]):ft.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:ft.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Rt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=l8(Qe(e._vs),32);e._vs=Rt(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&ft.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=Rt(n);e.s==null?e.s=o:e.s!==o&&ft.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?ft.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&ft.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!Sr(e.r)?ft.throwArgumentError("signature missing or invalid r","signature",r):e.r=Xi(e.r,32),e.s==null||!Sr(e.s)?ft.throwArgumentError("signature missing or invalid s","signature",r):e.s=Xi(e.s,32);let t=Qe(e.s);t[0]>=128&&ft.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=Rt(t);e._vs&&(Sr(e._vs)||ft.throwArgumentError("signature invalid _vs","signature",r),e._vs=Xi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&ft.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function js(r){return"0x"+wm.default.keccak_256(Qe(r))}var Em=Be(bd());var _m="bignumber/5.7.0";var p8=Em.default.BN,YN=new lt(_m);function vd(r){return new p8(r,36).toString(16)}var Sm="strings/5.7.0";var Im=new lt(Sm),aa;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(aa||(aa={}));var Jn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(Jn||(Jn={}));function m8(r,e,t,i,n){return Im.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function Am(r,e,t,i,n){if(r===Jn.BAD_PREFIX||r===Jn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===Jn.OVERRUN?t.length-e-1:0}function b8(r,e,t,i,n){return r===Jn.OVERLONG?(i.push(n),0):(i.push(65533),Am(r,e,t,i,n))}var v8=Object.freeze({error:m8,ignore:Am,replace:b8});function ca(r,e=aa.current){e!=aa.current&&(Im.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return Qe(t)}var Tm=`Ethereum Signed Message: -`;function hf(r){return typeof r=="string"&&(r=ca(r)),js(pd([ca(Tm),ca(String(r.length)),r]))}var Mm="address/5.7.0";var fa=new lt(Mm);function Rm(r){Sr(r,20)||fa.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=Qe(js(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var w8=9007199254740991;function x8(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var yd={};for(let r=0;r<10;r++)yd[String(r)]=String(r);for(let r=0;r<26;r++)yd[String.fromCharCode(65+r)]=String(10+r);var Pm=Math.floor(x8(w8));function _8(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>yd[i]).join("");for(;e.length>=Pm;){let i=e.substring(0,Pm);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function Nm(r){let e=null;if(typeof r!="string"&&fa.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=Rm(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&fa.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==_8(r)&&fa.throwArgumentError("bad icap checksum","address",r),e=vd(r.substring(4));e.length<40;)e="0"+e;e=Rm("0x"+e)}else fa.throwArgumentError("invalid address","address",r);return e}var Cm="properties/5.7.0";var IC=new lt(Cm);function Ks(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Le=Be(bd()),fi=Be(la());function Ys(r,e,t){return t={path:e,exports:{},require:function(i,n){return $_(i,n??t.path)}},r(t,t.exports),t.exports}function $_(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Cd=gb;function gb(r,e){if(!r)throw new Error(e||"Assertion failed")}gb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Mr=Ys(function(r,e){"use strict";var t=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var f=[];if(typeof o!="string"){for(var u=0;u>8,S=g&255;y?f.push(y,S):f.push(S)}return f}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var a="",f=0;f(S>>1)-1?R=(S>>1)-O:R=O,I.isubn(R)):R=0,y[A]=R,I.iushrn(1)}return y}t.getNAF=i;function n(f,u){var g=[[],[]];f=f.clone(),u=u.clone();for(var y=0,S=0,I;f.cmpn(-y)>0||u.cmpn(-S)>0;){var A=f.andln(3)+y&3,R=u.andln(3)+S&3;A===3&&(A=-1),R===3&&(R=-1);var O;A&1?(I=f.andln(7)+y&7,(I===3||I===5)&&R===2?O=-A:O=A):O=0,g[0].push(O);var N;R&1?(I=u.andln(7)+S&7,(I===3||I===5)&&A===2?N=-R:N=R):N=0,g[1].push(N),2*y===O+1&&(y=1-y),2*S===N+1&&(S=1-S),f.iushrn(1),u.iushrn(1)}return g}t.getJSF=n;function s(f,u,g){var y="_"+u;f.prototype[u]=function(){return this[y]!==void 0?this[y]:this[y]=g.call(this)}}t.cachedProperty=s;function o(f){return typeof f=="string"?t.toArray(f,"hex"):f}t.parseBytes=o;function a(f){return new Le.default(f,"hex","le")}t.intFromLE=a}),mf=Yt.getNAF,H_=Yt.getJSF,bf=Yt.assert;function tn(r,e){this.type=r,this.p=new Le.default(e.p,16),this.red=e.prime?Le.default.red(e.prime):Le.default.mont(this.p),this.zero=new Le.default(0).toRed(this.red),this.one=new Le.default(1).toRed(this.red),this.two=new Le.default(2).toRed(this.red),this.n=e.n&&new Le.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Xn=tn;tn.prototype.point=function(){throw new Error("Not implemented")};tn.prototype.validate=function(){throw new Error("Not implemented")};tn.prototype._fixedNafMul=function(e,t){bf(e.precomputed);var i=e._getDoubles(),n=mf(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];bf(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};tn.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,R=g;if(o[A]!==1||o[R]!==1){f[A]=mf(i[A],o[A],this._bitLength),f[R]=mf(i[R],o[R],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[R].length,u);continue}var O=[t[A],null,null,t[R]];t[A].y.cmp(t[R].y)===0?(O[1]=t[A].add(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg())):t[A].y.cmp(t[R].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].add(t[R].neg())):(O[1]=t[A].toJ().mixedAdd(t[R]),O[2]=t[A].toJ().mixedAdd(t[R].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=H_(i[A],i[R]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[R]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var D=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};hr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};dr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};dr.prototype.pointFromX=function(e,t){e=new Le.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};dr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};dr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};pt.prototype.isInfinity=function(){return this.inf};pt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};pt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),a=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)};pt.prototype.getX=function(){return this.x.fromRed()};pt.prototype.getY=function(){return this.y.fromRed()};pt.prototype.mul=function(e){return e=new Le.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};pt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};pt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};pt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};pt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};pt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function _t(r,e,t,i){Xn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Le.default(0)):(this.x=new Le.default(e,16),this.y=new Le.default(t,16),this.z=new Le.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Dd(_t,Xn.BasePoint);dr.prototype.jpoint=function(e,t,i){return new _t(this,e,t,i)};_t.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};_t.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};_t.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),R=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,R)};_t.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};_t.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};_t.prototype.inspect=function(){return this.isInfinity()?"":""};_t.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var pf=Ys(function(r,e){"use strict";var t=e;t.base=Xn,t.short=W_,t.mont=null,t.edwards=null}),gf=Ys(function(r,e){"use strict";var t=e,i=Yt.assert;function n(a){a.type==="short"?this.curve=new pf.short(a):a.type==="edwards"?this.curve=new pf.edwards(a):this.curve=new pf.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(a,f){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var u=new n(f);return Object.defineProperty(t,a,{configurable:!0,enumerable:!0,value:u}),u}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:fi.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:fi.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:fi.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:fi.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:fi.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:fi.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:fi.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:fi.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function en(r){if(!(this instanceof en))return new en(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Mr.toArray(r.entropy,r.entropyEnc||"hex"),t=Mr.toArray(r.nonce,r.nonceEnc||"hex"),i=Mr.toArray(r.pers,r.persEnc||"hex");Cd(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var mb=en;en.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};en.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Mr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var J_=Yt.assert;function vf(r,e){if(r instanceof vf)return r;this._importDER(r,e)||(J_(r.r&&r.s,"Signature without r or s"),this.r=new Le.default(r.r,16),this.s=new Le.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var yf=vf;function Y_(){this.place=0}function Rd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function pb(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}vf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=pb(t),i=pb(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Pd(n,t.length),n=n.concat(t),n.push(2),Pd(n,i.length);var s=n.concat(i),o=[48];return Pd(o,s.length),o=o.concat(s),Yt.encode(o,e)};var X_=function(){throw new Error("unsupported")},bb=Yt.assert;function ur(r){if(!(this instanceof ur))return new ur(r);typeof r=="string"&&(bb(Object.prototype.hasOwnProperty.call(gf,r),"Unknown curve "+r),r=gf[r]),r instanceof gf.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var Q_=ur;ur.prototype.keyPair=function(e){return new Od(this,e)};ur.prototype.keyFromPrivate=function(e,t){return Od.fromPrivate(this,e,t)};ur.prototype.keyFromPublic=function(e,t){return Od.fromPublic(this,e,t)};ur.prototype.genKeyPair=function(e){e||(e={});for(var t=new mb({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||X_(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Le.default(2));;){var s=new Le.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};ur.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};ur.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Le.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new mb({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Le.default(1)),g=0;;g++){var y=n.k?n.k(g):new Le.default(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var R=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(R=R.umod(this.n),R.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&R.cmp(this.nh)>0&&(R=this.n.sub(R),O^=1),new yf({r:A,s:R,recoveryParam:O})}}}}}};ur.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Le.default(e,16)),i=this.keyFromPublic(i,n),t=new yf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a=o.invm(this.n),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};ur.prototype.recoverPubKey=function(r,e,t,i){bb((3&t)===t,"The recovery param is more than two bits"),e=new yf(e,i);var n=this.n,s=new Le.default(r),o=e.r,a=e.s,f=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};ur.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new yf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var Z_=Ys(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=Yt,t.rand=function(){throw new Error("unsupported")},t.curve=pf,t.curves=gf,t.ec=Q_,t.eddsa=null}),vb=Z_.ec;var yb="signing-key/5.7.0";var Fd=new lt(yb),Ld=null;function ui(){return Ld||(Ld=new vb("secp256k1")),Ld}var Ud=class{constructor(e){Ks(this,"curve","secp256k1"),Ks(this,"privateKey",Rt(e)),cf(this.privateKey)!==32&&Fd.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=ui().keyFromPrivate(Qe(this.privateKey));Ks(this,"publicKey","0x"+t.getPublic(!1,"hex")),Ks(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),Ks(this,"_isSigningKey",!0)}_addPoint(e){let t=ui().keyFromPublic(Qe(this.publicKey)),i=ui().keyFromPublic(Qe(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=ui().keyFromPrivate(Qe(this.privateKey)),i=Qe(e);i.length!==32&&Fd.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return uf({recoveryParam:n.recoveryParam,r:Xi("0x"+n.r.toString(16),32),s:Xi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=ui().keyFromPrivate(Qe(this.privateKey)),i=ui().keyFromPublic(Qe(qd(e)));return Xi("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function wb(r,e){let t=uf(e),i={r:Qe(t.r),s:Qe(t.s)};return"0x"+ui().recoverPubKey(Qe(r),i,t.recoveryParam).encode("hex",!1)}function qd(r,e){let t=Qe(r);if(t.length===32){let i=new Ud(t);return e?"0x"+ui().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Rt(t):"0x"+ui().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+ui().keyFromPublic(t).getPublic(!0,"hex"):Rt(t)}return Fd.throwArgumentError("invalid public or private key","key","[REDACTED]")}var xb="transactions/5.7.0";var sD=new lt(xb),_b;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(_b||(_b={}));function eE(r){let e=qd(r);return Nm(ff(js(ff(e,1)),12))}function Eb(r,e){return eE(wb(Qe(r),e))}var fl=Be(Nb()),Yv=Be(Ub()),Ea=Be(Yo()),no=Be(Bb()),jf=Be(Kb());var Xv=Be(Fv());var Uv={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var i7=":";function Sa(r){let[e,t]=r.split(i7);return{namespace:e,reference:t}}function Qv(r,e){return r.includes(":")?[r]:e.chains||[]}var n7=Object.defineProperty,qv=Object.getOwnPropertySymbols,s7=Object.prototype.hasOwnProperty,o7=Object.prototype.propertyIsEnumerable,Bv=(r,e,t)=>e in r?n7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,kv=(r,e)=>{for(var t in e||(e={}))s7.call(e,t)&&Bv(r,t,e[t]);if(qv)for(var t of qv(e))o7.call(e,t)&&Bv(r,t,e[t]);return r},a7="ReactNative",Vt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var c7="js";function Ia(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ss(){return!(0,Ui.getDocument)()&&!!(0,Ui.getNavigator)()&&navigator.product===a7}function so(){return!Ia()&&!!(0,Ui.getNavigator)()&&!!(0,Ui.getDocument)()}function Aa(){return ss()?Vt.reactNative:Ia()?Vt.node:so()?Vt.browser:Vt.unknown}function Zv(){var r;try{return ss()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function f7(r,e){let t=io.parse(r);return t=kv(kv({},t),e),r=io.stringify(t),r}function oo(){return(0,Jv.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function u7(){if(Aa()===Vt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){let{OS:t,Version:i}=global.Platform;return[t,i].join("-")}let r=z1();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function h7(){var r;let e=Aa();return e===Vt.browser?[e,((r=(0,Ui.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function ul(r,e,t){let i=u7(),n=h7();return[[r,e].join("-"),[c7,t].join("-"),i,n].join("/")}function ey({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a}){let f=t.split("?"),u=ul(r,e,i),g={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},y=f7(f[1]||"",g);return f[0]+"?"+y}function is(r,e){return r.filter(t=>e.includes(t)).length===r.length}function hl(r){return Object.fromEntries(r.entries())}function dl(r){return new Map(Object.entries(r))}function qi(r=Fi.FIVE_MINUTES,e){let t=(0,Fi.toMiliseconds)(r||Fi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,a)=>{s=setTimeout(()=>{a(new Error(e))},t),i=o,n=a})}}function os(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function ty(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function ry(r){return ty("topic",r)}function iy(r){return ty("id",r)}function Kf(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ut(r,e){return(0,Fi.fromMiliseconds)((e||Date.now())+(0,Fi.toMiliseconds)(r))}function gi(r){return Date.now()>=(0,Fi.toMiliseconds)(r)}function Fe(r,e){return`${r}${e?`:${e}`:""}`}function d7(r=[],e=[]){return[...new Set([...r,...e])]}async function ny({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=l7(s,r,e),a=Aa();if(a===Vt.browser){if(!((i=(0,Ui.getDocument)())!=null&&i.hasFocus()))return;o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,p7()?"_blank":"_self","noreferrer noopener")}else a===Vt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function l7(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${g7(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function sy(r,e){let t="";try{if(so()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function ll(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function pl(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Ta(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function p7(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function g7(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function oy(r){return Buffer.from(r,"base64").toString("utf-8")}var m7="https://rpc.walletconnect.org/v1";async function b7(r,e,t,i,n,s){switch(t.t){case"eip191":return v7(r,e,t.s);case"eip1271":return await y7(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function v7(r,e,t){return Eb(hf(e),t).toLowerCase()===r.toLowerCase()}async function y7(r,e,t,i,n,s){let o=Sa(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let a="0x1626ba7e",f="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",g=t.substring(2),y=hf(e).substring(2),S=a+y+f+u+g,I=await fetch(`${s||m7}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:w7(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:A}=await I.json();return A?A.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function w7(){return Date.now()+Math.floor(Math.random()*1e3)}var x7=Object.defineProperty,_7=Object.defineProperties,E7=Object.getOwnPropertyDescriptors,zv=Object.getOwnPropertySymbols,S7=Object.prototype.hasOwnProperty,I7=Object.prototype.propertyIsEnumerable,jv=(r,e,t)=>e in r?x7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,A7=(r,e)=>{for(var t in e||(e={}))S7.call(e,t)&&jv(r,t,e[t]);if(zv)for(var t of zv(e))I7.call(e,t)&&jv(r,t,e[t]);return r},T7=(r,e)=>_7(r,E7(e)),M7="did:pkh:",gl=r=>r?.split(":"),R7=r=>{let e=r&&gl(r);if(e)return r.includes(M7)?e[3]:e[1]},Vf=r=>{let e=r&&gl(r);if(e)return e[2]+":"+e[3]},Ma=r=>{let e=r&&gl(r);if(e)return e.pop()};async function ml(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=bl(n,n.iss),o=Ma(n.iss);return await b7(o,s,i,Vf(n.iss),t)}var bl=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ma(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,a=`Chain ID: ${R7(e)}`,f=`Nonce: ${r.nonce}`,u=`Issued At: ${r.iat}`,g=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(R=>` -- ${R}`).join("")}`:void 0,A=Ra(r.resources);if(A){let R=_a(A);n=F7(n,R)}return[t,i,"",n,"",s,o,a,f,u,g,y,S,I].filter(R=>R!=null).join(` -`)};function P7(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function N7(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function ns(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function C7(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:D7(e,t,i)}}}function D7(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function ay(r){return ns(r),`urn:recap:${P7(r).replace(/=/g,"")}`}function _a(r){let e=N7(r.replace("urn:recap:",""));return ns(e),e}function cy(r,e,t){let i=C7(r,e,t);return ay(i)}function O7(r){return r&&r.includes("urn:recap:")}function fy(r,e){let t=_a(r),i=_a(e),n=L7(t,i);return ay(n)}function L7(r,e){ns(r),ns(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,f)=>a.localeCompare(f)).forEach(a=>{var f,u;i.att[n]=T7(A7({},i.att[n]),{[a]:((f=r.att[n])==null?void 0:f[a])||((u=e.att[n])==null?void 0:u[a])})})}),i}function F7(r="",e){ns(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(a=>{let f=Object.keys(e.att[a]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));f.sort((y,S)=>y.action.localeCompare(S.action));let u={};f.forEach(y=>{u[y.ability]||(u[y.ability]=[]),u[y.ability].push(y.action)});let g=Object.keys(u).map(y=>(n++,`(${n}) '${y}': '${u[y].join("', '")}' for '${a}'.`));i.push(g.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function vl(r){var e;let t=_a(r);ns(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function yl(r){let e=_a(r);ns(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Ra(r){if(!r)return;let e=r?.[r.length-1];return O7(e)?e:void 0}var uy="base10",Dt="base16",mi="base64pad",ao="base64url",Pa="utf8",hy=0,Pr=1,co=2,U7=0,Kv=1,xa=12,wl=32;function dy(){let r=jf.generateKeyPair();return{privateKey:rt(r.secretKey,Dt),publicKey:rt(r.publicKey,Dt)}}function $f(){let r=(0,Ea.randomBytes)(wl);return rt(r,Dt)}function ly(r,e){let t=jf.sharedKey(at(r,Dt),at(e,Dt),!0),i=new Yv.HKDF(no.SHA256,t).expand(wl);return rt(i,Dt)}function fo(r){let e=(0,no.hash)(at(r,Dt));return rt(e,Dt)}function Nr(r){let e=(0,no.hash)(at(r,Pa));return rt(e,Dt)}function py(r){return at(`${r}`,uy)}function fn(r){return Number(rt(r,uy))}function gy(r){let e=py(typeof r.type<"u"?r.type:hy);if(fn(e)===Pr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?at(r.senderPublicKey,Dt):void 0,i=typeof r.iv<"u"?at(r.iv,Dt):(0,Ea.randomBytes)(xa),n=new fl.ChaCha20Poly1305(at(r.symKey,Dt)).seal(i,at(r.message,Pa));return yy({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function my(r,e){let t=py(co),i=(0,Ea.randomBytes)(xa),n=at(r,Pa);return yy({type:t,sealed:n,iv:i,encoding:e})}function by(r){let e=new fl.ChaCha20Poly1305(at(r.symKey,Dt)),{sealed:t,iv:i}=uo({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return rt(n,Pa)}function vy(r,e){let{sealed:t}=uo({encoded:r,encoding:e});return rt(t,Pa)}function yy(r){let{encoding:e=mi}=r;if(fn(r.type)===co)return rt(Hn([r.type,r.sealed]),e);if(fn(r.type)===Pr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return rt(Hn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return rt(Hn([r.type,r.iv,r.sealed]),e)}function uo(r){let{encoded:e,encoding:t=mi}=r,i=at(e,t),n=i.slice(U7,Kv),s=Kv;if(fn(n)===Pr){let u=s+wl,g=u+xa,y=i.slice(s,u),S=i.slice(u,g),I=i.slice(g);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(fn(n)===co){let u=i.slice(s),g=(0,Ea.randomBytes)(xa);return{type:n,sealed:u,iv:g}}let o=s+xa,a=i.slice(s,o),f=i.slice(o);return{type:n,sealed:f,iv:a}}function wy(r,e){let t=uo({encoded:r,encoding:e?.encoding});return xl({type:fn(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?rt(t.senderPublicKey,Dt):void 0,receiverPublicKey:e?.receiverPublicKey})}function xl(r){let e=r?.type||hy;if(e===Pr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function _l(r){return r.type===Pr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function El(r){return r.type===co}function q7(r){return new Xv.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function B7(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function k7(r){return Buffer.from(B7(r),"base64")}function xy(r,e){let[t,i,n]=r.split("."),s=k7(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),f=`${t}.${i}`,u=new no.SHA256().update(Buffer.from(f)).digest(),g=q7(e),y=Buffer.from(u).toString("hex");if(!g.verify(y,{r:o,s:a}))throw new Error("Invalid signature");return Bs(r).payload}var z7="irn";function Hf(r){return r?.relay||{protocol:z7}}function ho(r){let e=Uv[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var j7=Object.defineProperty,K7=Object.defineProperties,V7=Object.getOwnPropertyDescriptors,Vv=Object.getOwnPropertySymbols,$7=Object.prototype.hasOwnProperty,H7=Object.prototype.propertyIsEnumerable,$v=(r,e,t)=>e in r?j7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Hv=(r,e)=>{for(var t in e||(e={}))$7.call(e,t)&&$v(r,t,e[t]);if(Vv)for(var t of Vv(e))H7.call(e,t)&&$v(r,t,e[t]);return r},G7=(r,e)=>K7(r,V7(e));function W7(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Sl(r){if(!r.includes("wc:")){let f=oy(r);f!=null&&f.includes("wc:")&&(r=f)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=io.parse(s),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:J7(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:W7(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function J7(r){return r.startsWith("//")?r.substring(2):r}function Y7(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function Il(r){return`${r.protocol}:${r.topic}@${r.version}?`+io.stringify(Hv(G7(Hv({symKey:r.symKey},Y7(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Na(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function lo(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function X7(r){let e=[];return Object.values(r).forEach(t=>{e.push(...lo(t.accounts))}),e}function Q7(r,e){let t=[];return Object.values(r).forEach(i=>{lo(i.accounts).includes(e)&&t.push(...i.methods)}),t}function Z7(r,e){let t=[];return Object.values(r).forEach(i=>{lo(i.accounts).includes(e)&&t.push(...i.events)}),t}function e9(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Al(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=e9(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=d7(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var t9={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},r9={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Q(r,e){let{message:t,code:i}=r9[r];return{message:e?`${t} ${e}`:t,code:i}}function ke(r,e){let{message:t,code:i}=t9[r];return{message:e?`${t} ${e}`:t,code:i}}function hn(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function Ca(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function St(r){return typeof r>"u"}function et(r,e){return e&&St(r)?!0:typeof r=="string"&&!!r.trim().length}function Tl(r,e){return e&&St(r)?!0:typeof r=="number"&&!isNaN(r)}function _y(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return is(n,i)?(i.forEach(o=>{let{accounts:a,methods:f,events:u}=r.namespaces[o],g=lo(a),y=t[o];(!is(Qv(o,y),g)||!is(y.methods,f)||!is(y.events,u))&&(s=!1)}),s):!1}function zf(r){return et(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function i9(r){if(et(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&zf(t)}}return!1}function Ey(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(et(r,!1)){if(e(r))return!0;let t=oy(r);return e(t)}}catch{}return!1}function Sy(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function Iy(r){return r?.topic}function Ay(r,e){let t=null;return et(r?.publicKey,!1)||(t=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function Gv(r){let e=!0;return hn(r)?r.length&&(e=r.every(t=>et(t,!1))):e=!1,e}function n9(r,e,t){let i=null;return hn(e)&&e.length?e.forEach(n=>{i||zf(n)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):zf(r)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function s9(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=n9(n,Qv(n,s),`${e} ${t}`);o&&(i=o)}),i}function o9(r,e){let t=null;return hn(r)?r.forEach(i=>{t||i9(i)||(t=ke("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=ke("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function a9(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=o9(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function c9(r,e){let t=null;return Gv(r?.methods)?Gv(r?.events)||(t=ke("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=ke("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Ty(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=c9(i,`${e}, namespace`);n&&(t=n)}),t}function My(r,e,t){let i=null;if(r&&Ca(r)){let n=Ty(r,e);n&&(i=n);let s=s9(r,e,t);s&&(i=s)}else i=Q("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Gf(r,e){let t=null;if(r&&Ca(r)){let i=Ty(r,e);i&&(t=i);let n=a9(r,e);n&&(t=n)}else t=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ml(r){return et(r.protocol,!0)}function Ry(r,e){let t=!1;return e&&!r?t=!0:r&&hn(r)&&r.length&&r.forEach(i=>{t=Ml(i)}),t}function Py(r){return typeof r=="number"}function Ot(r){return typeof r<"u"&&typeof r!==null}function Ny(r){return!(!r||typeof r!="object"||!r.code||!Tl(r.code,!1)||!r.message||!et(r.message,!1))}function Cy(r){return!(St(r)||!et(r.method,!1))}function Dy(r){return!(St(r)||St(r.result)&&St(r.error)||!Tl(r.id,!1)||!et(r.jsonrpc,!1))}function Oy(r){return!(St(r)||!et(r.name,!1))}function Rl(r,e){return!(!zf(e)||!X7(r).includes(e))}function Ly(r,e,t){return et(t,!1)?Q7(r,e).includes(t):!1}function Fy(r,e,t){return et(t,!1)?Z7(r,e).includes(t):!1}function Pl(r,e,t){let i=null,n=f9(r),s=u9(e),o=Object.keys(n),a=Object.keys(s),f=Wv(Object.keys(r)),u=Wv(Object.keys(e)),g=f.filter(y=>!u.includes(y));return g.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. - Required: ${g.toString()} - Received: ${Object.keys(e).toString()}`)),is(o,a)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. - Required: ${o.toString()} - Approved: ${a.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=lo(e[y].accounts);S.includes(y)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} - Required: ${y} - Approved: ${S.toString()}`))}),o.forEach(y=>{i||(is(n[y].methods,s[y].methods)?is(n[y].events,s[y].events)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function f9(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function Wv(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function u9(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:lo(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Uy(r,e){return Tl(r,!1)&&r<=e.max&&r>=e.min}function Nl(){let r=Aa();return new Promise(e=>{switch(r){case Vt.browser:e(h9());break;case Vt.reactNative:e(d9());break;case Vt.node:e(l9());break;default:e(!0)}})}function h9(){return so()&&navigator?.onLine}async function d9(){return ss()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function l9(){return!0}function qy(r){switch(Aa()){case Vt.browser:p9(r);break;case Vt.reactNative:g9(r);break;case Vt.node:break}}function p9(r){!ss()&&so()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function g9(r){ss()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>r(e?.isConnected))}var cl={},un=class{static get(e){return cl[e]}static set(e,t){cl[e]=t}static delete(e){delete cl[e]}};var e2=Be(kn());var Ft={};qt(Ft,{DEFAULT_ERROR:()=>Oa,IBaseJsonRpcProvider:()=>ru,IEvents:()=>La,IJsonRpcConnection:()=>Fl,IJsonRpcProvider:()=>Fa,INTERNAL_ERROR:()=>Wf,INVALID_PARAMS:()=>jy,INVALID_REQUEST:()=>ky,METHOD_NOT_FOUND:()=>zy,PARSE_ERROR:()=>By,RESERVED_ERROR_CODES:()=>Cl,SERVER_ERROR:()=>Da,SERVER_ERROR_CODE_RANGE:()=>Jf,STANDARD_ERROR_MAP:()=>dn,formatErrorMessage:()=>Qy,formatJsonRpcError:()=>as,formatJsonRpcRequest:()=>Dr,formatJsonRpcResult:()=>po,getBigIntRpcId:()=>Cr,getError:()=>Xf,getErrorByCode:()=>Qf,isHttpUrl:()=>A9,isJsonRpcError:()=>Lt,isJsonRpcPayload:()=>ql,isJsonRpcRequest:()=>go,isJsonRpcResponse:()=>gn,isJsonRpcResult:()=>Qt,isJsonRpcValidationInvalid:()=>T9,isLocalhostUrl:()=>Ul,isNodeJs:()=>Xy,isReservedErrorCode:()=>Yf,isServerErrorCode:()=>m9,isValidDefaultRoute:()=>eu,isValidErrorCode:()=>Ky,isValidLeadingWildcardRoute:()=>x9,isValidRoute:()=>w9,isValidTrailingWildcardRoute:()=>_9,isValidWildcardRoute:()=>tu,isWsUrl:()=>iu,parseConnectionError:()=>Dl,payloadId:()=>bi,validateJsonRpcError:()=>b9});var By="PARSE_ERROR",ky="INVALID_REQUEST",zy="METHOD_NOT_FOUND",jy="INVALID_PARAMS",Wf="INTERNAL_ERROR",Da="SERVER_ERROR",Cl=[-32700,-32600,-32601,-32602,-32603],Jf=[-32e3,-32099],dn={[By]:{code:-32700,message:"Parse error"},[ky]:{code:-32600,message:"Invalid Request"},[zy]:{code:-32601,message:"Method not found"},[jy]:{code:-32602,message:"Invalid params"},[Wf]:{code:-32603,message:"Internal error"},[Da]:{code:-32e3,message:"Server error"}},Oa=Da;function m9(r){return r<=Jf[0]&&r>=Jf[1]}function Yf(r){return Cl.includes(r)}function Ky(r){return typeof r=="number"}function Xf(r){return Object.keys(dn).includes(r)?dn[r]:dn[Oa]}function Qf(r){let e=Object.values(dn).find(t=>t.code===r);return e||dn[Oa]}function b9(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!Ky(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(Yf(r.error.code)){let e=Qf(r.error.code);if(e.message!==dn[Oa].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Dl(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var kt={};qt(kt,{isNodeJs:()=>Xy});var Yy=Be(Ll());Ht(kt,Be(Ll()));var Xy=Yy.isNode;Ht(Ft,kt);function bi(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function Cr(r=6){return BigInt(bi(r))}function Dr(r,e,t){return{id:t||bi(),jsonrpc:"2.0",method:r,params:e}}function po(r,e){return{id:r,jsonrpc:"2.0",result:e}}function as(r,e,t){return{id:r,jsonrpc:"2.0",error:Qy(e,t)}}function Qy(r,e){return typeof r>"u"?Xf(Wf):(typeof r=="string"&&(r=Object.assign(Object.assign({},Xf(Da)),{message:r})),typeof e<"u"&&(r.data=e),Yf(r.code)&&(r=Qf(r.code)),r)}function w9(r){return r.includes("*")?tu(r):!/\W/g.test(r)}function eu(r){return r==="*"}function tu(r){return eu(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function x9(r){return!eu(r)&&tu(r)&&!r.split("*")[0].trim()}function _9(r){return!eu(r)&&tu(r)&&!r.split("*")[1].trim()}var La=class{},Fl=class extends La{constructor(e){super()}},ru=class extends La{constructor(){super()}},Fa=class extends ru{constructor(e){super()}};var E9="^https?:",S9="^wss?:";function I9(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Zy(r,e){let t=I9(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function A9(r){return Zy(r,E9)}function iu(r){return Zy(r,S9)}function Ul(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function ql(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function go(r){return ql(r)&&"method"in r}function gn(r){return ql(r)&&(Qt(r)||Lt(r))}function Qt(r){return"result"in r}function Lt(r){return"error"in r}function T9(r){return"error"in r&&r.valid===!1}var nu=class extends Fa{constructor(e){super(e),this.events=new e2.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Dr(e.method,e.params||[],e.id||Cr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Lt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),gn(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var s2=Be(kn());var M9=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:r2(),R9=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",i2=r=>r.split("?")[0],n2=10,P9=M9(),su=class{constructor(e){if(this.url=e,this.events=new s2.EventEmitter,this.registering=!1,!iu(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(cr(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!iu(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Ft.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Ul(e)},o=new P9(e,[],s);R9()?o.onerror=a=>{let f=a;i(this.emitError(f.error))}:o.on("error",a=>{i(this.emitError(a))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?ei(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=as(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Dl(e,i2(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>n2&&this.events.setMaxListeners(n2)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${i2(this.url)}`));return this.events.emit("register_error",t),t}};var cw=Be(k2()),fw=Be(nf()),uw="wc",hw=2,x0="core",xi=`${uw}@2:${x0}:`,aI={name:x0,logger:"error"},cI={database:":memory:"},fI="crypto",z2="client_ed25519_seed",uI=ne.ONE_DAY,hI="keychain",dI="0.3",lI="messages",pI="0.3",gI=ne.SIX_HOURS,mI="publisher",_0="irn",bI="error",dw="wss://relay.walletconnect.org",vI="relayer",Ut={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},yI="_subscription",mr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},wI=.1;var Ql="2.17.1";var We={link_mode:"link_mode",relay:"relay"},xI="0.3",_I="WALLETCONNECT_CLIENT_ID",j2="WALLETCONNECT_LINK_MODE_APPS",yi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var EI="subscription",SI="0.3",II=ne.FIVE_SECONDS*1e3,AI="pairing",TI="0.3";var ja={wc_pairingDelete:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:0},res:{ttl:ne.ONE_DAY,prompt:!1,tag:0}}},vn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Or={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},MI="history",RI="0.3",PI="expirer",Zt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},NI="0.3";var CI="verify-api",DI="https://verify.walletconnect.com",lw="https://verify.walletconnect.org",yo=lw,OI=`${yo}/v3`,LI=[DI,lw],FI="echo",UI="https://echo.walletconnect.com";var Lr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},wi={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},br={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},yn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},wn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},wo={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},qI=.1,BI="event-client",kI=86400,zI="https://pulse.walletconnect.org/batch";function jI(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var D=k-O;D!==k&&B[D]===0;)D++;for(var W=f.repeat(R);D>>0,k=new Uint8Array(U);A[R];){var B=t[A.charCodeAt(R)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,R++}if(A[R]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var D=new Uint8Array(O+(U-L)),W=O;L!==U;)D[W++]=k[L++];return D}}}function I(A){var R=S(A);if(R)return R;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var KI=jI,VI=KI,pw=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},$I=r=>new TextEncoder().encode(r),HI=r=>new TextDecoder().decode(r),Zl=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},e0=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return gw(this,e)}},t0=class{constructor(e){this.decoders=e}or(e){return gw(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},gw=(r,e)=>new t0({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),r0=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Zl(e,t,i),this.decoder=new e0(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},bu=({name:r,prefix:e,encode:t,decode:i})=>new r0(r,e,t,i),$a=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=VI(t,e);return bu({prefix:r,name:e,encode:i,decode:s=>pw(n(s))})},GI=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},WI=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<bu({prefix:e,name:r,encode(n){return WI(n,i,t)},decode(n){return GI(n,i,t,r)}}),JI=bu({prefix:"\0",name:"identity",encode:r=>HI(r),decode:r=>$I(r)}),YI=Object.freeze({__proto__:null,identity:JI}),XI=It({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),QI=Object.freeze({__proto__:null,base2:XI}),ZI=It({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),eA=Object.freeze({__proto__:null,base8:ZI}),tA=$a({prefix:"9",name:"base10",alphabet:"0123456789"}),rA=Object.freeze({__proto__:null,base10:tA}),iA=It({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),nA=It({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),sA=Object.freeze({__proto__:null,base16:iA,base16upper:nA}),oA=It({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),aA=It({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cA=It({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fA=It({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uA=It({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),hA=It({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),dA=It({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),lA=It({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),pA=It({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),gA=Object.freeze({__proto__:null,base32:oA,base32upper:aA,base32pad:cA,base32padupper:fA,base32hex:uA,base32hexupper:hA,base32hexpad:dA,base32hexpadupper:lA,base32z:pA}),mA=$a({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),bA=$a({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),vA=Object.freeze({__proto__:null,base36:mA,base36upper:bA}),yA=$a({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wA=$a({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),xA=Object.freeze({__proto__:null,base58btc:yA,base58flickr:wA}),_A=It({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),EA=It({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),SA=It({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),IA=It({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),AA=Object.freeze({__proto__:null,base64:_A,base64pad:EA,base64url:SA,base64urlpad:IA}),mw=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),TA=mw.reduce((r,e,t)=>(r[t]=e,r),[]),MA=mw.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function RA(r){return r.reduce((e,t)=>(e+=TA[t],e),"")}function PA(r){let e=[];for(let t of r){let i=MA[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var NA=bu({prefix:"\u{1F680}",name:"base256emoji",encode:RA,decode:PA}),CA=Object.freeze({__proto__:null,base256emoji:NA}),DA=bw,K2=128,OA=127,LA=~OA,FA=Math.pow(2,31);function bw(r,e,t){e=e||[],t=t||0;for(var i=t;r>=FA;)e[t++]=r&255|K2,r/=128;for(;r&LA;)e[t++]=r&255|K2,r>>>=7;return e[t]=r|0,bw.bytes=t-i+1,e}var UA=i0,qA=128,V2=127;function i0(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw i0.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&V2)<=qA);return i0.bytes=s-i,t}var BA=Math.pow(2,7),kA=Math.pow(2,14),zA=Math.pow(2,21),jA=Math.pow(2,28),KA=Math.pow(2,35),VA=Math.pow(2,42),$A=Math.pow(2,49),HA=Math.pow(2,56),GA=Math.pow(2,63),WA=function(r){return r(vw.encode(r,e,t),e),H2=r=>vw.encodingLength(r),n0=(r,e)=>{let t=e.byteLength,i=H2(r),n=i+H2(t),s=new Uint8Array(n+t);return $2(r,s,0),$2(t,s,i),s.set(e,n),new s0(r,t,e,s)},s0=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},yw=({name:r,code:e,encode:t})=>new o0(r,e,t),o0=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?n0(this.code,t):t.then(i=>n0(this.code,i))}else throw Error("Unknown type, must be binary type")}},ww=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),YA=yw({name:"sha2-256",code:18,encode:ww("SHA-256")}),XA=yw({name:"sha2-512",code:19,encode:ww("SHA-512")}),QA=Object.freeze({__proto__:null,sha256:YA,sha512:XA}),xw=0,ZA="identity",_w=pw,eT=r=>n0(xw,_w(r)),tT={code:xw,name:ZA,encode:_w,digest:eT},rT=Object.freeze({__proto__:null,identity:tT});new TextEncoder,new TextDecoder;var G2={...YI,...QI,...eA,...rA,...sA,...gA,...vA,...xA,...AA,...CA};({...QA,...rT});function iT(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Ew(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var W2=Ew("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Yl=Ew("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=iT(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=wt(t,this.name)}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,hl(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?dl(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},c0=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=fI,this.randomSessionIdentifier=$f(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=ad(n);return rf(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=dy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=ad(s),a=this.randomSessionIdentifier;return await F1(a,n,uI,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let a=this.getPrivateKey(n),f=ly(a,s);return this.setSymKey(f,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||fo(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let a=xl(o),f=cr(s);if(El(a))return my(f,o?.encoding);if(_l(a)){let S=a.senderPublicKey,I=a.receiverPublicKey;n=await this.generateSharedKey(S,I)}let u=this.getSymKey(n),{type:g,senderPublicKey:y}=a;return gy({type:g,symKey:u,message:f,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let a=wy(s,o);if(El(a)){let f=vy(s,o?.encoding);return ei(f)}if(_l(a)){let f=a.receiverPublicKey,u=a.senderPublicKey;n=await this.generateSharedKey(f,u)}try{let f=this.getSymKey(n),u=by({symKey:f,encoded:s,encoding:o?.encoding});return ei(u)}catch(f){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(f)}},this.getPayloadType=(n,s=mi)=>{let o=uo({encoded:n,encoding:s});return fn(o.type)},this.getPayloadSenderPublicKey=(n,s=mi)=>{let o=uo({encoded:n,encoding:s});return o.senderPublicKey?rt(o.senderPublicKey,Dt):void 0},this.core=e,this.logger=wt(t,this.name),this.keychain=i||new a0(this.core,this.logger)}get context(){return Tt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(z2)}catch{e=$f(),await this.keychain.set(z2,e)}return sT(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},f0=class extends Oc{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=lI,this.version=pI,this.initialized=!1,this.storagePrefix=xi,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=Nr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=Nr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=wt(e,this.name),this.core=t}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,hl(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?dl(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},u0=class extends Lc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new zi.EventEmitter,this.name=mI,this.queue=new Map,this.publishTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.failedPublishTimeout=(0,ne.toMiliseconds)(ne.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let a=s?.ttl||gI,f=Hf(s),u=s?.prompt||!1,g=s?.tag||0,y=s?.id||Cr().toString(),S={topic:i,message:n,opts:{ttl:a,relay:f,prompt:u,tag:g,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${g}`,A=Date.now(),R,O=1;try{for(;R===void 0;){if(Date.now()-A>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:O},`publisher.publish - attempt ${O}`),R=await await os(this.rpcPublish(i,n,a,f,u,g,y,s?.attestation).catch(N=>this.logger.warn(N)),this.publishTimeout,I),O++,R||await new Promise(N=>setTimeout(N,this.failedPublishTimeout))}this.relayer.events.emit(Ut.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw N;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=wt(t,this.name),this.registerEventListeners()}get context(){return Tt(this.logger)}rpcPublish(e,t,i,n,s,o,a,f){var u,g,y,S;let I={method:ho(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:f},id:a};return St((u=I.params)==null?void 0:u.prompt)&&((g=I.params)==null||delete g.prompt),St((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(zn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ut.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ut.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},h0=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},oT=Object.defineProperty,aT=Object.defineProperties,cT=Object.getOwnPropertyDescriptors,J2=Object.getOwnPropertySymbols,fT=Object.prototype.hasOwnProperty,uT=Object.prototype.propertyIsEnumerable,Y2=(r,e,t)=>e in r?oT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ka=(r,e)=>{for(var t in e||(e={}))fT.call(e,t)&&Y2(r,t,e[t]);if(J2)for(var t of J2(e))uT.call(e,t)&&Y2(r,t,e[t]);return r},Xl=(r,e)=>aT(r,cT(e)),d0=class extends qc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new h0,this.events=new zi.EventEmitter,this.name=EI,this.version=SI,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=xi,this.subscribeTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=Hf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let a=new ne.Watch;a.start(n);let f=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(f),a.stop(n),s(!0)),a.elapsed(n)>=II&&(clearInterval(f),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=wt(t,this.name),this.clientId=""}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=Hf(i);await this.rpcUnsubscribe(e,t,n);let s=ke("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===We.relay&&await this.restartToComplete();let s={method:ho(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let a=Nr(e+this.clientId);if(i?.transportType===We.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},(0,ne.toMiliseconds)(ne.ONE_SECOND)),a;let f=await os(this.relayer.request(s).catch(u=>this.logger.warn(u)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!f&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return f?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ut.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:ho(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await os(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:ho(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await os(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:ho(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Xl(Ka({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,Ka({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,Ka({},t)),this.topicMap.set(t.topic,e),this.events.emit(yi.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(yi.deleted,Xl(Ka({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(yi.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);hn(t)&&this.onBatchSubscribe(t.map((i,n)=>Xl(Ka({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(zn.pulse,async()=>{await this.checkPending()}),this.events.on(yi.created,async e=>{let t=yi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(yi.deleted,async e=>{let t=yi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},hT=Object.defineProperty,X2=Object.getOwnPropertySymbols,dT=Object.prototype.hasOwnProperty,lT=Object.prototype.propertyIsEnumerable,Q2=(r,e,t)=>e in r?hT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Z2=(r,e)=>{for(var t in e||(e={}))dT.call(e,t)&&Q2(r,t,e[t]);if(X2)for(var t of X2(e))lT.call(e,t)&&Q2(r,t,e[t]);return r},l0=class extends Fc{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new zi.EventEmitter,this.name=vI,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ne.toMiliseconds)(ne.THIRTY_SECONDS+ne.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||Cr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let a=await new Promise(async(f,u)=>{let g=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(mr.disconnect,g);let y=await o;this.provider.off(mr.disconnect,g),f(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Ia())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ut.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Ut.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(mr.payload,this.onPayloadHandler),this.provider.on(mr.connect,this.onConnectHandler),this.provider.on(mr.disconnect,this.onDisconnectHandler),this.provider.on(mr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?wt(e.logger,this.name):(0,Go.default)(Jo({level:e.logger||bI})),this.messages=new f0(this.logger,e.core),this.subscriber=new d0(this,this.logger),this.publisher=new u0(this,this.logger),this.relayUrl=e?.relayUrl||dw,this.projectId=e.projectId,this.bundleId=Zv(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return Tt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:We.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",f,u=g=>{g.topic===e&&(this.subscriber.off(yi.created,u),f())};return await Promise.all([new Promise(g=>{f=g,this.subscriber.on(yi.created,u)}),new Promise(async(g,y)=>{a=await this.subscriber.subscribe(e,Z2({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||a,g()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await os(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(mr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(mr.disconnect,n),await os(this.provider.connect(),(0,ne.toMiliseconds)(ne.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Nl())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=ut(ne.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ut.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Ia())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new nu(new su(ey({sdkVersion:Ql,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),go(e)){if(!e.method.endsWith(yI))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,a={topic:i,message:n,publishedAt:s,transportType:We.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Z2({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else gn(e)&&this.events.emit(Ut.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ut.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=po(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(mr.payload,this.onPayloadHandler),this.provider.off(mr.connect,this.onConnectHandler),this.provider.off(mr.disconnect,this.onDisconnectHandler),this.provider.off(mr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Nl();qy(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ut.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ne.toMiliseconds)(wI))))}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},pT=Object.defineProperty,ew=Object.getOwnPropertySymbols,gT=Object.prototype.hasOwnProperty,mT=Object.prototype.propertyIsEnumerable,tw=(r,e,t)=>e in r?pT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rw=(r,e)=>{for(var t in e||(e={}))gT.call(e,t)&&tw(r,t,e[t]);if(ew)for(var t of ew(e))mT.call(e,t)&&tw(r,t,e[t]);return r},_i=class extends Uc{constructor(e,t,i,n=xi,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=xI,this.cached=[],this.initialized=!1,this.storagePrefix=xi,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!St(o)?this.map.set(this.getKey(o),o):Sy(o)?this.map.set(o.id,o):Iy(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(f=>(0,cw.default)(a[f],o[f]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let f=rw(rw({},this.getData(o)),a);this.map.set(o,f),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=wt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},p0=class{constructor(e,t){this.core=e,this.logger=t,this.name=AI,this.version=TI,this.events=new zi.default,this.initialized=!1,this.storagePrefix=xi,this.ignoredPayloadTypes=[Pr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=$f(),s=await this.core.crypto.setSymKey(n),o=ut(ne.FIVE_MINUTES),a={protocol:_0},f={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},u=Il({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(vn.create,f),this.core.expirer.set(s,o),await this.pairings.set(s,f),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Lr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:a,expiryTimestamp:f,methods:u}=Sl(i.uri);n.props.properties.topic=s,n.addTrace(Lr.pairing_uri_validation_success),n.addTrace(Lr.pairing_uri_not_expired);let g;if(this.pairings.keys.includes(s)){if(g=this.pairings.get(s),n.addTrace(Lr.existing_pairing),g.active)throw n.setError(wi.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Lr.pairing_not_expired)}let y=f||ut(ne.FIVE_MINUTES),S={topic:s,relay:a,expiry:y,active:!1,methods:u};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(Lr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(vn.create,S),n.addTrace(Lr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Lr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(wi.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(I){throw n.setError(wi.subscribe_pairing_topic_failure),I}return n.addTrace(Lr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=ut(ne.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:f}=qi();this.events.once(Fe("pairing_ping",s),({error:u})=>{u?f(u):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ke("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:a}=i,f=this.core.crypto.keychain.get(n);return Il({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:f,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{let o=Dr(n,s),a=await this.core.crypto.encode(i,o),f=ja[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,f),o.id},this.sendResult=async(i,n,s)=>{let o=po(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=ja[f.request.method].res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=as(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=ja[f.request.method]?ja[f.request.method].res:ja.unregistered_method.res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ke("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>gi(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(vn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{Qt(n)?this.events.emit(Fe("pairing_ping",s),{}):Lt(n)&&this.events.emit(Fe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(vn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let a=ke("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ke("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Ot(i)){let{message:a}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(wi.malformed_pairing_uri),new Error(a)}if(!Ey(i.uri)){let{message:a}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(wi.malformed_pairing_uri),new Error(a)}let o=Sl(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(wi.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(wi.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0,ne.toMiliseconds)(o?.expiryTimestamp){if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!et(i,!1)){let{message:n}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(gi(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=wt(t,this.name),this.pairings=new _i(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Tt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ut.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===We.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{go(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):gn(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Zt.expired,async e=>{let{topic:t}=Kf(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(vn.expire,{topic:t}))})}},g0=class extends Dc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new zi.EventEmitter,this.name=MI,this.version=RI,this.cached=[],this.initialized=!1,this.storagePrefix=xi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:ut(ne.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Or.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Lt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Or.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Or.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:Dr(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Or.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Or.created,e=>{let t=Or.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.updated,e=>{let t=Or.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.deleted,e=>{let t=Or.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(zn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,ne.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Or.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},m0=class extends Bc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new zi.EventEmitter,this.name=PI,this.version=NI,this.cached=[],this.initialized=!1,this.storagePrefix=xi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Zt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Zt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Tt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return ry(e);if(typeof e=="number")return iy(e);let{message:t}=Q("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Zt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,ne.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Zt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(zn.pulse,()=>this.checkExpirations()),this.events.on(Zt.created,e=>{let t=Zt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Zt.expired,e=>{let t=Zt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Zt.deleted,e=>{let t=Zt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},b0=class extends kc{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=CI,this.verifyUrlV3=OI,this.storagePrefix=xi,this.version=hw,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ne.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!so()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:a}=n,f=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{let u=(0,fw.getDocument)(),g=this.startAbortTimer(ne.ONE_SECOND*5),y=await new Promise((S,I)=>{let A=()=>{window.removeEventListener("message",O),u.body.removeChild(R),I("attestation aborted")};this.abortController.signal.addEventListener("abort",A);let R=u.createElement("iframe");R.src=f,R.style.display="none",R.addEventListener("error",A,{signal:this.abortController.signal});let O=N=>{if(N.data&&typeof N.data=="string")try{let U=JSON.parse(N.data);if(U.type==="verify_attestation"){if(Bs(U.attestation).payload.id!==o)return;clearInterval(g),u.body.removeChild(R),this.abortController.signal.removeEventListener("abort",A),window.removeEventListener("message",O),S(U.attestation===null?"":U.attestation)}}catch(U){this.logger.warn(U)}};u.body.appendChild(R),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Bs(s).payload.id!==a)return;let u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;let f=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,f)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(ne.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=n=>{let s=n||yo;return LI.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${yo}`),s=yo),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(ne.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=xy(n,s.publicKey),a={hasExpired:(0,ne.toMiliseconds)(o.exp)this.abortController.abort(),(0,ne.toMiliseconds)(e))}},v0=class extends zc{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=FI,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,f=`${UI}/${this.projectId}/clients`;await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})},this.logger=wt(t,this.context)}},bT=Object.defineProperty,iw=Object.getOwnPropertySymbols,vT=Object.prototype.hasOwnProperty,yT=Object.prototype.propertyIsEnumerable,nw=(r,e,t)=>e in r?bT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Va=(r,e)=>{for(var t in e||(e={}))vT.call(e,t)&&nw(r,t,e[t]);if(iw)for(var t of iw(e))yT.call(e,t)&&nw(r,t,e[t]);return r},y0=class extends jc{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=BI,this.storagePrefix=xi,this.storageVersion=qI,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Ta())try{let n={eventId:pl(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:ul(this.core.relayer.protocol,this.core.relayer.version,Ql)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:a,trace:f}}=n,u=pl(),g=this.core.projectId||"",y=Date.now(),S=Va({eventId:u,timestamp:y,props:{event:s,type:o,properties:{topic:a,trace:f}},bundleId:g,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let a=Array.from(this.events.values()).find(f=>f.props.properties.topic===o);if(a)return Va(Va({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(zn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,ne.fromMiliseconds)(Date.now())-(0,ne.fromMiliseconds)(n.timestamp)>kI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Va(Va({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${zI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ql}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>oo().url,this.logger=wt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},wT=Object.defineProperty,sw=Object.getOwnPropertySymbols,xT=Object.prototype.hasOwnProperty,_T=Object.prototype.propertyIsEnumerable,ow=(r,e,t)=>e in r?wT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,aw=(r,e)=>{for(var t in e||(e={}))xT.call(e,t)&&ow(r,t,e[t]);if(sw)for(var t of sw(e))_T.call(e,t)&&ow(r,t,e[t]);return r},w0=class r extends Cc{constructor(e){var t;super(e),this.protocol=uw,this.version=hw,this.name=x0,this.events=new zi.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:f})=>{if(!o||!a)return;let u={topic:o,message:a,publishedAt:Date.now(),transportType:We.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:f})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||dw,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Jo({level:typeof e?.logger=="string"&&e.logger?e.logger:aI.logger}),{logger:n,chunkLoggerController:s}=Ag({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=wt(n,this.name),this.heartbeat=new _c,this.crypto=new c0(this,this.logger,e?.keychain),this.history=new g0(this,this.logger),this.expirer=new m0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new Ic(aw(aw({},cI),e?.storageOptions)),this.relayer=new l0({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new p0(this,this.logger),this.verify=new b0(this,this.logger,this.storage),this.echoClient=new v0(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new y0(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(_I,i),t}get context(){return Tt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(j2,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(j2)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},Sw=w0;var wu=Be(kn()),qe=Be(Ts());var Mw="wc",Rw=2,Pw="client",D0=`${Mw}@${Rw}:${Pw}:`,E0={name:Pw,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var Iw="WALLETCONNECT_DEEPLINK_CHOICE";var ET="proposal";var ST="Proposal expired",IT="session",xo=qe.SEVEN_DAYS,AT="engine",vt={wc_sessionPropose:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:qe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:qe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1119}}},S0={min:qe.FIVE_MINUTES,max:qe.SEVEN_DAYS},Ei={idle:"IDLE",active:"ACTIVE"},TT="request",MT=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],RT="wc";var PT="auth",NT="authKeys",CT="pairingTopics",DT="requests",xu=`${RT}@${1.5}:${PT}:`,vu=`${xu}:PUB_KEY`,OT=Object.defineProperty,LT=Object.defineProperties,FT=Object.getOwnPropertyDescriptors,Aw=Object.getOwnPropertySymbols,UT=Object.prototype.hasOwnProperty,qT=Object.prototype.propertyIsEnumerable,Tw=(r,e,t)=>e in r?OT(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e)=>{for(var t in e||(e={}))UT.call(e,t)&&Tw(r,t,e[t]);if(Aw)for(var t of Aw(e))qT.call(e,t)&&Tw(r,t,e[t]);return r},Fr=(r,e)=>LT(r,FT(e)),I0=class extends Vc{constructor(e){super(e),this.name=AT,this.events=new wu.default,this.initialized=!1,this.requestQueue={state:Ei.idle,queue:[]},this.sessionRequestQueue={state:Ei.idle,queue:[]},this.requestQueueDelay=qe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(vt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=Fr(st({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:f}=i,u=n,g,y=!1;try{u&&(y=this.client.core.pairing.pairings.get(u).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),B}if(!u||!y){let{topic:B,uri:j}=await this.client.core.pairing.create();u=B,g=j}if(!u){let{message:B}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(B)}let S=await this.client.core.crypto.generateKeyPair(),I=vt.wc_sessionPropose.req.ttl||qe.FIVE_MINUTES,A=ut(I),R=st({requiredNamespaces:s,optionalNamespaces:o,relays:f??[{protocol:_0}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:A,pairingTopic:u},a&&{sessionProperties:a}),{reject:O,resolve:N,done:U}=qi(I,ST);this.events.once(Fe("session_connect"),async({error:B,session:j})=>{if(B)O(B);else if(j){j.self.publicKey=S;let V=Fr(st({},j),{pairingTopic:R.pairingTopic,requiredNamespaces:R.requiredNamespaces,optionalNamespaces:R.optionalNamespaces,transportType:We.relay});await this.client.session.set(j.topic,V),await this.setExpiry(j.topic,j.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(V),N(V)}});let k=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:R,throwOnFailedPublish:!0});return await this.setProposal(k,st({id:k},R)),{uri:g,approval:U}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[br.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(D){throw o.setError(yn.no_internet_connection),D}try{await this.isValidProposalId(t?.id)}catch(D){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(yn.proposal_not_found),D}try{await this.isValidApprove(t)}catch(D){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(yn.session_approve_namespace_validation_failure),D}let{id:a,relayProtocol:f,namespaces:u,sessionProperties:g,sessionConfig:y}=t,S=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:A,requiredNamespaces:R,optionalNamespaces:O}=S,N=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});N||(N=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:br.session_approve_started,properties:{topic:I,trace:[br.session_approve_started,br.session_namespaces_validation_success]}}));let U=await this.client.core.crypto.generateKeyPair(),k=A.publicKey,B=await this.client.core.crypto.generateSharedKey(U,k),j=st(st({relay:{protocol:f??"irn"},namespaces:u,controller:{publicKey:U,metadata:this.client.metadata},expiry:ut(xo)},g&&{sessionProperties:g}),y&&{sessionConfig:y}),V=We.relay;N.addTrace(br.subscribing_session_topic);try{await this.client.core.relayer.subscribe(B,{transportType:V})}catch(D){throw N.setError(yn.subscribe_session_topic_failure),D}N.addTrace(br.subscribe_session_topic_success);let L=Fr(st({},j),{topic:B,requiredNamespaces:R,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:A.publicKey,metadata:A.metadata},controller:U,transportType:We.relay});await this.client.session.set(B,L),N.addTrace(br.store_session);try{N.addTrace(br.publishing_session_settle),await this.sendRequest({topic:B,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(D=>{throw N?.setError(yn.session_settle_publish_failure),D}),N.addTrace(br.session_settle_publish_success),N.addTrace(br.publishing_session_approve),await this.sendResult({id:a,topic:I,result:{relay:{protocol:f??"irn"},responderPublicKey:U},throwOnFailedPublish:!0}).catch(D=>{throw N?.setError(yn.session_approve_publish_failure),D}),N.addTrace(br.session_approve_publish_success)}catch(D){throw this.client.logger.error(D),this.client.session.delete(B,ke("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(B),D}return this.client.core.eventClient.deleteEvent({eventId:N.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:A.metadata}),await this.client.proposal.delete(a,ke("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(B,ut(xo)),{topic:B,acknowledged:()=>Promise.resolve(this.client.session.get(B))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:vt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:a}=qi(),f=bi(),u=Cr().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Fe("session_update",f),({error:y})=>{y?a(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:f,relayRpcId:u}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:g}),a(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(f){throw this.client.logger.error("extend() -> isValidExtend() failed"),f}let{topic:i}=t,n=bi(),{done:s,resolve:o,reject:a}=qi();return this.events.once(Fe("session_extend",n),({error:f})=>{f?a(f):o()}),await this.setExpiry(i,ut(xo)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(f=>{a(f)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(A){throw this.client.logger.error("request() -> isValidRequest() failed"),A}let{chainId:i,request:n,topic:s,expiry:o=vt.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(s);a?.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let f=bi(),u=Cr().toString(),{done:g,resolve:y,reject:S}=qi(o,"Request expired. Please try again.");this.events.once(Fe("session_request",f),({error:A,result:R})=>{A?S(A):y(R)});let I=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return I?(await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(A=>S(A)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),await g()):await Promise.all([new Promise(async A=>{await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(R=>S(R)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),A()}),new Promise(async A=>{var R;if(!((R=a.sessionConfig)!=null&&R.disableDeepLink)){let O=await sy(this.client.core.storage,Iw);await ny({id:f,topic:s,wcDeepLink:O})}A()}),g()]).then(A=>A[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Qt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Lt(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=bi(),s=Cr().toString(),{done:o,resolve:a,reject:f}=qi();this.events.once(Fe("session_ping",n),({error:u})=>{u?f(u):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=Cr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ke("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>_y(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?We.link_mode:We.relay;o===We.relay&&await this.confirmOnlineStateOrThrow();let{chains:a,statement:f="",uri:u,domain:g,nonce:y,type:S,exp:I,nbf:A,methods:R=[],expiry:O}=t,N=[...t.resources||[]],{topic:U,uri:k}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:U,uri:k}});let B=await this.client.core.crypto.generateKeyPair(),j=fo(B);if(await Promise.all([this.client.auth.authKeys.set(vu,{responseTopic:j,publicKey:B}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:U})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${U}`),R.length>0){let{namespace:v}=Sa(a[0]),h=cy(v,"request",R);Ra(N)&&(h=fy(h,N.pop())),N.push(h)}let V=O&&O>vt.wc_sessionAuthenticate.req.ttl?O:vt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:a,statement:f,aud:u,domain:g,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:A,resources:N},requester:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(V)},D={eip155:{chains:a,methods:[...new Set(["personal_sign",...R])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:D,relays:[{protocol:"irn"}],pairingTopic:U,proposer:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(vt.wc_sessionPropose.req.ttl)},{done:P,resolve:l,reject:w}=qi(V,"Request expired"),p=async({error:v,session:h})=>{if(this.events.off(Fe("session_request",d),c),v)w(v);else if(h){h.self.publicKey=B,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:h.peer.metadata});let _=this.client.session.get(h.topic);await this.deleteProposal(b),l({session:_})}},c=async v=>{var h,_,T;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),v.error){let q=ke("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return v.error.code===q.code?void 0:(this.events.off(Fe("session_connect"),p),w(v.error.message))}await this.deleteProposal(b),this.events.off(Fe("session_connect"),p);let{cacaos:m,responder:M}=v.result,z=[],E=[];for(let q of m){await ml({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(ke("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,Y=Ra(K.resources),H=[Vf(K.iss)],$=Ma(K.iss);if(Y){let ee=vl(Y),G=yl(Y);z.push(...ee),H.push(...G)}for(let ee of H)E.push(`${ee}:${$}`)}let C=await this.client.core.crypto.generateSharedKey(B,M.publicKey),F;z.length>0&&(F={topic:C,acknowledged:!0,self:{publicKey:B,metadata:this.client.metadata},peer:M,controller:M.publicKey,expiry:ut(xo),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:U,namespaces:Al([...new Set(z)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(C,{transportType:o}),await this.client.session.set(C,F),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:M.metadata}),F=this.client.session.get(C)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(_=M.metadata.redirect)!=null&&_.linkMode&&(T=M.metadata.redirect)!=null&&T.universal&&i&&(this.client.core.addLinkModeSupportedApp(M.metadata.redirect.universal),this.client.session.update(C,{transportType:We.link_mode})),l({auths:m,session:F})},d=bi(),b=bi();this.events.once(Fe("session_connect"),p),this.events.once(Fe("session_request",d),c);let x;try{if(s){let v=Dr("wc_sessionAuthenticate",L,d);this.client.core.history.set(U,v);let h=await this.client.core.crypto.encode("",v,{type:co,encoding:ao});x=Na(i,U,h)}else await Promise.all([this.sendRequest({topic:U,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:U,method:"wc_sessionPropose",params:W,expiry:vt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(v){throw this.events.off(Fe("session_connect"),p),this.events.off(Fe("session_request",d),c),v}return await this.setProposal(b,st({id:b},W)),await this.setAuthRequest(d,{request:Fr(st({},L),{verifyContext:{}}),pairingTopic:U,transportType:o}),{uri:x??k,response:P}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[wn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(wo.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(wo.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let a=o.transportType||We.relay;a===We.relay&&await this.confirmOnlineStateOrThrow();let f=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),g=fo(f),y={type:Pr,receiverPublicKey:f,senderPublicKey:u},S=[],I=[];for(let O of n){if(!await ml({cacao:O,projectId:this.client.core.projectId})){s.setError(wo.invalid_cacao);let j=ke("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:g,error:j,encodeOpts:y}),new Error(j.message)}s.addTrace(wn.cacaos_verified);let{p:N}=O,U=Ra(N.resources),k=[Vf(N.iss)],B=Ma(N.iss);if(U){let j=vl(U),V=yl(U);S.push(...j),k.push(...V)}for(let j of k)I.push(`${j}:${B}`)}let A=await this.client.core.crypto.generateSharedKey(u,f);s.addTrace(wn.create_authenticated_session_topic);let R;if(S?.length>0){R={topic:A,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:f,metadata:o.requester.metadata},controller:f,expiry:ut(xo),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Al([...new Set(S)],[...new Set(I)]),transportType:a},s.addTrace(wn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(A,{transportType:a})}catch(O){throw s.setError(wo.subscribe_authenticated_session_topic_failure),O}s.addTrace(wn.subscribe_authenticated_session_topic_success),await this.client.session.set(A,R),s.addTrace(wn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(wn.publishing_authenticated_session_approve);try{await this.sendResult({topic:g,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(O){throw s.setError(wo.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:R}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),f=fo(o),u={type:Pr,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:f,error:n,encodeOpts:u,rpcOpts:vt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return bl(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=t,{self:f}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ke("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(f.publicKey)&&await this.client.core.crypto.deleteKeyPair(f.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Iw).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,ke("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=Ei.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(yn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,ke("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=Ei.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,ut(vt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=We.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,a=s.request.expiryTimestamp||ut(vt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:f,throwOnFailedPublish:u,appLink:g}=t,y=Dr(n,s,f),S,I=!!g;try{let O=I?ao:mi;S=await this.client.core.crypto.encode(i,y,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let A;if(MT.includes(n)){let O=Nr(JSON.stringify(y)),N=Nr(S);A=await this.client.core.verify.register({id:N,decryptedId:O})}let R=vt[n].req;if(R.attestation=A,o&&(R.ttl=o),a&&(R.id=a),this.client.core.history.set(i,y),I){let O=Na(g,i,S);await global.Linking.openURL(O,this.client.name)}else{let O=vt[n].req;o&&(O.ttl=o),a&&(O.id=a),u?(O.internal=Fr(st({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(N=>this.client.logger.error(N))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:f}=t,u=po(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ao:mi;g=await this.client.core.crypto.encode(n,u,Fr(st({},a||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Na(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=vt[S.request.method].res;o?(I.internal=Fr(st({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,I)):this.client.core.relayer.publish(n,g,I).catch(A=>this.client.logger.error(A))}await this.client.core.history.resolve(u)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:f}=t,u=as(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ao:mi;g=await this.client.core.crypto.encode(n,u,Fr(st({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Na(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=a||vt[S.request.method].res;this.client.core.relayer.publish(n,g,I)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;gi(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{gi(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Ei.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Ei.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=Ei.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=t,f=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:f}))switch(f){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${f}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:a,id:f}=n;try{let u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(st({},n.params));let g=a.expiryTimestamp||ut(vt.wc_sessionPropose.req.ttl),y=st({id:f,pairingTopic:i,expiryTimestamp:g},a);await this.setProposal(f,y);let S=await this.getVerifyContext({attestationId:s,hash:Nr(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&u?.setError(wi.proposal_listener_not_found),u?.addTrace(Lr.emit_session_proposal),this.client.events.emit("session_proposal",{id:f,params:y,verifyContext:S})}catch(u){await this.sendError({id:f,topic:i,error:u,rpcOpts:vt.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(Qt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});let f=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:f});let u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});let g=await this.client.core.crypto.generateSharedKey(f,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});let y=await this.client.core.relayer.subscribe(g,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(Lt(i)){await this.client.proposal.delete(s,ke("USER_DISCONNECTED"));let o=Fe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Fe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:a,expiry:f,namespaces:u,sessionProperties:g,sessionConfig:y}=i.params,S=Fr(st(st({topic:t,relay:o,expiry:f,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},g&&{sessionProperties:g}),y&&{sessionConfig:y}),{transportType:We.relay}),I=Fe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Fe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;Qt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Fe("session_approve",n),{})):Lt(i)&&(await this.client.session.delete(t,ke("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,a=un.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:ke("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(st({topic:t},n));try{un.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(f){throw un.delete(o),f}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Fe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qt(i)?this.events.emit(Fe("session_update",n),{}):Lt(i)&&this.events.emit(Fe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,ut(xo)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Fe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qt(i)?this.events.emit(Fe("session_extend",n),{}):Lt(i)&&this.events.emit(Fe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Fe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Qt(i)?this.events.emit(Fe("session_ping",n),{}):Lt(i)&&this.events.emit(Fe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ut.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:ke("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:a,attestation:f,encryptedId:u,transportType:g}=t,{id:y,params:S}=a;try{await this.isValidRequest(st({topic:o},S));let I=this.client.session.get(o),A=await this.getVerifyContext({attestationId:f,hash:Nr(JSON.stringify(Dr("wc_sessionRequest",S,y))),encryptedId:u,metadata:I.peer.metadata,transportType:g}),R={id:y,topic:o,params:S,verifyContext:A};await this.setPendingSessionRequest(R),g===We.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(R):(this.addSessionRequestToSessionRequestQueue(R),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Fe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Qt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,a=un.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(st({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),un.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Qt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:a,transportType:f}=t;try{let{requester:u,authPayload:g,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:Nr(JSON.stringify(s)),encryptedId:a,metadata:u.metadata,transportType:f}),I={requester:u,pairingTopic:n,id:s.id,authPayload:g,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:f}),f===We.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(u){this.client.logger.error(u);let g=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,f),I={type:Pr,receiverPublicKey:g,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:I,rpcOpts:vt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Ei.idle,this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,a=Fe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Fe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Ei.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Ei.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Dr("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(f)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=t;if(St(i)||await this.isValidPairingTopic(i),!Ry(a,!0)){let{message:f}=Q("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(f)}!St(n)&&Ca(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!St(s)&&Ca(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),St(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=My(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Ot(t))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let a=this.client.proposal.get(i),f=Gf(n,"approve()");if(f)throw new Error(f.message);let u=Pl(a.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!et(s,!0)){let{message:g}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}St(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Ot(t)){let{message:s}=Q("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Ny(n)){let{message:s}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Ot(t)){let{message:u}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(u)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Ml(i)){let{message:u}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}let a=Ay(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);let f=Gf(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(gi(o)){let{message:u}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(f)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=Gf(n,"update()");if(o)throw new Error(o.message);let a=Pl(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(f)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:a}=this.client.session.get(i);if(!Rl(a,s)){let{message:f}=Q("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!Cy(n)){let{message:f}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(f)}if(!Ly(a,s,n.method)){let{message:f}=Q("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(f)}if(o&&!Uy(o,S0)){let{message:f}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${S0.min} and ${S0.max}`);throw new Error(f)}},this.isValidRespond=async t=>{var i;if(!Ot(t)){let{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!Dy(s)){let{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Ot(t)){let{message:a}=Q("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!Rl(o,s)){let{message:a}=Q("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!Oy(n)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!Fy(o,s,n.name)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!et(n,!1))throw new Error("uri is required parameter");if(!et(s,!1))throw new Error("domain is required parameter");if(!et(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(f=>Sa(f).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:a}=Sa(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=t,f={verified:{verifyUrl:o.verifyUrl||yo,validation:"UNKNOWN",origin:o.url||""}};try{if(a===We.link_mode){let g=this.getAppLinkIfEnabled(o,a);return f.verified.validation=g&&new URL(g).origin===new URL(o.url).origin?"VALID":"INVALID",f}let u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(f.verified.origin=u.origin,f.verified.isScam=u.isScam,f.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(f)}`),f},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!et(n,!1)){let{message:s}=Q("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,a,f,u,g,y,S;return!t||i!==We.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((u=(f=this.client.metadata)==null?void 0:f.redirect)==null?void 0:u.universal)!==""&&((g=t?.redirect)==null?void 0:g.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=ll(t,"topic")||"",n=decodeURIComponent(ll(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:We.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Ta()||ss()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ut.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(vu)?this.client.auth.authKeys.get(vu):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===We.link_mode?ao:mi});try{go(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:n,transportType:s,encryptedId:Nr(i)})):gn(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:s}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:s})}catch(f){this.client.logger.error(f)}}registerExpirerEvents(){this.client.core.expirer.on(Zt.expired,async e=>{let{topic:t,id:i}=Kf(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(vn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(vn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=Q("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=Q("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(et(e,!1)){let{message:t}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Py(e)){let{message:t}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},A0=class extends _i{constructor(e,t){super(e,t,ET,D0),this.core=e,this.logger=t}},T0=class extends _i{constructor(e,t){super(e,t,IT,D0),this.core=e,this.logger=t}},M0=class extends _i{constructor(e,t){super(e,t,TT,D0,i=>i.id),this.core=e,this.logger=t}},R0=class extends _i{constructor(e,t){super(e,t,NT,xu,()=>vu),this.core=e,this.logger=t}},P0=class extends _i{constructor(e,t){super(e,t,CT,xu),this.core=e,this.logger=t}},N0=class extends _i{constructor(e,t){super(e,t,DT,xu,i=>i.id),this.core=e,this.logger=t}},C0=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new R0(this.core,this.logger),this.pairingTopics=new P0(this.core,this.logger),this.requests=new N0(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},yu=class r extends Kc{constructor(e){super(e),this.protocol=Mw,this.version=Rw,this.name=E0.name,this.events=new wu.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||E0.name,this.metadata=e?.metadata||oo(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,Go.default)(Jo({level:e?.logger||E0.logger}));this.core=e?.core||new Sw(e),this.logger=wt(t,this.name),this.session=new T0(this.core,this.logger),this.proposal=new A0(this.core,this.logger),this.pendingRequest=new M0(this.core,this.logger),this.engine=new I0(this),this.auth=new C0(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return Tt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};function O0(r,e){let t=[...Np,...e?.methods??[]];e?.methods?.includes("mvx_signLoginToken")||t.push("mvx_signLoginToken");let i=[`${wr}:${r}`],n=e?.events??[];return{requiredNamespaces:{[wr]:{methods:t,chains:i,events:n}}}}function L0(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=e.find(O0(r)).filter(i=>i.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw"WalletConnect Session is not connected",new Error("WalletConnect Session is not connected")}function ji(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=L0(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function Nw(r){return!!r}function F0(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function U0({transaction:r,response:e}){if(!e)throw"WalletConnect could not sign the transactions. Invalid signatures",new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,a=r.guardian;if(a&&a!==o)throw"WalletConnect: Invalid Guardian",new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=Gt(t),i&&(r.guardianSignature=Gt(i)),r}function Cw(r){if(r)return{...r,url:oo().url}}async function Dw(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var er=class{constructor(e,t,i,n,s){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.options=s}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:Cw(this.options?.metadata)}:{},t=await yu.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=O0(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await Dw(Pp);let i=F0(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||ji(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:ke("USER_DISCONNECTED")});else{let t=ji(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:ke("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new Wt({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=yt.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return U0({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return yt.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];U0({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ji(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=ji(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?Nw(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=F0(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&ji(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=L0(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!hn(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var q0=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},tr=class r{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:Ip,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(i=>{setTimeout(()=>{window.location.href=e,i(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:Ap,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let i=this.buildWalletUrl({endpoint:Rp,callbackUrl:t?.callbackUrl,params:{message:$i(e.data)}});return await this.redirect(i),i}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1),t=Gu(e);if((t.status?.toString()||"")!=="signed")throw new uc;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Mp,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(Tp,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=Gu(e.slice(1));return r.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,Oo)&&e[Oo]===nc}getTxSignReturnValue(e){let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let s of t)if(!e[s]||!Array.isArray(e[s]))throw new Uo;let i=e.nonce.length;for(let s of t)if(e[s].length!==i)throw new Uo;let n=[];for(let s=0;s{let a=r.prepareWalletTransaction(o);for(let f in a)Object.prototype.hasOwnProperty.call(a,f)&&!Object.prototype.hasOwnProperty.call(n,f)&&(n[f]=[]),n[f].push(a[f])});let s=this.buildWalletUrl({endpoint:e,callbackUrl:i?.callbackUrl,params:n});window.location.href=s}};var B0=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},_o=class{constructor(e){this.config=Object.assign(new B0,e)}getToken(e,t,i){let n=this.encodeValue(e),s=this.encodeValue(t);return`${n}.${s}.${i}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),i=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${i}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(o=>o.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(rc(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var _u=(r,e)=>t=>{let i=t.data;try{i=Wu()&&typeof i=="string"?JSON.parse(i):i}catch{console.error("error parsing eventData",i)}let{type:n,payload:s}=i;!Wu()&&t.origin!=Do()||!(r===n||n==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",_u(r,e)),e({type:n,payload:s}))};var xn=class r{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",_u("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:i}=e.payload;if(i||!t)throw new Error("Unable to re-login");let{accessToken:n}=t;return n?(this.account=t,n):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(s=>yt.transactionToPlainObject(s))}),{data:i,error:n}=t.payload;if(n||!i)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return i.map(s=>yt.plainObjectToTransaction(s))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:$i(e.data)}}),{data:i,error:n}=t.payload;return n||!i?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(this.cancelAction(),null):i.status!=="signed"?(console.error("Could not sign message"),null):new Wt({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:Gt(i.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),Do()):t.parent&&t.parent.postMessage(e,Do())),await this.waitingForResponse(Cp[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",_u(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return r._instance||(r._instance=new r(e)),r._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var te=class{static set(e,t){if(!e)return;let i={...this.events,[e]:t};this.events=i}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var Ur=(U=>(U.onLoginStart="onLoginStart",U.onLoginSuccess="onLoginSuccess",U.onLoginFailure="onLoginFailure",U.onLogoutStart="onLogoutStart",U.onLogoutSuccess="onLogoutSuccess",U.onLogoutFailure="onLogoutFailure",U.onQrPending="onQrPending",U.onQrLoaded="onQrLoaded",U.onTxStart="onTxStart",U.onTxSent="onTxSent",U.onTxFinalized="onTxFinalized",U.onTxFailure="onTxFailure",U.onSignMsgStart="onSignMsgStart",U.onSignMsgFinalized="onSignMsgFinalized",U.onSignMsgFailure="onSignMsgFailure",U.onQueryStart="onQueryStart",U.onQueryFinalized="onQueryFinalized",U.onQueryFailure="onQueryFailure",U))(Ur||{}),_n=(o=>(o.ledger="ledger",o.mobile="mobile",o.webWallet="web-wallet",o.browserExtension="browser-extension",o.xAlias="x-alias",o.webview="webview",o))(_n||{}),k0=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(k0||{}),z0=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(z0||{});var ot=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);var Eo=async r=>{if(!r.dappProvider)throw new Error("Logout failed: There is no active session!");te.run("onLogoutStart");try{let e=await r.dappProvider.logout();return e&&(re.clear(),te.run("onLogoutSuccess")),e}catch(e){let t=ot(e);`${t}`,te.run("onLogoutFailure",t)}};function Eu(r){return r[Math.floor(Math.random()*r.length)]}var Ow=async r=>{if(!r.initOptions.walletConnectV2ProjectId||!r.initOptions.chainType)return;let e={onClientLogin:()=>{},onClientLogout:()=>Eo(r),onClientEvent:n=>{}},t=Eu(r.initOptions.walletConnectV2RelayAddresses),i=new er(e,At[r.initOptions.chainType].shortId,t,r.initOptions.walletConnectV2ProjectId);try{return await i.init(),i}catch{}};var $t=r=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(r)}};var j0=async(r,e)=>{let t=$t("signature"),i=$t("address"),n=re.get("address"),s=re.get("loginToken");if(t&&re.set("signature",t),i||n){i&&(re.set("address",i),window.history.replaceState(null,"",window.location.pathname));let o=new tr(`${r}${Wi}`);if(t&&e&&i){let f=new _o({apiUrl:e,origin:window.location.origin}).getToken(i,s,t);re.set("accessToken",f)}return o}};var Su=class r{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new r("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var Iu=class{constructor({apiUrl:e,chainType:t,apiTimeout:i}){this.chainType=t||dc,this.apiUrl=e||At[this.chainType]?.apiAddress,this.apiTimeout=i||At[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let i=new AbortController,n=setTimeout(()=>i.abort(),this.apiTimeout),s={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:i.signal};try{let o=await fetch(this.apiUrl+"/"+e,Object.assign(s,t||{})),a=await o.json();if(!o.ok){let f=a?.error||o.status;return clearTimeout(n),Promise.reject(f)}return clearTimeout(n),a}catch(o){this.handleApiError(o,e)}}}async apiPost(e,t,i){if(typeof fetch<"u"){let n=new AbortController,s=setTimeout(()=>n.abort(),this.apiTimeout),o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:n.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(o,i||{})),f=await a.json();if(!a.ok){let u=f?.error||a.status;return clearTimeout(s),Promise.reject(u)}return clearTimeout(s),f}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let i=e.response.data,n=i.error||i.message||JSON.stringify(i);throw new Error(n)}async sendTransaction(e){let t=yt.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),i=new Su(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:qn(t.data||""),status:i,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!i.isPending()}}async queryContract({address:e,func:t,args:i,value:n,caller:s}){try{let o={scAddress:e,caller:s,funcName:t,value:n,args:()=>i?.map(f=>rc(f))},a=await this.apiPost("query",o);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(o){this.handleApiError(o,"query")}}};var So=()=>new Date().setHours(new Date().getHours()+24),Au=r=>Date.now()>r;var ds=async r=>{let e=re.get("address"),t=re.get("expires");if(!(t&&Au(t))&&e&&r.networkProvider){let n=new Si(e);try{let s=await r.networkProvider.getAccount(e),o=await r.networkProvider.getGuardianData(e);re.set("address",e),re.set("activeGuardian",o.guarded&&o.activeGuardian?.address?o.activeGuardian.address:""),re.set("nonce",s.nonce.valueOf()),re.set("balance",s.balance.toString()),n.update(s)}catch(s){`${ot(s)}`}}};var Lw=async(r,e,t,i="/")=>{let n=await lc(),o={callbackUrl:encodeURIComponent(`${window.location.origin}${i}`),token:e};try{if(n&&!await n.login(o))throw new Error("There were problems while logging in!")}catch(u){let g=ot(u);throw new Error(g)}if(!n)throw new Error("There were problems with auth provider initialization!");let a=n.getAccount();re.set("loginToken",e);let f=a?.signature;if(f&&re.set("signature",f),r.networkProvider&&f)try{let u=await n.getAddress();if(!u)throw new Error("Canceled!");re.set("address",u),re.set("loginMethod","browser-extension"),re.set("expires",So()),await ds(r);let g=t.getToken(u,e,f);return re.set("accessToken",g),te.run("onLoginSuccess"),n}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var F3=Be(L3(),1);var DM=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},OM=r=>{let e=`${Op}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},LM=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},FM=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},dp={},UM=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",dp[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:dp[r.topic].signal}),t},qu={},qM=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=UM(r,e);return i.appendChild(s),qu[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:qu[r.topic].signal}),i},BM=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},kM=r=>{if(!r)return;document.getElementById(r)?.remove()},zM=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),jM=async r=>r?await(0,F3.toString)(r,{type:"svg"}):void 0,U3=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=await jM(e),o;if(s&&(o=DM(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),zM()&&n.appendChild(OM(e))),n&&t instanceof er){let a=t.pairings,f=async g=>{try{g&&(await t.logout({topic:g}),kM(g))}catch(y){`${ot(y)}`}finally{qu[g].abort()}},u=async g=>{try{let{approval:y}=await t.connect({topic:g,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(g)?.after(BM()),await t.login({approval:y,token:i})}catch(y){`${ot(y)}`}finally{for(let y of Object.values(qu))y?.abort();for(let y of Object.values(dp))y?.abort()}};if(a&&a.length>0){let g=LM();n.appendChild(g);let y=FM();g.appendChild(y);for(let S of a){let I=qM(S,f,u);g.appendChild(I)}}}return n};var q3=async(r,e,t,i)=>{if(!i)throw new Error("You haven't provided the QR code container DOM element id");let n=Eu(r.initOptions.walletConnectV2RelayAddresses);if(!n||!r.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!r.initOptions.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!r.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let s,o={onClientLogin:async()=>{if(r.dappProvider instanceof er){let f=await r.dappProvider.getAddress(),u=await r.dappProvider.getSignature();re.set("address",f),re.set("loginMethod","mobile"),re.set("expires",So()),await ds(r),u&&re.set("signature",u),re.set("loginToken",e);let g=t.getToken(f,e,u);re.set("accessToken",g),te.run("onLoginSuccess"),s?.replaceChildren()}},onClientLogout:async()=>{r.dappProvider instanceof er&&await Eo(r)},onClientEvent:f=>{}},a=new er(o,At[r.initOptions.chainType].shortId,n,r.initOptions.walletConnectV2ProjectId);try{if(a){r.dappProvider=a,te.run("onQrPending"),await a.init();let{uri:f,approval:u}=await a.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),g=e?`${f}&token=${e}`:f;return i&&g&&(s=await U3(i,g,a,e),te.run("onQrLoaded")),await a.login({approval:u,token:e}),a}}catch(f){let u=ot(f);`${u}`,te.run("onLoginFailure",u)}};var lp=async(r,e,t,i)=>{let n=new tr(`${r}${Wi}`),o={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${i||"/"}`):"/",token:e};try{return re.set("loginMethod",At[t].xAliasAddress===r?"x-alias":"web-wallet"),await n.login(o),re.set("expires",So()),re.set("loginToken",e),n}catch(a){let f=ot(a);`${f}`,re.set("loginMethod",""),te.run("onLoginFailure",f)}};var Bu=async(r,e)=>{te.run("onTxSent",r);let i=await new qo(e).awaitCompleted(r.txHash),n=i.sender,s=new Si(n),o=await e.getAccount(n);s.update(o),re.set("address",s.bech32()),re.set("balance",s.balance),te.run("onTxFinalized",i)};var ku=r=>{let e=r.sender,t=new Si(e),i=r.nonce.valueOf();t.incrementNonce(),re.set("nonce",(i+1n).toString())};var B3=async(r,e,t,i)=>{if($t(Oo)===nc&&r&&e){let s=re.get("activeGuardian"),o=re.get("loginMethod"),a=$t("hasWebWalletGuardianSign"),f;if("getTransactionsFromWalletUrl"in r){if(f=r.getTransactionsFromWalletUrl()?.[0],!f)return;o==="web-wallet"&&(f.data=Hi(f.data))}else s&&o!=="web-wallet"&&o!=="x-alias"&&a&&(f=new tr(`${t}${Wi}`).getTransactionsFromWalletUrl()?.[0]);if(f){let u=yt.plainObjectToTransaction(f);u.nonce=BigInt(i),ku(u);try{te.run("onTxStart",u);let g=await e.sendTransaction(u);await Bu(g,e)}catch(g){let S=`Getting transaction information failed! ${ot(g)}`;throw te.run("onTxFailure",u,S),new Error(S)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var k3=r=>{let e=re.get("activeGuardian");return e&&(r.version=ic,r.options=_p,r.guardian=e),r},z3=async(r,e)=>{let t=new tr(`${e}${Wi}`),i=window?.location.href,n=new URL(i);n.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([r],{callbackUrl:encodeURIComponent(n.toString())})},j3=r=>{let e=re.get("activeGuardian");return!(!re.get("address")||!e||r.isGuardedTransaction())};var K3=()=>{let r=!$t("walletProviderStatus"),e=$t("status")==="signed",t=$t("message"),i=$t("signature");r&&e&&t&&i&&(te.run("onSignMsgFinalized",t,i),window.history.replaceState(null,"",window.location.pathname))};function KM(r){try{let e=atob(r),t=btoa(e),i=Co(r),n=Hi(i),s=r===t||t.startsWith(r),o=r===n||n.startsWith(r);if(s&&o)return!0}catch{return!1}return!1}function Po(r){return KM(r)?atob(r):r}var zu=r=>Object.prototype.toString.call(r)==="[object String]";var V3=r=>{if(!r||!zu(r))return null;let e=r.split(".");if(e.length!==4)return null;try{let[t,i,n,s]=e,o=JSON.parse(Po(s)),a=Po(t);return{ttl:Number(n),extraInfo:o,origin:a,blockHash:i}}catch(t){return console.error(`Error trying to decode ${r}:`,t),null}};var $3=r=>{if(!r||!zu(r))return null;let e=r.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,i,n]=e,s=Po(t),o=Po(i),a=V3(o);if(!a)return{address:s,body:o,signature:n,blockHash:"",origin:"",ttl:0};let f={...a,address:s,body:o,signature:n};return a.extraInfo?.timestamp||delete f.extraInfo,f}catch{return null}};function H3(r,e){let t=$3(r);if(t==null)return;let{signature:i,address:n,body:s}=t;i&&r&&n&&(re.set("loginToken",s),re.set("accessToken",r),re.set("signature",i),re.set("address",n),re.set("loginMethod","webview"),e.dappProvider=new xn)}var G3=r=>{r.onLoginStart&&te.set("onLoginStart",r.onLoginStart),r.onLoginSuccess&&te.set("onLoginSuccess",r.onLoginSuccess),r.onLoginFailure&&te.set("onLoginFailure",r.onLoginFailure),r.onLogoutStart&&te.set("onLogoutStart",r.onLogoutStart),r.onLogoutSuccess&&te.set("onLogoutSuccess",r.onLogoutSuccess),r.onLogoutFailure&&te.set("onLogoutFailure",r.onLogoutFailure),r.onQrPending&&te.set("onQrPending",r.onQrPending),r.onQrLoaded&&te.set("onQrLoaded",r.onQrLoaded),r.onTxStart&&te.set("onTxStart",r.onTxStart),r.onTxSent&&te.set("onTxSent",r.onTxSent),r.onTxFinalized&&te.set("onTxFinalized",r.onTxFinalized),r.onTxFailure&&te.set("onTxFailure",r.onTxFailure),r.onSignMsgStart&&te.set("onSignMsgStart",r.onSignMsgStart),r.onSignMsgFinalized&&te.set("onSignMsgFinalized",r.onSignMsgFinalized),r.onSignMsgFailure&&te.set("onSignMsgFailure",r.onSignMsgFailure),r.onQueryStart&&te.set("onQueryStart",r.onQueryStart),r.onQueryFinalized&&te.set("onQueryFinalized",r.onQueryFinalized),r.onQueryFailure&&te.set("onQueryFailure",r.onQueryFailure)};var ju=async r=>{te.run("onLoginStart");try{await r(()=>{te.run("onLoginSuccess")})}catch(e){let t=ot(e);`${t}`,te.run("onLoginFailure",t)}};var bs=class bs{static async init(e){let t=re.get();if(t.expires&&Au(t.expires)){re.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:dc,apiUrl:Dp,apiTimeout:1e4,walletConnectV2ProjectId:"",walletConnectV2RelayAddresses:Lp,...e},this.networkProvider=new Iu(this.initOptions),G3(this.initOptions);let i=$t("accessToken");i&&await ju(async s=>{H3(i,this),await ds(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&$t("address"))&&t?.loginMethod&&(await ju(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await lc()),t.loginMethod==="mobile"&&(this.dappProvider=await Ow(this)),t.loginMethod==="webview"&&(this.dappProvider=new xn),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await j0(At[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await j0(At[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await ds(this),s()}),this.initOptions?.chainType&&(await B3(this.dappProvider,this.networkProvider,At[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),K3()))}static async login(e,t){if(!Object.values(_n).includes(e)){let n="Wrong login method!";throw te.run("onLoginFailure",n),new Error(n)}if(!this.networkProvider){let n="Login failed: Use ElvenJs.init() first!";throw te.run("onLoginFailure",n),new Error(n)}await ju(async()=>{let n=new _o({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),s=await n.initialize();if(e==="browser-extension"){let o=await Lw(this,s,n,t?.callbackRoute);this.dappProvider=o}if(e==="mobile"){let o=await q3(this,s,n,t?.qrCodeContainer);this.dappProvider=o}if(e==="web-wallet"&&this.initOptions?.chainType){let o=await lp(At[this.initOptions.chainType].walletAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}if(e==="x-alias"&&this.initOptions?.chainType){let o=await lp(At[this.initOptions.chainType].xAliasAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}})}static async logout(){try{let e=await Eo(this);return this.dappProvider=void 0,e}catch(e){let t=ot(e)}}static async signAndSendTransaction(e){if(!this.dappProvider){let i="Transaction signing failed: There is no active session!";throw te.run("onTxFailure",e,i),new Error(i)}if(!this.networkProvider){let i="Transaction signing failed: There is no active network provider!";throw te.run("onTxFailure",e,i),new Error(i)}let t=k3(e);try{te.run("onTxStart",e);let i=re.get();if(e.nonce=i.nonce,this.dappProvider instanceof Bn&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof er&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof xn&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof tr&&await this.dappProvider.signTransaction(e),i.loginMethod!=="web-wallet"&&i.loginMethod!=="x-alias"){let n=j3(t);if(n||ku(t),n&&this.initOptions?.chainType){await z3(t,At[this.initOptions.chainType].walletAddress);return}let s=await this.networkProvider.sendTransaction(t);await Bu(s,this.networkProvider)}}catch(i){let n=ot(i);throw te.run("onTxFailure",t,`Getting transaction information failed! ${n}`),new Error(`Getting transaction information failed! ${n}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let n="Message signing failed: There is no active session!";throw te.run("onSignMsgFailure",e,n),new Error(n)}if(!this.networkProvider){let n="Message signing failed: There is no active network provider!";throw te.run("onSignMsgFailure",e,n),new Error(n)}let i="";try{if(te.run("onSignMsgStart",e),this.dappProvider instanceof Bn){let s=await this.dappProvider.signMessage(new Wt({data:Vi(e)}));s?.signature&&(i=ar(s.signature))}if(this.dappProvider instanceof er){let s=await this.dappProvider.signMessage(new Wt({data:Vi(e)}));s?.signature&&(i=ar(s.signature))}if(this.dappProvider instanceof xn){let s=await this.dappProvider.signMessage(new Wt({data:Vi(e)}));s?.signature&&(i=ar(s.signature))}if(this.dappProvider instanceof tr){let s=a=>encodeURIComponent(a).replace(/[!'()*]/g,f=>`%${f.charCodeAt(0).toString(16).toUpperCase()}`),o=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new Wt({data:Vi(e)}),{callbackUrl:encodeURIComponent(`${o}${o.includes("?")?"&":"?"}message=${s(e)}`)})}let n=re.get();return n.loginMethod!=="web-wallet"&&n.loginMethod!=="x-alias"&&te.run("onSignMsgFinalized",e,i),{message:e,messageSignature:i}}catch(n){let s=ot(n);throw te.run("onSignMsgFailure",e,s),new Error(`Message signing failed! ${s}`)}}static async queryContract({address:e,func:t,args:i=[],value:n=0,caller:s}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let o={address:e,func:t,args:i,value:n,caller:s};try{te.run("onQueryStart",o);let a=await this.networkProvider.queryContract(o);return te.run("onQueryFinalized",a),a}catch(a){let f=ot(a);throw te.run("onQueryFinalized",o,f),new Error(`Smart contract query failed! ${f}`)}}};bs.storage=re,bs.destroy=()=>{bs.networkProvider=void 0,bs.dappProvider=void 0,bs.initOptions=void 0,te.clear()};var pp=bs;var VM=({amount:r,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=r.toString().replace(/,/g,""),[i,n=""]=t.split("."),s=i+n.padEnd(e,"0");return s=s.substring(0,i.length+e),BigInt(s)},W3=({amount:r,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let i=BigInt(r)<0n,n=BigInt(r).toString();i&&(n=n.slice(1)),n=n.padStart(e+1,"0");let s=n.slice(0,-e),o=n.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),g=BigInt(r)+u;return i&&(g=-g),W3({amount:g,decimals:e,rounding:t})}}let a=`${s}.${o.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),i&&(a=`-${a}`),a};export{Si as Account,k0 as DappCoreWCV2CustomMethodsEnum,pp as ElvenJS,Ur as EventStoreEvents,_n as LoginMethodsEnum,Lo as Transaction,qo as TransactionWatcher,z0 as WebWalletUrlParamsEnum,W3 as formatAmount,VM as parseAmount}; +var _="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ne=new Uint8Array(256);for(let n=0;n<_.length;n++)Ne[_.charCodeAt(n)]=n;var rt=new TextEncoder,it=new TextDecoder,ke=n=>/^[0-9a-fA-F]{64}$/.test(n),R=n=>rt.encode(n),I=n=>it.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),X=n=>b(R(n)),C=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},ot=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Ee=a&63;e+=_.charAt(l),e+=_.charAt(u),e+=r+1I(C(n)),E=n=>{let e=typeof n=="string"?R(n):n;return ot(e)};function st(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function at(n,e,t){let r=n;for(let o=0;o{Te([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&Te([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function we(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=st(r);at(t,i,o)}return t}function Ue(n){let e=[];return Te([],n,e),e.join("&")}var ct=()=>typeof window<"u"&&typeof window.location<"u",z=()=>{if(ct()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},ye=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var P=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";ke(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:b(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return b(this.address)}};var Oe=1e9,Me=0,J=2,We=2,be=64,_e=1;var De="sdk-js";var Fe="hook/login",Ge="hook/logout";var He="hook/sign",$e="hook/2fa",Be="hook/sign-message",Q="walletProviderStatus",Y="transactionsSigned";var qe={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var L=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||Oe),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||J),this.options=Number(e.options?.valueOf()||Me),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var Z=class extends v{constructor(){super("Async timer already running")}},ee=class extends v{constructor(){super("Async timer aborted")}};var D=class extends v{constructor(){super("Expected transaction status not reached")}},j=class extends v{constructor(){super("Expected transaction events not found")}};var te=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var ne=class extends v{constructor(){super("Cannot sign single transaction.")}},re=class extends v{constructor(){super("Account is not connected.")}},K=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},ie=class extends Error{constructor(){super("Cannot get signed message")}};var F=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new Z;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new ee),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var ve=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},S=class S{constructor(e,t={}){this.fetcher=new ve(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||S.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||S.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||S.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new D;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new te;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new D;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new j;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new j;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new D;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==be)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${be}.`);return t}async awaitConditionally(e,t,r){let o=new F("watcher:periodic"),i=new F("watcher:patience"),s=new F("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};S.DefaultPollingInterval=6e3,S.DefaultTimeout=S.DefaultPollingInterval*15,S.DefaultPatience=0,S.NoopOnStatusReceived=()=>{};var V=S;var w=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||_e,this.signer=e.signer||De}};var p=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?E(e.senderUsername):void 0,receiverUsername:e.receiverUsername?E(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?E(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?b(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?b(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new L({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:q(e.receiverUsername||""),sender:e.sender,senderUsername:q(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?C(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var N=class N{constructor(){this.account={address:""};this.initialized=!1;if(N._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");N._instance=this}static getInstance(){return N._instance}setAddress(e){return this.account.address=e,N._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new ne;return t[0]}ensureConnected(){if(!this.account.address)throw new re}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>p.transactionToPlainObject(r))});try{return t.map(o=>p.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:I(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new w({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};N._instance=new N;var O=N;var oe="elvenjs_state",ze="https://devnet-api.multiversx.com";var k="/dapp/init",se="devnet";var f={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(oe);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(oe,JSON.stringify(t))},clear(){localStorage.removeItem(oe)}};var ae=async()=>{let n=O.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var xe=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},y=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:Fe,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:Ge,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Be,callbackUrl:t?.callbackUrl,params:{message:I(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=we(e);if((t.status?.toString()||"")!=="signed")throw new ie;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint($e,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(He,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=we(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,Q)&&e[Q]===Y}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new K;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new K;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var Se=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},G=class{constructor(e){this.config=Object.assign(new Se,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(s=>s.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(X(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var ce=(n,e)=>t=>{let r=t.data;try{r=ye()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!ye()&&t.origin!=z()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",ce(n,e)),e({type:o,payload:i}))};var U=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",ce("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>p.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>p.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:I(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new w({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),z()):t.parent&&t.parent.postMessage(e,z())),await this.waitingForResponse(qe[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",ce(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var T=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var Ae=async(n,e)=>{let t=T("signature"),r=T("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new y(`${n}${k}`);if(t&&e&&r){let l=new G({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var de=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var le=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||se,this.apiUrl=e||f[this.chainType]?.apiAddress,this.apiTimeout=r||f[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=p.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new de(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:C(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>X(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var A=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(A||{}),M=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(M||{}),lt=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(lt||{}),Pe=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(Pe||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var h=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var ue=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=h(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var H=()=>new Date().setHours(new Date().getHours()+24),ge=n=>Date.now()>n;var $=async n=>{let e=d.get("address"),t=d.get("expires");if(!(t&&ge(t))&&e&&n.networkProvider){let o=new P(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=h(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Qe=async(n,e,t,r="/")=>{let o=await ae(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=h(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",H()),await $(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var Re=async(n,e,t,r)=>{let o=new y(`${n}${k}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",f[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",H()),d.set("loginToken",e),o}catch(a){let l=h(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var pe=async(n,e)=>{c.run("onTxSent",n);let r=await new V(e).awaitCompleted(n.txHash),o=r.sender,i=new P(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var he=n=>{let e=n.sender,t=new P(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var je=async(n,e,t,r)=>{if(T(Q)===Y&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=T("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=E(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new y(`${t}${k}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=p.plainObjectToTransaction(l);u.nonce=BigInt(r),he(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await pe(m,e)}catch(m){let Le=`Getting transaction information failed! ${h(m)}`;throw c.run("onTxFailure",u,Le),new Error(Le)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var Ke=n=>{let e=d.get("activeGuardian");return e&&(n.version=J,n.options=We,n.guardian=e),n},Ve=async(n,e)=>{let t=new y(`${e}${k}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},Xe=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Je=()=>{let n=!T("walletProviderStatus"),e=T("status")==="signed",t=T("message"),r=T("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ut(n){try{let e=atob(n),t=btoa(e),r=q(n),o=E(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function B(n){return ut(n)?atob(n):n}var me=n=>Object.prototype.toString.call(n)==="[object String]";var Ye=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(B(i)),a=B(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Ze=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=B(t),s=B(r),a=Ye(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function et(n,e){let t=Ze(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new U)}var tt=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure),n.onQrPending&&c.set("onQrPending",n.onQrPending),n.onQrLoaded&&c.set("onQrLoaded",n.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var fe=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=h(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var W=class W{static async init(e){let t=d.get();if(t.expires&&ge(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:se,apiUrl:ze,apiTimeout:1e4,...e},this.networkProvider=new le(this.initOptions),this.mobileProvider=this.initOptions?.externalSigningProviders?.mobile?.provider?new this.initOptions.externalSigningProviders.mobile.provider(this.initOptions.externalSigningProviders.mobile.config):void 0,tt(this.initOptions);let r=T("accessToken");r&&await fe(async i=>{et(r,this),await $(this),i()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&T("address"))&&t?.loginMethod&&(await fe(async i=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await ae()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this,ue,f,w,L,p)),t.loginMethod==="webview"&&(this.dappProvider=new U),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await Ae(f[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await Ae(f[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await $(this),i()}),this.initOptions?.chainType&&(await je(this.dappProvider,this.networkProvider,f[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Je()))}static async login(e,t){if(!Object.values(M).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await fe(async()=>{let o=new G({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize();if(e==="browser-extension"){let s=await Qe(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o,d,ue,H,$,c,f,w,L,p);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await Re(f[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await Re(f[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await ue(this);return this.dappProvider=void 0,e}catch(e){let t=h(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=Ke(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof O&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof y&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=Xe(t);if(o||he(t),o&&this.initOptions?.chainType){await Ve(t,f[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await pe(i,this.networkProvider)}}catch(r){let o=h(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof O){let i=await this.dappProvider.signMessage(new w({data:R(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new w({data:R(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new w({data:R(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof y){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new w({data:R(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=h(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=h(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}};W.storage=d,W.destroy=()=>{W.networkProvider=void 0,W.dappProvider=void 0,W.initOptions=void 0,c.clear()};var Ie=W;var gt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},nt=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),nt({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{P as Account,lt as DappCoreWCV2CustomMethodsEnum,Ie as ElvenJS,A as EventStoreEvents,M as LoginMethodsEnum,L as Transaction,V as TransactionWatcher,Pe as WebWalletUrlParamsEnum,nt as formatAmount,gt as parseAmount}; /** keccak.js https://github.com/adraffy/keccak.js @license MIT */ /** https://github.com/emn178/js-sha3/blob/master/src/sha3.js @license MIT */ -/*! Bundled license information: - -tslib/tslib.es6.js: - (*! ***************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** *) - -js-sha3/src/sha3.js: - (** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.8.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2018 - * @license MIT - *) -*/ diff --git a/demo-app/index.html b/demo-app/index.html index 8acfbe2..0a116d3 100644 --- a/demo-app/index.html +++ b/demo-app/index.html @@ -173,6 +173,8 @@

Other demos:

parseAmount, } from './elven.js'; + import { MobileSigningProvider } from './mobile-signing-provider.js'; + // Options are the defaults and here only to show all of them // You don't have to add them if you want to use default setup // You can only add your custom callbacks @@ -182,9 +184,17 @@

Other demos:

apiUrl: 'https://devnet-api.multiversx.com', chainType: 'devnet', apiTimeout: 10000, - // Remember to change it. Get yours here: https://cloud.walletconnect.com/sign-in - walletConnectV2ProjectId: 'f502675c63610bfe4454080ac86d70e6', - walletConnectV2RelayAddresses: ['wss://relay.walletconnect.com'], + externalSigningProviders: { + mobile: { + provider: MobileSigningProvider, + config: { + // Remember to change it. Get yours here: https://cloud.walletconnect.com/sign-in + walletConnectV2ProjectId: 'f502675c63610bfe4454080ac86d70e6', + walletConnectV2RelayAddresses: ['wss://relay.walletconnect.com'], + qrCodeContainer: 'qr-code-container', + } + } + }, // All callbacks are optional // You could also rely on try catch to some extent, but callbacks in one place seems convenient // Login callbacks: @@ -240,11 +250,7 @@

Other demos:

document.getElementById('button-login-mobile').addEventListener('click', async () => { clearQrCodeContainer(); try { - await ElvenJS.login('mobile', { - // You can also use the DOM element here: - // qrCodeContainer: document.querySelector('#qr-code-container') - qrCodeContainer: 'qr-code-container', - }); + await ElvenJS.login('mobile'); } catch (e) { console.log('Login: Something went wrong, try again!', e?.message); } diff --git a/demo-app/mobile-signing-provider.js b/demo-app/mobile-signing-provider.js index 66228aa..1a6796a 100644 --- a/demo-app/mobile-signing-provider.js +++ b/demo-app/mobile-signing-provider.js @@ -6,4 +6,62 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var o=()=>(n=>1+n)(2),r=o;export{r as default}; +var W6=Object.create;var Ta=Object.defineProperty;var Y6=Object.getOwnPropertyDescriptor;var X6=Object.getOwnPropertyNames;var Z6=Object.getPrototypeOf,Q6=Object.prototype.hasOwnProperty;var C0=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Z=(r,e)=>()=>(r&&(e=r(r=0)),e);var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),vt=(r,e)=>{for(var t in e)Ta(r,t,{get:e[t],enumerable:!0})},Ra=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of X6(e))!Q6.call(r,n)&&n!==t&&Ta(r,n,{get:()=>e[n],enumerable:!(i=Y6(e,n))||i.enumerable});return r},Lt=(r,e,t)=>(Ra(r,e,"default"),t&&Ra(t,e,"default")),Ue=(r,e,t)=>(t=r!=null?W6(Z6(r)):{},Ra(e||!r||!r.__esModule?Ta(t,"default",{value:r,enumerable:!0}):t,r)),so=r=>Ra(Ta({},"__esModule",{value:!0}),r);var _n=W((kR,ou)=>{"use strict";var Zn=typeof Reflect=="object"?Reflect:null,P0=Zn&&typeof Zn.apply=="function"?Zn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Da;Zn&&typeof Zn.ownKeys=="function"?Da=Zn.ownKeys:Object.getOwnPropertySymbols?Da=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Da=function(e){return Object.getOwnPropertyNames(e)};function ew(r){console&&console.warn&&console.warn(r)}var L0=Number.isNaN||function(e){return e!==e};function Ve(){Ve.init.call(this)}ou.exports=Ve;ou.exports.once=nw;Ve.EventEmitter=Ve;Ve.prototype._events=void 0;Ve.prototype._eventsCount=0;Ve.prototype._maxListeners=void 0;var O0=10;function Na(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ve,"defaultMaxListeners",{enumerable:!0,get:function(){return O0},set:function(r){if(typeof r!="number"||r<0||L0(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");O0=r}});Ve.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ve.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||L0(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function q0(r){return r._maxListeners===void 0?Ve.defaultMaxListeners:r._maxListeners}Ve.prototype.getMaxListeners=function(){return q0(this)};Ve.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")P0(c,this,t);else for(var u=c.length,b=k0(c,u),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,ew(f)}return r}Ve.prototype.addListener=function(e,t){return F0(this,e,t,!1)};Ve.prototype.on=Ve.prototype.addListener;Ve.prototype.prependListener=function(e,t){return F0(this,e,t,!0)};function tw(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function U0(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=tw.bind(i);return n.listener=t,i.wrapFn=n,n}Ve.prototype.once=function(e,t){return Na(t),this.on(e,U0(this,e,t)),this};Ve.prototype.prependOnceListener=function(e,t){return Na(t),this.prependListener(e,U0(this,e,t)),this};Ve.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Na(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():rw(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ve.prototype.off=Ve.prototype.removeListener;Ve.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function B0(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?iw(n):k0(n,n.length)}Ve.prototype.listeners=function(e){return B0(this,e,!0)};Ve.prototype.rawListeners=function(e){return B0(this,e,!1)};Ve.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):z0.call(r,e)};Ve.prototype.listenerCount=z0;function z0(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ve.prototype.eventNames=function(){return this._eventsCount>0?Da(this._events):[]};function k0(r,e){for(var t=new Array(e),i=0;ifu,__asyncDelegator:()=>mw,__asyncGenerator:()=>vw,__asyncValues:()=>yw,__await:()=>oo,__awaiter:()=>hw,__classPrivateFieldGet:()=>Ew,__classPrivateFieldSet:()=>Sw,__createBinding:()=>lw,__decorate:()=>fw,__exportStar:()=>pw,__extends:()=>ow,__generator:()=>dw,__importDefault:()=>xw,__importStar:()=>_w,__makeTemplateObject:()=>ww,__metadata:()=>uw,__param:()=>cw,__read:()=>j0,__rest:()=>aw,__spread:()=>gw,__spreadArrays:()=>bw,__values:()=>cu});function ow(r,e){au(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function aw(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function cw(r,e){return function(t,i){e(t,i,r)}}function uw(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function hw(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{u(i.next(b))}catch(y){o(y)}}function c(b){try{u(i.throw(b))}catch(y){o(y)}}function u(b){b.done?s(b.value):n(b.value).then(f,c)}u((i=i.apply(r,e||[])).next())})}function dw(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(u){return function(b){return c([u,b])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function j0(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function gw(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{c(i[S](I))}catch(M){y(s[0][3],M)}}function c(S){S.value instanceof oo?Promise.resolve(S.value.v).then(u,b):y(s[0][2],S)}function u(S){f("next",S)}function b(S){f("throw",S)}function y(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function mw(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:oo(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function yw(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof cu=="function"?cu(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,c){o=r[s](o),n(f,c,o.done,o.value)})}}function n(s,o,f,c){Promise.resolve(c).then(function(u){s({value:u,done:f})},o)}}function ww(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function _w(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function xw(r){return r&&r.__esModule?r:{default:r}}function Ew(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Sw(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var au,fu,es=Z(()=>{au=function(r,e){return au=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},au(r,e)};fu=function(){return fu=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.delay=void 0;function Iw(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Ca.delay=Iw});var $0=W(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.ONE_THOUSAND=ts.ONE_HUNDRED=void 0;ts.ONE_HUNDRED=100;ts.ONE_THOUSAND=1e3});var H0=W(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.ONE_YEAR=ee.FOUR_WEEKS=ee.THREE_WEEKS=ee.TWO_WEEKS=ee.ONE_WEEK=ee.THIRTY_DAYS=ee.SEVEN_DAYS=ee.FIVE_DAYS=ee.THREE_DAYS=ee.ONE_DAY=ee.TWENTY_FOUR_HOURS=ee.TWELVE_HOURS=ee.SIX_HOURS=ee.THREE_HOURS=ee.ONE_HOUR=ee.SIXTY_MINUTES=ee.THIRTY_MINUTES=ee.TEN_MINUTES=ee.FIVE_MINUTES=ee.ONE_MINUTE=ee.SIXTY_SECONDS=ee.THIRTY_SECONDS=ee.TEN_SECONDS=ee.FIVE_SECONDS=ee.ONE_SECOND=void 0;ee.ONE_SECOND=1;ee.FIVE_SECONDS=5;ee.TEN_SECONDS=10;ee.THIRTY_SECONDS=30;ee.SIXTY_SECONDS=60;ee.ONE_MINUTE=ee.SIXTY_SECONDS;ee.FIVE_MINUTES=ee.ONE_MINUTE*5;ee.TEN_MINUTES=ee.ONE_MINUTE*10;ee.THIRTY_MINUTES=ee.ONE_MINUTE*30;ee.SIXTY_MINUTES=ee.ONE_MINUTE*60;ee.ONE_HOUR=ee.SIXTY_MINUTES;ee.THREE_HOURS=ee.ONE_HOUR*3;ee.SIX_HOURS=ee.ONE_HOUR*6;ee.TWELVE_HOURS=ee.ONE_HOUR*12;ee.TWENTY_FOUR_HOURS=ee.ONE_HOUR*24;ee.ONE_DAY=ee.TWENTY_FOUR_HOURS;ee.THREE_DAYS=ee.ONE_DAY*3;ee.FIVE_DAYS=ee.ONE_DAY*5;ee.SEVEN_DAYS=ee.ONE_DAY*7;ee.THIRTY_DAYS=ee.ONE_DAY*30;ee.ONE_WEEK=ee.SEVEN_DAYS;ee.TWO_WEEKS=ee.ONE_WEEK*2;ee.THREE_WEEKS=ee.ONE_WEEK*3;ee.FOUR_WEEKS=ee.ONE_WEEK*4;ee.ONE_YEAR=ee.ONE_DAY*365});var uu=W(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});var G0=(es(),so(Qn));G0.__exportStar($0(),Pa);G0.__exportStar(H0(),Pa)});var W0=W(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.fromMiliseconds=rs.toMiliseconds=void 0;var J0=uu();function Mw(r){return r*J0.ONE_THOUSAND}rs.toMiliseconds=Mw;function Aw(r){return Math.floor(r/J0.ONE_THOUSAND)}rs.fromMiliseconds=Aw});var X0=W(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var Y0=(es(),so(Qn));Y0.__exportStar(V0(),Oa);Y0.__exportStar(W0(),Oa)});var Z0=W(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.Watch=void 0;var La=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};ao.Watch=La;ao.default=La});var Q0=W(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.IWatch=void 0;var hu=class{};qa.IWatch=hu});var ep=W(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var Rw=(es(),so(Qn));Rw.__exportStar(Q0(),du)});var ns=W(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});var Fa=(es(),so(Qn));Fa.__exportStar(X0(),is);Fa.__exportStar(Z0(),is);Fa.__exportStar(ep(),is);Fa.__exportStar(uu(),is)});var hr,tp=Z(()=>{hr=class{}});var lu=Z(()=>{tp()});var ip,Ba,pu,rp,xn,Ua,np=Z(()=>{ip=Ue(_n()),Ba=Ue(ns());lu();pu=class extends hr{constructor(e){super()}},rp=Ba.FIVE_SECONDS,xn={pulse:"heartbeat_pulse"},Ua=class r extends pu{constructor(e){super(e),this.events=new ip.EventEmitter,this.interval=rp,this.interval=e?.interval||rp}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,Ba.toMiliseconds)(this.interval))}pulse(){this.events.emit(xn.pulse)}}});function Cw(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){Pw(r);return}return e}function Pw(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function fo(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!Nw.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(Tw.test(r)||Dw.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,Cw)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}var Tw,Dw,Nw,sp=Z(()=>{Tw=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Dw=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Nw=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/});function Ow(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ut(r,...e){try{return Ow(r(...e))}catch(t){return Promise.reject(t)}}function Lw(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function qw(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function co(r){if(Lw(r))return String(r);if(qw(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return co(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function op(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}function ap(r){if(typeof r=="string")return r;op();let e=Buffer.from(r).toString("base64");return gu+e}function fp(r){return typeof r!="string"||!r.startsWith(gu)?r:(op(),Buffer.from(r.slice(gu.length),"base64"))}function qt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function cp(...r){return qt(r.join(":"))}function uo(r){return r=qt(r),r?r+":":""}var gu,up=Z(()=>{gu="base64:"});function lp(r={}){let e={mounts:{"":r.driver||Uw()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=u=>{for(let b of e.mountpoints)if(u.startsWith(b))return{base:b,relativeKey:u.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,b)=>e.mountpoints.filter(y=>y.startsWith(u)||b&&u.startsWith(y)).map(y=>({relativeBase:u.length>y.length?u.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(u,b)=>{if(e.watching){b=qt(b);for(let y of e.watchListeners)y(u,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let u in e.mounts)e.unwatch[u]=await hp(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(let u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},f=(u,b,y)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of u){let T=typeof M=="string",O=qt(T?M:M.key),N=T?void 0:M.value,B=T||!M.options?b:{...b,...M.options},z=t(O);I(z).items.push({key:O,value:N,relativeKey:z.relativeKey,options:B})}return Promise.all([...S.values()].map(M=>y(M))).then(M=>M.flat())},c={hasItem(u,b={}){u=qt(u);let{relativeKey:y,driver:S}=t(u);return ut(S.hasItem,y,b)},getItem(u,b={}){u=qt(u);let{relativeKey:y,driver:S}=t(u);return ut(S.getItem,y,b).then(I=>fo(I))},getItems(u,b){return f(u,b,y=>y.driver.getItems?ut(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:cp(y.base,I.key),value:fo(I.value)}))):Promise.all(y.items.map(S=>ut(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:fo(I)})))))},getItemRaw(u,b={}){u=qt(u);let{relativeKey:y,driver:S}=t(u);return S.getItemRaw?ut(S.getItemRaw,y,b):ut(S.getItem,y,b).then(I=>fp(I))},async setItem(u,b,y={}){if(b===void 0)return c.removeItem(u);u=qt(u);let{relativeKey:S,driver:I}=t(u);I.setItem&&(await ut(I.setItem,S,co(b),y),I.watch||n("update",u))},async setItems(u,b){await f(u,b,async y=>{if(y.driver.setItems)return ut(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:co(S.value),options:S.options})),b);y.driver.setItem&&await Promise.all(y.items.map(S=>ut(y.driver.setItem,S.relativeKey,co(S.value),S.options)))})},async setItemRaw(u,b,y={}){if(b===void 0)return c.removeItem(u,y);u=qt(u);let{relativeKey:S,driver:I}=t(u);if(I.setItemRaw)await ut(I.setItemRaw,S,b,y);else if(I.setItem)await ut(I.setItem,S,ap(b),y);else return;I.watch||n("update",u)},async removeItem(u,b={}){typeof b=="boolean"&&(b={removeMeta:b}),u=qt(u);let{relativeKey:y,driver:S}=t(u);S.removeItem&&(await ut(S.removeItem,y,b),(b.removeMeta||b.removeMata)&&await ut(S.removeItem,y+"$",b),S.watch||n("remove",u))},async getMeta(u,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),u=qt(u);let{relativeKey:y,driver:S}=t(u),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ut(S.getMeta,y,b)),!b.nativeOnly){let M=await ut(S.getItem,y+"$",b).then(T=>fo(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(u,b,y={}){return this.setItem(u+"$",b,y)},removeMeta(u,b={}){return this.removeItem(u+"$",b)},async getKeys(u,b={}){u=uo(u);let y=i(u,!0),S=[],I=[];for(let M of y){let T=await ut(M.driver.getKeys,M.relativeBase,b);for(let O of T){let N=M.mountpoint+qt(O);S.some(B=>N.startsWith(B))||I.push(N)}S=[M.mountpoint,...S.filter(O=>!O.startsWith(M.mountpoint))]}return u?I.filter(M=>M.startsWith(u)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(u,b={}){u=uo(u),await Promise.all(i(u,!1).map(async y=>{if(y.driver.clear)return ut(y.driver.clear,y.relativeBase,b);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",b);return Promise.all(S.map(I=>y.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>dp(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,b){if(u=uo(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[u]=b,e.watching&&Promise.resolve(hp(b,n,u)).then(y=>{e.unwatch[u]=y}).catch(console.error),c},async unmount(u,b=!0){u=uo(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),b&&await dp(e.mounts[u]),e.mountpoints=e.mountpoints.filter(y=>y!==u),delete e.mounts[u])},getMount(u=""){u=qt(u)+":";let b=t(u);return{driver:b.driver,base:b.base}},getMounts(u="",b={}){return u=qt(u),i(u,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(u,b={})=>c.getKeys(u,b),get:(u,b={})=>c.getItem(u,b),set:(u,b,y={})=>c.setItem(u,b,y),has:(u,b={})=>c.hasItem(u,b),del:(u,b={})=>c.removeItem(u,b),remove:(u,b={})=>c.removeItem(u,b)};return c}function hp(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function dp(r){typeof r.dispose=="function"&&await ut(r.dispose)}var Fw,Uw,pp=Z(()=>{sp();up();Fw="memory",Uw=()=>{let r=new Map;return{name:Fw,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}}});function En(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function vu(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=En(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}function ho(){return bu||(bu=vu("keyval-store","keyval")),bu}function mu(r,e=ho()){return e("readonly",t=>En(t.get(r)))}function gp(r,e,t=ho()){return t("readwrite",i=>(i.put(e,r),En(i.transaction)))}function bp(r,e=ho()){return e("readwrite",t=>(t.delete(r),En(t.transaction)))}function vp(r=ho()){return r("readwrite",e=>(e.clear(),En(e.transaction)))}function Bw(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},En(r.transaction)}function mp(r=ho()){return r("readonly",e=>{if(e.getAllKeys)return En(e.getAllKeys());let t=[];return Bw(e,i=>t.push(i.key)).then(()=>t)})}var bu,yp=Z(()=>{});function jr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return kw(r)}catch{return r}}function Zt(r){return typeof r=="string"?r:zw(r)||""}var zw,kw,ss=Z(()=>{zw=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),kw=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)}});function Hw(r){var e;return[r[0],jr((e=r[1])!=null?e:"")]}var Kw,jw,Vw,$w,wu,yu,za,_u,Gw,wp,Jw,Ww,ka,_p=Z(()=>{pp();yp();ss();Kw="idb-keyval",jw=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=vu(r.dbName,r.storeName)),{name:Kw,options:r,async hasItem(n){return!(typeof await mu(t(n),i)>"u")},async getItem(n){return await mu(t(n),i)??null},setItem(n,s){return gp(t(n),s,i)},removeItem(n){return bp(t(n),i)},getKeys(){return mp(i)},clear(){return vp(i)}}},Vw="WALLET_CONNECT_V2_INDEXED_DB",$w="keyvaluestorage",wu=class{constructor(){this.indexedDb=lp({driver:jw({dbName:Vw,storeName:$w})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Zt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},yu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},za={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof yu<"u"&&yu.localStorage?za.exports=yu.localStorage:typeof window<"u"&&window.localStorage?za.exports=window.localStorage:za.exports=new e})();_u=class{constructor(){this.localStorage=za.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Hw)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return jr(t)}async setItem(e,t){this.localStorage.setItem(e,Zt(t))}async removeItem(e){this.localStorage.removeItem(e)}},Gw="wc_storage_version",wp=1,Jw=async(r,e,t)=>{let i=Gw,n=await e.getItem(i);if(n&&n>=wp){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let c=f.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){let u=await r.getItem(f);await e.setItem(f,u),o.push(f)}}await e.setItem(i,wp),t(e),Ww(r,o)},Ww=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},ka=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new _u;this.storage=e;try{let t=new wu;Jw(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}}});var Ep=W((pT,xp)=>{"use strict";function Yw(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}xp.exports=Xw;function Xw(r,e,t){var i=t&&t.stringify||Yw,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=c||e[b]==null)break;y=c||e[b]==null)break;y=c||e[b]===void 0)break;y",y=I+2,I++;break}u+=i(e[b]),y=I+2,I++;break;case 115:if(b>=c)break;y{"use strict";var Sp=Ep();Ap.exports=Vr;var lo=a5().console||{},Zw={mapHttpRequest:Ka,mapHttpResponse:Ka,wrapRequestSerializer:xu,wrapResponseSerializer:xu,wrapErrorSerializer:xu,req:Ka,res:Ka,err:i5};function Qw(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Vr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||lo;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=Qw(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",c=Object.create(t);c.log||(c.log=po),Object.defineProperty(c,"levelVal",{get:b}),Object.defineProperty(c,"level",{get:y,set:S});let u={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:n5(r)};c.levels=Vr.levels,c.level=f,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=po,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=I,e&&(c._logEvent=Eu());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,os(u,c,"error","log"),os(u,c,"fatal","error"),os(u,c,"warn","error"),os(u,c,"info","log"),os(u,c,"debug","log"),os(u,c,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let O=T.serializers;if(n&&O){var N=Object.assign({},i,O),B=r.browser.serialize===!0?Object.keys(N):n;delete M.serializers,ja([M],B,N,this._stdErrSerialize)}function z(F){this._childLevel=(F._childLevel|0)+1,this.error=as(F,M,"error"),this.fatal=as(F,M,"fatal"),this.warn=as(F,M,"warn"),this.info=as(F,M,"info"),this.debug=as(F,M,"debug"),this.trace=as(F,M,"trace"),N&&(this.serializers=N,this._serialize=B),e&&(this._logEvent=Eu([].concat(F._logEvent.bindings,M)))}return z.prototype=this,new z(this)}return c}Vr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Vr.stdSerializers=Zw;Vr.stdTimeFunctions=Object.assign({},{nullTime:Ip,epochTime:Mp,unixTime:s5,isoTime:o5});function os(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?po:n[t]?n[t]:lo[t]||lo[i]||po,e5(r,e,t)}function e5(r,e,t){!r.transmit&&e[t]===po||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===lo?lo:this;for(var c=0;c-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function as(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n"u"?t=p5(r,e):t=r.bindings().context||"",t}function b5(r,e,t=bo){let i=St(r,t);return i.trim()?`${i}/${e}`:e}function mt(r,e,t=bo){let i=b5(r,e,t),n=r.child({context:i});return g5(n,i,t)}function v5(r){var e,t;let i=new Mu((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,li.default)(Ga(Ha({},r.opts),{level:"trace",browser:Ga(Ha({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function m5(r){var e;let t=new Au((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,li.default)(Ga(Ha({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Dp(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?v5(r):m5(r)}var li,go,f5,bo,Ru,Iu,Va,$a,Mu,Au,c5,u5,h5,Rp,d5,l5,Tp,Ha,Ga,Tu=Z(()=>{li=Ue(Su()),go=Ue(Su());ss();f5={level:"info"},bo="custom_context",Ru=1e3*1024,Iu=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Va=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Iu(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},$a=class{constructor(e,t=Ru){this.level=e??"error",this.levelValue=li.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Va(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===li.levels.values.error?console.error(e):t===li.levels.values.warn?console.warn(e):t===li.levels.values.debug?console.debug(e):t===li.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Zt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Va(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Zt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Mu=class{constructor(e,t=Ru){this.baseChunkLogger=new $a(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Au=class{constructor(e,t=Ru){this.baseChunkLogger=new $a(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},c5=Object.defineProperty,u5=Object.defineProperties,h5=Object.getOwnPropertyDescriptors,Rp=Object.getOwnPropertySymbols,d5=Object.prototype.hasOwnProperty,l5=Object.prototype.propertyIsEnumerable,Tp=(r,e,t)=>e in r?c5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ha=(r,e)=>{for(var t in e||(e={}))d5.call(e,t)&&Tp(r,t,e[t]);if(Rp)for(var t of Rp(e))l5.call(e,t)&&Tp(r,t,e[t]);return r},Ga=(r,e)=>u5(r,h5(e))});var Np,Ja,Wa,Ya,Xa,Za,Qa,ef,tf,rf,nf,sf,of,af,Du=Z(()=>{lu();Np=Ue(_n()),Ja=class extends hr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},Wa=class extends hr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},Ya=class{constructor(e,t){this.logger=e,this.core=t}},Xa=class extends hr{constructor(e,t){super(),this.relayer=e,this.logger=t}},Za=class extends hr{constructor(e){super()}},Qa=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}},ef=class extends hr{constructor(e,t){super(),this.relayer=e,this.logger=t}},tf=class extends hr{constructor(e,t){super(),this.core=e,this.logger=t}},rf=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},nf=class{constructor(e,t){this.projectId=e,this.logger=t}},sf=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}},of=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},af=class{constructor(e){this.client=e}}});var Pp=W(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.BrowserRandomSource=void 0;var Cp=65536,Nu=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});function y5(r){for(var e=0;e{});var Op=W(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});cf.NodeRandomSource=void 0;var w5=Qt(),Ou=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof C0<"u"){let e=Pu();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});uf.SystemRandomSource=void 0;var _5=Pp(),x5=Op(),Lu=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new _5.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new x5.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};uf.SystemRandomSource=Lu});var qp=W(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});function E5(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}kt.mul=Math.imul||E5;function S5(r,e){return r+e|0}kt.add=S5;function I5(r,e){return r-e|0}kt.sub=I5;function M5(r,e){return r<>>32-e}kt.rotl=M5;function A5(r,e){return r<<32-e|r>>>e}kt.rotr=A5;function R5(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}kt.isInteger=Number.isInteger||R5;kt.MAX_SAFE_INTEGER=9007199254740991;kt.isSafeInteger=function(r){return kt.isInteger(r)&&r>=-kt.MAX_SAFE_INTEGER&&r<=kt.MAX_SAFE_INTEGER}});var fs=W(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});var Fp=qp();function T5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}qe.readInt16BE=T5;function D5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}qe.readUint16BE=D5;function N5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}qe.readInt16LE=N5;function C5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}qe.readUint16LE=C5;function Up(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}qe.writeUint16BE=Up;qe.writeInt16BE=Up;function Bp(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}qe.writeUint16LE=Bp;qe.writeInt16LE=Bp;function qu(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}qe.readInt32BE=qu;function Fu(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}qe.readUint32BE=Fu;function Uu(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}qe.readInt32LE=Uu;function Bu(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}qe.readUint32LE=Bu;function hf(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}qe.writeUint32BE=hf;qe.writeInt32BE=hf;function df(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}qe.writeUint32LE=df;qe.writeInt32LE=df;function P5(r,e){e===void 0&&(e=0);var t=qu(r,e),i=qu(r,e+4);return t*4294967296+i-(i>>31)*4294967296}qe.readInt64BE=P5;function O5(r,e){e===void 0&&(e=0);var t=Fu(r,e),i=Fu(r,e+4);return t*4294967296+i}qe.readUint64BE=O5;function L5(r,e){e===void 0&&(e=0);var t=Uu(r,e),i=Uu(r,e+4);return i*4294967296+t-(t>>31)*4294967296}qe.readInt64LE=L5;function q5(r,e){e===void 0&&(e=0);var t=Bu(r,e),i=Bu(r,e+4);return i*4294967296+t}qe.readUint64LE=q5;function zp(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),hf(r/4294967296>>>0,e,t),hf(r>>>0,e,t+4),e}qe.writeUint64BE=zp;qe.writeInt64BE=zp;function kp(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),df(r>>>0,e,t),df(r/4294967296>>>0,e,t+4),e}qe.writeUint64LE=kp;qe.writeInt64LE=kp;function F5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}qe.readUintBE=F5;function U5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}qe.writeUintBE=B5;function z5(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Fp.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.randomStringForEntropy=It.randomString=It.randomUint32=It.randomBytes=It.defaultRandomSource=void 0;var W5=Lp(),Y5=fs(),Kp=Qt();It.defaultRandomSource=new W5.SystemRandomSource;function zu(r,e=It.defaultRandomSource){return e.randomBytes(r)}It.randomBytes=zu;function X5(r=It.defaultRandomSource){let e=zu(4,r),t=(0,Y5.readUint32LE)(e);return(0,Kp.wipe)(e),t}It.randomUint32=X5;var jp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Vp(r,e=jp,t=It.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=zu(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let c=o[f];c{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var us=fs(),cs=Qt();pi.DIGEST_LENGTH=64;pi.BLOCK_SIZE=128;var Hp=function(){function r(){this.digestLength=pi.DIGEST_LENGTH,this.blockSize=pi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){cs.wipe(this._buffer),cs.wipe(this._tempHi),cs.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ku(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ku(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){cs.wipe(e.stateHi),cs.wipe(e.stateLo),e.buffer&&cs.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();pi.SHA512=Hp;var $p=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function ku(r,e,t,i,n,s,o){for(var f=t[0],c=t[1],u=t[2],b=t[3],y=t[4],S=t[5],I=t[6],M=t[7],T=i[0],O=i[1],N=i[2],B=i[3],z=i[4],F=i[5],k=i[6],V=i[7],L,P,J,D,l,w,p,a;o>=128;){for(var d=0;d<16;d++){var v=8*d+s;r[d]=us.readUint32BE(n,v),e[d]=us.readUint32BE(n,v+4)}for(var d=0;d<80;d++){var _=f,m=c,h=u,x=b,A=y,g=S,R=I,K=M,E=T,C=O,q=N,U=B,j=z,Y=F,H=k,$=V;if(L=M,P=V,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=(y>>>14|z<<18)^(y>>>18|z<<14)^(z>>>9|y<<23),P=(z>>>14|y<<18)^(z>>>18|y<<14)^(y>>>9|z<<23),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=y&S^~y&I,P=z&F^~z&k,l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=$p[d*2],P=$p[d*2+1],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=r[d%16],P=e[d%16],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,J=p&65535|a<<16,D=l&65535|w<<16,L=J,P=D,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),P=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=f&c^f&u^c&u,P=T&O^T&N^O&N,l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,K=p&65535|a<<16,$=l&65535|w<<16,L=x,P=U,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=J,P=D,l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,U=l&65535|w<<16,c=_,u=m,b=h,y=x,S=A,I=g,M=R,f=K,O=E,N=C,B=q,z=U,F=j,k=Y,V=H,T=$,d%16===15)for(var v=0;v<16;v++)L=r[v],P=e[v],l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=r[(v+9)%16],P=e[(v+9)%16],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,J=r[(v+1)%16],D=e[(v+1)%16],L=(J>>>1|D<<31)^(J>>>8|D<<24)^J>>>7,P=(D>>>1|J<<31)^(D>>>8|J<<24)^(D>>>7|J<<25),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,J=r[(v+14)%16],D=e[(v+14)%16],L=(J>>>19|D<<13)^(D>>>29|J<<3)^J>>>6,P=(D>>>19|J<<13)^(J>>>29|D<<3)^(D>>>6|J<<26),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[v]=p&65535|a<<16,e[v]=l&65535|w<<16}L=f,P=T,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[0],P=i[0],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=c,P=O,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[1],P=i[1],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=c=p&65535|a<<16,i[1]=O=l&65535|w<<16,L=u,P=N,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[2],P=i[2],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=u=p&65535|a<<16,i[2]=N=l&65535|w<<16,L=b,P=B,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[3],P=i[3],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=B=l&65535|w<<16,L=y,P=z,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[4],P=i[4],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=y=p&65535|a<<16,i[4]=z=l&65535|w<<16,L=S,P=F,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[5],P=i[5],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=F=l&65535|w<<16,L=I,P=k,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[6],P=i[6],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=k=l&65535|w<<16,L=M,P=V,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[7],P=i[7],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=V=l&65535|w<<16,s+=128,o-=128}return s}function Q5(r){var e=new Hp;e.update(r);var t=e.digest();return e.clean(),t}pi.hash=Q5});var a1=W(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var e4=mo(),yo=Gp(),Zp=Qt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function re(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,Qp(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function e1(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function Yp(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return wo(t,r),wo(i,e),e1(t,i)}function t1(r){let e=new Uint8Array(32);return wo(e,r),e[0]&1}function s4(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Sn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function Mn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function $e(r,e,t){let i,n,s=0,o=0,f=0,c=0,u=0,b=0,y=0,S=0,I=0,M=0,T=0,O=0,N=0,B=0,z=0,F=0,k=0,V=0,L=0,P=0,J=0,D=0,l=0,w=0,p=0,a=0,d=0,v=0,_=0,m=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],K=t[4],E=t[5],C=t[6],q=t[7],U=t[8],j=t[9],Y=t[10],H=t[11],$=t[12],te=t[13],G=t[14],X=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,c+=i*R,u+=i*K,b+=i*E,y+=i*C,S+=i*q,I+=i*U,M+=i*j,T+=i*Y,O+=i*H,N+=i*$,B+=i*te,z+=i*G,F+=i*X,i=e[1],o+=i*x,f+=i*A,c+=i*g,u+=i*R,b+=i*K,y+=i*E,S+=i*C,I+=i*q,M+=i*U,T+=i*j,O+=i*Y,N+=i*H,B+=i*$,z+=i*te,F+=i*G,k+=i*X,i=e[2],f+=i*x,c+=i*A,u+=i*g,b+=i*R,y+=i*K,S+=i*E,I+=i*C,M+=i*q,T+=i*U,O+=i*j,N+=i*Y,B+=i*H,z+=i*$,F+=i*te,k+=i*G,V+=i*X,i=e[3],c+=i*x,u+=i*A,b+=i*g,y+=i*R,S+=i*K,I+=i*E,M+=i*C,T+=i*q,O+=i*U,N+=i*j,B+=i*Y,z+=i*H,F+=i*$,k+=i*te,V+=i*G,L+=i*X,i=e[4],u+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*K,M+=i*E,T+=i*C,O+=i*q,N+=i*U,B+=i*j,z+=i*Y,F+=i*H,k+=i*$,V+=i*te,L+=i*G,P+=i*X,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*K,T+=i*E,O+=i*C,N+=i*q,B+=i*U,z+=i*j,F+=i*Y,k+=i*H,V+=i*$,L+=i*te,P+=i*G,J+=i*X,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*K,O+=i*E,N+=i*C,B+=i*q,z+=i*U,F+=i*j,k+=i*Y,V+=i*H,L+=i*$,P+=i*te,J+=i*G,D+=i*X,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*K,N+=i*E,B+=i*C,z+=i*q,F+=i*U,k+=i*j,V+=i*Y,L+=i*H,P+=i*$,J+=i*te,D+=i*G,l+=i*X,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,N+=i*K,B+=i*E,z+=i*C,F+=i*q,k+=i*U,V+=i*j,L+=i*Y,P+=i*H,J+=i*$,D+=i*te,l+=i*G,w+=i*X,i=e[9],M+=i*x,T+=i*A,O+=i*g,N+=i*R,B+=i*K,z+=i*E,F+=i*C,k+=i*q,V+=i*U,L+=i*j,P+=i*Y,J+=i*H,D+=i*$,l+=i*te,w+=i*G,p+=i*X,i=e[10],T+=i*x,O+=i*A,N+=i*g,B+=i*R,z+=i*K,F+=i*E,k+=i*C,V+=i*q,L+=i*U,P+=i*j,J+=i*Y,D+=i*H,l+=i*$,w+=i*te,p+=i*G,a+=i*X,i=e[11],O+=i*x,N+=i*A,B+=i*g,z+=i*R,F+=i*K,k+=i*E,V+=i*C,L+=i*q,P+=i*U,J+=i*j,D+=i*Y,l+=i*H,w+=i*$,p+=i*te,a+=i*G,d+=i*X,i=e[12],N+=i*x,B+=i*A,z+=i*g,F+=i*R,k+=i*K,V+=i*E,L+=i*C,P+=i*q,J+=i*U,D+=i*j,l+=i*Y,w+=i*H,p+=i*$,a+=i*te,d+=i*G,v+=i*X,i=e[13],B+=i*x,z+=i*A,F+=i*g,k+=i*R,V+=i*K,L+=i*E,P+=i*C,J+=i*q,D+=i*U,l+=i*j,w+=i*Y,p+=i*H,a+=i*$,d+=i*te,v+=i*G,_+=i*X,i=e[14],z+=i*x,F+=i*A,k+=i*g,V+=i*R,L+=i*K,P+=i*E,J+=i*C,D+=i*q,l+=i*U,w+=i*j,p+=i*Y,a+=i*H,d+=i*$,v+=i*te,_+=i*G,m+=i*X,i=e[15],F+=i*x,k+=i*A,V+=i*g,L+=i*R,P+=i*K,J+=i*E,D+=i*C,l+=i*q,w+=i*U,p+=i*j,a+=i*Y,d+=i*H,v+=i*$,_+=i*te,m+=i*G,h+=i*X,s+=38*k,o+=38*V,f+=38*L,c+=38*P,u+=38*J,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*v,N+=38*_,B+=38*m,z+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=c,r[4]=u,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=N,r[13]=B,r[14]=z,r[15]=F}function In(r,e){$e(r,e,e)}function r1(r,e){let t=re(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)In(t,t),i!==2&&i!==4&&$e(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function o4(r,e){let t=re(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)In(t,t),i!==1&&$e(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function $u(r,e){let t=re(),i=re(),n=re(),s=re(),o=re(),f=re(),c=re(),u=re(),b=re();Mn(t,r[1],r[0]),Mn(b,e[1],e[0]),$e(t,t,b),Sn(i,r[0],r[1]),Sn(b,e[0],e[1]),$e(i,i,b),$e(n,r[3],e[3]),$e(n,n,i4),$e(s,r[2],e[2]),Sn(s,s,s),Mn(o,i,t),Mn(f,s,n),Sn(c,s,n),Sn(u,i,t),$e(r[0],o,f),$e(r[1],u,c),$e(r[2],c,f),$e(r[3],o,u)}function Xp(r,e,t){for(let i=0;i<4;i++)Qp(r[i],e[i],t)}function Gu(r,e){let t=re(),i=re(),n=re();r1(n,e[2]),$e(t,e[0],n),$e(i,e[1],n),wo(r,i),r[31]^=t1(t)<<7}function i1(r,e,t){Ci(r[0],Vu),Ci(r[1],hs),Ci(r[2],hs),Ci(r[3],Vu);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;Xp(r,e,n),$u(e,r),$u(r,r),Xp(r,e,n)}}function Ju(r,e){let t=[re(),re(),re(),re()];Ci(t[0],Jp),Ci(t[1],Wp),Ci(t[2],hs),$e(t[3],Jp,Wp),i1(r,t,e)}function n1(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,yo.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[re(),re(),re(),re()];Ju(i,e),Gu(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=n1;function a4(r){let e=(0,e4.randomBytes)(32,r),t=n1(e);return(0,Zp.wipe)(e),t}ze.generateKeyPair=a4;function f4(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=f4;var ju=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function s1(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*ju[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*ju[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Hu(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;s1(r,e)}function c4(r,e){let t=new Float64Array(64),i=[re(),re(),re(),re()],n=(0,yo.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new yo.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Hu(f),Ju(i,f),Gu(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let c=o.digest();Hu(c);for(let u=0;u<32;u++)t[u]=f[u];for(let u=0;u<32;u++)for(let b=0;b<32;b++)t[u+b]+=c[u]*n[b];return s1(s.subarray(32),t),s}ze.sign=c4;function o1(r,e){let t=re(),i=re(),n=re(),s=re(),o=re(),f=re(),c=re();return Ci(r[2],hs),s4(r[1],e),In(n,r[1]),$e(s,n,r4),Mn(n,n,r[2]),Sn(s,r[2],s),In(o,s),In(f,o),$e(c,f,o),$e(t,c,n),$e(t,t,s),o4(t,t),$e(t,t,n),$e(t,t,s),$e(t,t,s),$e(r[0],t,s),In(i,r[0]),$e(i,i,s),Yp(i,n)&&$e(r[0],r[0],n4),In(i,r[0]),$e(i,i,s),Yp(i,n)?-1:(t1(r[0])===e[31]>>7&&Mn(r[0],Vu,r[0]),$e(r[3],r[0],r[1]),0)}function u4(r,e,t){let i=new Uint8Array(32),n=[re(),re(),re(),re()],s=[re(),re(),re(),re()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(o1(s,r))return!1;let o=new yo.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Hu(f),i1(n,s,f),Ju(s,t.subarray(32)),$u(n,s),Gu(i,n),!e1(t,i)}ze.verify=u4;function h4(r){let e=[re(),re(),re(),re()];if(o1(e,r))throw new Error("Ed25519: invalid public key");let t=re(),i=re(),n=e[1];Sn(t,hs,n),Mn(i,hs,n),r1(i,i),$e(t,t,i);let s=new Uint8Array(32);return wo(s,t),s}ze.convertPublicKeyToX25519=h4;function d4(r){let e=(0,yo.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,Zp.wipe)(e),t}ze.convertSecretKeyToX25519=d4});var f1,c1,_o,xo,Wu,Yu,u1,h1,d1,Xu,l1,p1,lf=Z(()=>{f1="EdDSA",c1="JWT",_o=".",xo="base64url",Wu="utf8",Yu="utf8",u1=":",h1="did",d1="key",Xu="base58btc",l1="z",p1="K36"});function Eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var pf=Z(()=>{});function An(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=Eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var Zu=Z(()=>{pf()});function l4(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,F=new Uint8Array(z);N!==B;){for(var k=M[N],V=0,L=z-1;(k!==0||V>>0,F[L]=k%f>>>0,k=k/f>>>0;if(k!==0)throw new Error("Non-zero carry");O=V,N++}for(var P=z-O;P!==z&&F[P]===0;)P++;for(var J=c.repeat(T);P>>0,z=new Uint8Array(B);M[T];){var F=t[M.charCodeAt(T)];if(F===255)return;for(var k=0,V=B-1;(F!==0||k>>0,z[V]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");N=k,T++}if(M[T]!==" "){for(var L=B-N;L!==B&&z[L]===0;)L++;for(var P=new Uint8Array(O+(B-L)),J=O;L!==B;)P[J++]=z[L++];return P}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var p4,g4,g1,b1=Z(()=>{p4=l4,g4=p4,g1=g4});var FT,v1,gi,m1,y1,Pi=Z(()=>{FT=new Uint8Array(0),v1=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},m1=r=>new TextEncoder().encode(r),y1=r=>new TextDecoder().decode(r)});var Qu,eh,th,_1,rh,ds,Oi,b4,v4,et,dr=Z(()=>{b1();Pi();Qu=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},eh=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return _1(this,e)}},th=class{constructor(e){this.decoders=e}or(e){return _1(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},_1=(r,e)=>new th({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),rh=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Qu(e,t,i),this.decoder=new eh(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ds=({name:r,prefix:e,encode:t,decode:i})=>new rh(r,e,t,i),Oi=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=g1(t,e);return ds({prefix:r,name:e,encode:i,decode:s=>gi(n(s))})},b4=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[u++]=255&c>>f)}if(f>=t||255&c<<8-f)throw new SyntaxError("Unexpected end of data");return o},v4=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<ds({prefix:e,name:r,encode(n){return v4(n,i,t)},decode(n){return b4(n,i,t,r)}})});var ih={};vt(ih,{identity:()=>m4});var m4,x1=Z(()=>{dr();Pi();m4=ds({prefix:"\0",name:"identity",encode:r=>y1(r),decode:r=>m1(r)})});var nh={};vt(nh,{base2:()=>y4});var y4,E1=Z(()=>{dr();y4=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})});var sh={};vt(sh,{base8:()=>w4});var w4,S1=Z(()=>{dr();w4=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})});var oh={};vt(oh,{base10:()=>_4});var _4,I1=Z(()=>{dr();_4=Oi({prefix:"9",name:"base10",alphabet:"0123456789"})});var ah={};vt(ah,{base16:()=>x4,base16upper:()=>E4});var x4,E4,M1=Z(()=>{dr();x4=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),E4=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});var fh={};vt(fh,{base32:()=>ls,base32hex:()=>A4,base32hexpad:()=>T4,base32hexpadupper:()=>D4,base32hexupper:()=>R4,base32pad:()=>I4,base32padupper:()=>M4,base32upper:()=>S4,base32z:()=>N4});var ls,S4,I4,M4,A4,R4,T4,D4,N4,ch=Z(()=>{dr();ls=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),S4=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),I4=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),M4=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),A4=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),R4=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),T4=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),D4=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),N4=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})});var uh={};vt(uh,{base36:()=>C4,base36upper:()=>P4});var C4,P4,A1=Z(()=>{dr();C4=Oi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),P4=Oi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})});var hh={};vt(hh,{base58btc:()=>$r,base58flickr:()=>O4});var $r,O4,dh=Z(()=>{dr();$r=Oi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),O4=Oi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});var lh={};vt(lh,{base64:()=>L4,base64pad:()=>q4,base64url:()=>F4,base64urlpad:()=>U4});var L4,q4,F4,U4,R1=Z(()=>{dr();L4=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),q4=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),F4=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),U4=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});var ph={};vt(ph,{base256emoji:()=>j4});function k4(r){return r.reduce((e,t)=>(e+=B4[t],e),"")}function K4(r){let e=[];for(let t of r){let i=z4[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var T1,B4,z4,j4,D1=Z(()=>{dr();T1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),B4=T1.reduce((r,e,t)=>(r[t]=e,r),[]),z4=T1.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);j4=ds({prefix:"\u{1F680}",name:"base256emoji",encode:k4,decode:K4})});function P1(r,e,t){e=e||[],t=t||0;for(var i=t;r>=G4;)e[t++]=r&255|N1,r/=128;for(;r&H4;)e[t++]=r&255|N1,r>>>=7;return e[t]=r|0,P1.bytes=t-i+1,e}function gh(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw gh.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&C1)<=W4);return gh.bytes=s-i,t}var V4,N1,$4,H4,G4,J4,W4,C1,Y4,X4,Z4,Q4,e8,t8,r8,i8,n8,s8,o8,a8,So,O1=Z(()=>{V4=P1,N1=128,$4=127,H4=~$4,G4=Math.pow(2,31);J4=gh,W4=128,C1=127;Y4=Math.pow(2,7),X4=Math.pow(2,14),Z4=Math.pow(2,21),Q4=Math.pow(2,28),e8=Math.pow(2,35),t8=Math.pow(2,42),r8=Math.pow(2,49),i8=Math.pow(2,56),n8=Math.pow(2,63),s8=function(r){return r{O1();Io=(r,e=0)=>[So.decode(r,e),So.decode.bytes],ps=(r,e,t=0)=>(So.encode(r,e,t),e),gs=r=>So.encodingLength(r)});var Rn,L1,q1,bs,Ao=Z(()=>{Pi();bf();Rn=(r,e)=>{let t=e.byteLength,i=gs(r),n=i+gs(t),s=new Uint8Array(n+t);return ps(r,s,0),ps(t,s,i),s.set(e,n),new bs(r,t,e,s)},L1=r=>{let e=gi(r),[t,i]=Io(e),[n,s]=Io(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new bs(t,n,o,e)},q1=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&v1(r.bytes,e.bytes),bs=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}});var vh,bh,mh=Z(()=>{Ao();vh=({name:r,code:e,encode:t})=>new bh(r,e,t),bh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Rn(this.code,t):t.then(i=>Rn(this.code,i))}else throw Error("Unknown type, must be binary type")}}});var yh={};vt(yh,{sha256:()=>f8,sha512:()=>c8});var U1,f8,c8,B1=Z(()=>{mh();U1=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),f8=vh({name:"sha2-256",code:18,encode:U1("SHA-256")}),c8=vh({name:"sha2-512",code:19,encode:U1("SHA-512")})});var wh={};vt(wh,{identity:()=>d8});var z1,u8,k1,h8,d8,K1=Z(()=>{Pi();Ao();z1=0,u8="identity",k1=gi,h8=r=>Rn(z1,k1(r)),d8={code:z1,name:u8,encode:k1,digest:h8}});var j1=Z(()=>{Pi()});var nD,sD,V1=Z(()=>{nD=new TextEncoder,sD=new TextDecoder});var yf,g8,b8,v8,Ro,m8,$1,H1,vf,mf,y8,w8,_8,G1=Z(()=>{bf();Ao();dh();ch();Pi();yf=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:mf,byteLength:mf,code:vf,version:vf,multihash:vf,bytes:vf,_baseCache:mf,asCID:mf})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==Ro)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==m8)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=Rn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&q1(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return b8(t,n,e||$r.encoder);default:return v8(t,n,e||ls.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return w8(/^0\.0/,_8),!!(e&&(e[H1]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||$1(t,i,n.bytes))}else if(e!=null&&e[H1]===!0){let{version:t,multihash:i,code:n}=e,s=L1(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==Ro)throw new Error(`Version 0 CID must use dag-pb (code: ${Ro}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=$1(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Ro,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=gi(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new bs(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=Io(e.subarray(t));return t+=S,y},n=i(),s=Ro;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),c=i(),u=t+c,b=u-o;return{version:n,codec:s,multihashCode:f,digestSize:c,multihashSize:b,size:u}}static parse(e,t){let[i,n]=g8(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},g8=(r,e)=>{switch(r[0]){case"Q":{let t=e||$r;return[$r.prefix,t.decode(`${$r.prefix}${r}`)]}case $r.prefix:{let t=e||$r;return[$r.prefix,t.decode(r)]}case ls.prefix:{let t=e||ls;return[ls.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},b8=(r,e,t)=>{let{prefix:i}=t;if(i!==$r.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},v8=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},Ro=112,m8=18,$1=(r,e,t)=>{let i=gs(r),n=i+gs(e),s=new Uint8Array(n+t.byteLength);return ps(r,s,0),ps(e,s,i),s.set(t,n),s},H1=Symbol.for("@ipld/js-cid/CID"),vf={writable:!1,configurable:!1,enumerable:!0},mf={writable:!1,enumerable:!1,configurable:!1},y8="0.0.0-dev",w8=(r,e)=>{if(r.test(y8))console.warn(e);else throw new Error(e)},_8=`CID.isCID(v) is deprecated and will be removed in the next major release. +Following code pattern: + +if (CID.isCID(value)) { + doSomethingWithCID(value) +} + +Is replaced with: + +const cid = CID.asCID(value) +if (cid) { + // Make sure to use cid instead of value + doSomethingWithCID(cid) +} +`});var J1=Z(()=>{G1();bf();Pi();mh();Ao()});var _h,lD,W1=Z(()=>{x1();E1();S1();I1();M1();ch();A1();dh();R1();D1();B1();K1();j1();V1();J1();_h={...ih,...nh,...sh,...oh,...ah,...fh,...uh,...hh,...lh,...ph},lD={...yh,...wh}});function X1(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var Y1,xh,x8,wf,Eh=Z(()=>{W1();pf();Y1=X1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),xh=X1("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Eo(r.length);for(let t=0;t{Eh()});function st(r,e="utf8"){let t=wf[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}var Ih=Z(()=>{Eh()});function Z1(r){return jr(tt(st(r,xo),Wu))}function _f(r){return tt(st(Zt(r),Wu),xo)}function xf(r){let e=st(p1,Xu),t=l1+tt(An([e,r]),Xu);return[h1,d1,t].join(u1)}function E8(r){return tt(r,xo)}function S8(r){return st(r,xo)}function Q1(r){return st([_f(r.header),_f(r.payload)].join(_o),Yu)}function eg(r){return[_f(r.header),_f(r.payload),E8(r.signature)].join(_o)}function vs(r){let e=r.split(_o),t=Z1(e[0]),i=Z1(e[1]),n=S8(e[2]),s=st(e.slice(0,2).join(_o),Yu);return{header:t,payload:i,signature:n,data:s}}var Mh=Z(()=>{Zu();Sh();Ih();ss();lf()});function Ah(r=(0,tg.randomBytes)(32)){return To.generateKeyPairFromSeed(r)}async function ig(r,e,t,i,n=(0,rg.fromMiliseconds)(Date.now())){let s={alg:f1,typ:c1},o=xf(i.publicKey),f=n+t,c={iss:o,sub:r,aud:e,iat:n,exp:f},u=Q1({header:s,payload:c}),b=To.sign(i.secretKey,u);return eg({header:s,payload:c,signature:b})}var To,tg,rg,ng=Z(()=>{To=Ue(a1()),tg=Ue(mo()),rg=Ue(ns());lf();Mh()});var sg=Z(()=>{});var Ef=Z(()=>{ng();lf();sg();Mh()});function ug(r){return r?cg(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new N8:typeof navigator<"u"?cg(navigator.userAgent):F8()}function L8(r){return r!==""&&O8.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function cg(r){var e=L8(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new D8;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{og=function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,s;i{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.getLocalStorage=Je.getLocalStorageOrThrow=Je.getCrypto=Je.getCryptoOrThrow=Je.getLocation=Je.getLocationOrThrow=Je.getNavigator=Je.getNavigatorOrThrow=Je.getDocument=Je.getDocumentOrThrow=Je.getFromWindowOrThrow=Je.getFromWindow=void 0;function Tn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Je.getFromWindow=Tn;function ms(r){let e=Tn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Je.getFromWindowOrThrow=ms;function B8(){return ms("document")}Je.getDocumentOrThrow=B8;function z8(){return Tn("document")}Je.getDocument=z8;function k8(){return ms("navigator")}Je.getNavigatorOrThrow=k8;function K8(){return Tn("navigator")}Je.getNavigator=K8;function j8(){return ms("location")}Je.getLocationOrThrow=j8;function V8(){return Tn("location")}Je.getLocation=V8;function $8(){return ms("crypto")}Je.getCryptoOrThrow=$8;function H8(){return Tn("crypto")}Je.getCrypto=H8;function G8(){return ms("localStorage")}Je.getLocalStorageOrThrow=G8;function J8(){return Tn("localStorage")}Je.getLocalStorage=J8});var lg=W(If=>{"use strict";Object.defineProperty(If,"__esModule",{value:!0});If.getWindowMetadata=void 0;var dg=Sf();function W8(){let r,e;try{r=dg.getDocumentOrThrow(),e=dg.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=M.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let N=e.protocol+"//"+e.host;if(O.indexOf("/")===0)N+=O;else{let B=e.pathname.split("/");B.pop();let z=B.join("/");N+=z+"/"+O}S.push(N)}else if(O.indexOf("//")===0){let N=e.protocol+O;S.push(N)}else S.push(O)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(O)).filter(O=>O?y.includes(O):!1);if(T.length&&T){let O=M.getAttribute("content");if(O)return O}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),c=e.origin,u=t();return{description:f,url:c,icons:u,name:o}}If.getWindowMetadata=W8});var gg=W((zD,pg)=>{"use strict";pg.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var wg=W((kD,yg)=>{"use strict";var mg="%[a-f0-9]{2}",bg=new RegExp("("+mg+")|([^%]+?)","gi"),vg=new RegExp("("+mg+")+","gi");function Rh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],Rh(t),Rh(i))}function Y8(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(bg)||[],t=1;t{"use strict";_g.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Sg=W((jD,Eg)=>{"use strict";Eg.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Z8=gg(),Q8=wg(),Mg=xg(),e_=Sg(),t_=r=>r==null,Th=Symbol("encodeFragmentIdentifier");function r_(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ot(e,r),"[",n,"]"].join("")]:[...t,[ot(e,r),"[",ot(n,r),"]=",ot(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ot(e,r),"[]"].join("")]:[...t,[ot(e,r),"[]=",ot(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ot(e,r),":list="].join("")]:[...t,[ot(e,r),":list=",ot(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[ot(t,r),e,ot(n,r)].join("")]:[[i,ot(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,ot(e,r)]:[...t,[ot(e,r),"=",ot(i,r)].join("")]}}function i_(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&bi(i,r).includes(r.arrayFormatSeparator);i=o?bi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(c=>bi(c,r)):i===null?i:bi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&bi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>bi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Ag(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function ot(r,e){return e.encode?e.strict?Z8(r):encodeURIComponent(r):r}function bi(r,e){return e.decode?Q8(r):r}function Rg(r){return Array.isArray(r)?r.sort():typeof r=="object"?Rg(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Tg(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function n_(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Dg(r){r=Tg(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ig(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Ng(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Ag(e.arrayFormatSeparator);let t=i_(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Mg(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:bi(o,e),t(bi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ig(s[o],e);else i[n]=Ig(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Rg(o):n[s]=o,n},Object.create(null))}Ft.extract=Dg;Ft.parse=Ng;Ft.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Ag(e.arrayFormatSeparator);let t=o=>e.skipNull&&t_(r[o])||e.skipEmptyString&&r[o]==="",i=r_(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?ot(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?ot(o,e)+"[]":f.reduce(i(o),[]).join("&"):ot(o,e)+"="+ot(f,e)}).filter(o=>o.length>0).join("&")};Ft.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Mg(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Ng(Dg(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:bi(i,e)}:{})};Ft.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Th]:!0},e);let t=Tg(r.url).split("?")[0]||"",i=Ft.extract(r.url),n=Ft.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ft.stringify(s,e);o&&(o=`?${o}`);let f=n_(r.url);return r.fragmentIdentifier&&(f=`#${e[Th]?ot(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ft.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Th]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ft.parseUrl(r,t);return Ft.stringifyUrl({url:i,query:e_(n,e),fragmentIdentifier:s},t)};Ft.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ft.pick(r,i,t)}});var Pg=W(($D,Mf)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=global:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof Mf=="object"&&Mf.exports,f=typeof define=="function"&&define.amd,c=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],N=[128,256],B=["hex","buffer","arrayBuffer","array","digest"],z={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),c&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var F=function(E,C,q){return function(U){return new g(E,C,E).update(U)[q]()}},k=function(E,C,q){return function(U,j){return new g(E,C,j).update(U)[q]()}},V=function(E,C,q){return function(U,j,Y,H){return a["cshake"+E].update(U,j,Y,H)[q]()}},L=function(E,C,q){return function(U,j,Y,H){return a["kmac"+E].update(U,j,Y,H)[q]()}},P=function(E,C,q,U){for(var j=0;j>5,this.byteCount=this.blockCount<<2,this.outputBlocks=q>>5,this.extraBytes=(q&31)>>3;for(var U=0;U<50;++U)this.s[U]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var C,q=typeof E;if(q!=="string"){if(q==="object"){if(E===null)throw new Error(r);if(c&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!c||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}for(var U=this.blocks,j=this.byteCount,Y=E.length,H=this.blockCount,$=0,te=this.s,G,X;$>2]|=E[$]<>2]|=X<>2]|=(192|X>>6)<>2]|=(128|X&63)<=57344?(U[G>>2]|=(224|X>>12)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<>2]|=(240|X>>18)<>2]|=(128|X>>12&63)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<=j){for(this.start=G-j,this.block=U[H],G=0;G>8,q=E&255;q>0;)j.unshift(q),E=E>>8,q=E&255,++U;return C?j.push(U):j.unshift(U),this.update(j),j.length},g.prototype.encodeString=function(E){var C,q=typeof E;if(q!=="string"){if(q==="object"){if(E===null)throw new Error(r);if(c&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!c||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}var U=0,j=E.length;if(C)U=j;else for(var Y=0;Y=57344?U+=3:(H=65536+((H&1023)<<10|E.charCodeAt(++Y)&1023),U+=4)}return U+=this.encode(U*8),this.update(E),U},g.prototype.bytepad=function(E,C){for(var q=this.encode(C),U=0;U>2]|=this.padding[C&3],this.lastByteIndex===this.byteCount)for(E[0]=E[q],C=1;C>4&15]+u[$&15]+u[$>>12&15]+u[$>>8&15]+u[$>>20&15]+u[$>>16&15]+u[$>>28&15]+u[$>>24&15];Y%E===0&&(K(C),j=0)}return U&&($=C[j],H+=u[$>>4&15]+u[$&15],U>1&&(H+=u[$>>12&15]+u[$>>8&15]),U>2&&(H+=u[$>>20&15]+u[$>>16&15])),H},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,C=this.s,q=this.outputBlocks,U=this.extraBytes,j=0,Y=0,H=this.outputBits>>3,$;U?$=new ArrayBuffer(q+1<<2):$=new ArrayBuffer(H);for(var te=new Uint32Array($);Y>8&255,H[$+2]=te>>16&255,H[$+3]=te>>24&255;Y%E===0&&K(C)}return U&&($=Y<<2,te=C[j],H[$]=te&255,U>1&&(H[$+1]=te>>8&255),U>2&&(H[$+2]=te>>16&255)),H};function R(E,C,q){g.call(this,E,C,q)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var K=function(E){var C,q,U,j,Y,H,$,te,G,X,Rr,ne,se,Tr,oe,ae,Dr,fe,ce,Nr,ue,he,Cr,de,le,Pr,pe,ge,Or,be,ve,Lr,me,ye,qr,we,_e,Fr,xe,Ee,Ur,Se,Ie,Br,Me,Ae,zr,Re,Te,kr,De,Ne,Kr,Ce,Pe,ur,Ke,je,Gt,Jt,Wt,Yt,Xt;for(U=0;U<48;U+=2)j=E[0]^E[10]^E[20]^E[30]^E[40],Y=E[1]^E[11]^E[21]^E[31]^E[41],H=E[2]^E[12]^E[22]^E[32]^E[42],$=E[3]^E[13]^E[23]^E[33]^E[43],te=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],X=E[6]^E[16]^E[26]^E[36]^E[46],Rr=E[7]^E[17]^E[27]^E[37]^E[47],ne=E[8]^E[18]^E[28]^E[38]^E[48],se=E[9]^E[19]^E[29]^E[39]^E[49],C=ne^(H<<1|$>>>31),q=se^($<<1|H>>>31),E[0]^=C,E[1]^=q,E[10]^=C,E[11]^=q,E[20]^=C,E[21]^=q,E[30]^=C,E[31]^=q,E[40]^=C,E[41]^=q,C=j^(te<<1|G>>>31),q=Y^(G<<1|te>>>31),E[2]^=C,E[3]^=q,E[12]^=C,E[13]^=q,E[22]^=C,E[23]^=q,E[32]^=C,E[33]^=q,E[42]^=C,E[43]^=q,C=H^(X<<1|Rr>>>31),q=$^(Rr<<1|X>>>31),E[4]^=C,E[5]^=q,E[14]^=C,E[15]^=q,E[24]^=C,E[25]^=q,E[34]^=C,E[35]^=q,E[44]^=C,E[45]^=q,C=te^(ne<<1|se>>>31),q=G^(se<<1|ne>>>31),E[6]^=C,E[7]^=q,E[16]^=C,E[17]^=q,E[26]^=C,E[27]^=q,E[36]^=C,E[37]^=q,E[46]^=C,E[47]^=q,C=X^(j<<1|Y>>>31),q=Rr^(Y<<1|j>>>31),E[8]^=C,E[9]^=q,E[18]^=C,E[19]^=q,E[28]^=C,E[29]^=q,E[38]^=C,E[39]^=q,E[48]^=C,E[49]^=q,Tr=E[0],oe=E[1],Ae=E[11]<<4|E[10]>>>28,zr=E[10]<<4|E[11]>>>28,ge=E[20]<<3|E[21]>>>29,Or=E[21]<<3|E[20]>>>29,Jt=E[31]<<9|E[30]>>>23,Wt=E[30]<<9|E[31]>>>23,Se=E[40]<<18|E[41]>>>14,Ie=E[41]<<18|E[40]>>>14,ye=E[2]<<1|E[3]>>>31,qr=E[3]<<1|E[2]>>>31,ae=E[13]<<12|E[12]>>>20,Dr=E[12]<<12|E[13]>>>20,Re=E[22]<<10|E[23]>>>22,Te=E[23]<<10|E[22]>>>22,be=E[33]<<13|E[32]>>>19,ve=E[32]<<13|E[33]>>>19,Yt=E[42]<<2|E[43]>>>30,Xt=E[43]<<2|E[42]>>>30,Ce=E[5]<<30|E[4]>>>2,Pe=E[4]<<30|E[5]>>>2,we=E[14]<<6|E[15]>>>26,_e=E[15]<<6|E[14]>>>26,fe=E[25]<<11|E[24]>>>21,ce=E[24]<<11|E[25]>>>21,kr=E[34]<<15|E[35]>>>17,De=E[35]<<15|E[34]>>>17,Lr=E[45]<<29|E[44]>>>3,me=E[44]<<29|E[45]>>>3,de=E[6]<<28|E[7]>>>4,le=E[7]<<28|E[6]>>>4,ur=E[17]<<23|E[16]>>>9,Ke=E[16]<<23|E[17]>>>9,Fr=E[26]<<25|E[27]>>>7,xe=E[27]<<25|E[26]>>>7,Nr=E[36]<<21|E[37]>>>11,ue=E[37]<<21|E[36]>>>11,Ne=E[47]<<24|E[46]>>>8,Kr=E[46]<<24|E[47]>>>8,Br=E[8]<<27|E[9]>>>5,Me=E[9]<<27|E[8]>>>5,Pr=E[18]<<20|E[19]>>>12,pe=E[19]<<20|E[18]>>>12,je=E[29]<<7|E[28]>>>25,Gt=E[28]<<7|E[29]>>>25,Ee=E[38]<<8|E[39]>>>24,Ur=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Cr=E[49]<<14|E[48]>>>18,E[0]=Tr^~ae&fe,E[1]=oe^~Dr&ce,E[10]=de^~Pr&ge,E[11]=le^~pe&Or,E[20]=ye^~we&Fr,E[21]=qr^~_e&xe,E[30]=Br^~Ae&Re,E[31]=Me^~zr&Te,E[40]=Ce^~ur&je,E[41]=Pe^~Ke&Gt,E[2]=ae^~fe&Nr,E[3]=Dr^~ce&ue,E[12]=Pr^~ge&be,E[13]=pe^~Or&ve,E[22]=we^~Fr&Ee,E[23]=_e^~xe&Ur,E[32]=Ae^~Re&kr,E[33]=zr^~Te&De,E[42]=ur^~je&Jt,E[43]=Ke^~Gt&Wt,E[4]=fe^~Nr&he,E[5]=ce^~ue&Cr,E[14]=ge^~be&Lr,E[15]=Or^~ve&me,E[24]=Fr^~Ee&Se,E[25]=xe^~Ur&Ie,E[34]=Re^~kr&Ne,E[35]=Te^~De&Kr,E[44]=je^~Jt&Yt,E[45]=Gt^~Wt&Xt,E[6]=Nr^~he&Tr,E[7]=ue^~Cr&oe,E[16]=be^~Lr&de,E[17]=ve^~me&le,E[26]=Ee^~Se&ye,E[27]=Ur^~Ie&qr,E[36]=kr^~Ne&Br,E[37]=De^~Kr&Me,E[46]=Jt^~Yt&Ce,E[47]=Wt^~Xt&Pe,E[8]=he^~Tr&ae,E[9]=Cr^~oe&Dr,E[18]=Lr^~de&Pr,E[19]=me^~le&pe,E[28]=Se^~ye&we,E[29]=Ie^~qr&_e,E[38]=Ne^~Br&Ae,E[39]=Kr^~Me&zr,E[48]=Yt^~Ce&ur,E[49]=Xt^~Pe&Ke,E[0]^=T[U],E[1]^=T[U+1]};if(o)Mf.exports=a;else{for(v=0;v{Og="logger/5.7.0"});function s_(){try{let r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var qg,Fg,Af,Ug,Dh,Bg,Nh,lr,zg,ht,Li=Z(()=>{"use strict";Lg();qg=!1,Fg=!1,Af={debug:1,default:2,info:2,warning:3,error:4,off:5},Ug=Af.default,Dh=null;Bg=s_();(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(Nh||(Nh={}));(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(lr||(lr={}));zg="0123456789abcdef",ht=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();Af[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Ug>Af[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(Fg)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(c=>{let u=i[c];try{if(u instanceof Uint8Array){let b="";for(let y=0;y>4],b+=zg[u[y]&15];n.push(c+"=Uint8Array(0x"+b+")")}else n.push(c+"="+JSON.stringify(u))}catch{n.push(c+"="+JSON.stringify(i[c].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case lr.NUMERIC_FAULT:{o="NUMERIC_FAULT";let c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case lr.CALL_EXCEPTION:case lr.INSUFFICIENT_FUNDS:case lr.MISSING_NEW:case lr.NONCE_EXPIRED:case lr.REPLACEMENT_UNDERPRICED:case lr.TRANSACTION_REPLACED:case lr.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(c){f[c]=i[c]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),Bg&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bg})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Dh||(Dh=new r(Og)),Dh}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qg){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Fg=!!e,qg=!!t}static setLogLevel(e){let t=Af[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}Ug=t}static from(e){return new r(e)}};ht.errors=lr;ht.levels=Nh});var kg,Kg=Z(()=>{kg="bytes/5.7.0"});function Vg(r){return!!r.toHexString}function ys(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return ys(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function $g(r){return pr(r)&&!(r.length%2)||Ph(r)}function jg(r){return typeof r=="number"&&r==r&&r%1===0}function Ph(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!jg(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Xe(r,e){if(e||(e={}),typeof r=="number"){at.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),ys(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vg(r)&&(r=r.toHexString()),pr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":at.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nXe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),ys(i)}function o_(r,e){r=Xe(r),r.length>e&&at.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),ys(t)}function pr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}function Mt(r,e){if(e||(e={}),typeof r=="number"){at.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Ch[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vg(r))return r.toHexString();if(pr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":at.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Ph(r)){let t="0x";for(let i=0;i>4]+Ch[n&15]}return t}return at.throwArgumentError("invalid hexlify value","value",r)}function Rf(r){if(typeof r!="string")r=Mt(r);else if(!pr(r)||r.length%2)return null;return(r.length-2)/2}function Tf(r,e,t){return typeof r!="string"?r=Mt(r):(!pr(r)||r.length%2)&&at.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function qi(r,e){for(typeof r!="string"?r=Mt(r):pr(r)||at.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&at.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function Df(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if($g(r)){let t=Xe(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Mt(t.slice(0,32)),e.s=Mt(t.slice(32,64))):t.length===65?(e.r=Mt(t.slice(0,32)),e.s=Mt(t.slice(32,64)),e.v=t[64]):at.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:at.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Mt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=o_(Xe(e._vs),32);e._vs=Mt(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&at.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=Mt(n);e.s==null?e.s=o:e.s!==o&&at.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?at.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&at.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!pr(e.r)?at.throwArgumentError("signature missing or invalid r","signature",r):e.r=qi(e.r,32),e.s==null||!pr(e.s)?at.throwArgumentError("signature missing or invalid s","signature",r):e.s=qi(e.s,32);let t=Xe(e.s);t[0]>=128&&at.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=Mt(t);e._vs&&(pr(e._vs)||at.throwArgumentError("signature invalid _vs","signature",r),e._vs=qi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&at.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}var at,Ch,Dn=Z(()=>{"use strict";Li();Kg();at=new ht(kg);Ch="0123456789abcdef"});function ws(r){return"0x"+Hg.default.keccak_256(Xe(r))}var Hg,Nf=Z(()=>{"use strict";Hg=Ue(Pg());Dn()});var Lh=W(()=>{});var Fh=W((Gg,qh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var d=function(){};d.prototype=a.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,a,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(d=a,a=10),this._init(p||0,a||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Lh().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,d){return a.cmp(d)>0?a:d},n.min=function(a,d){return a.cmp(d)<0?a:d},n.prototype._init=function(a,d,v){if(typeof a=="number")return this._initNumber(a,d,v);if(typeof a=="object")return this._initArray(a,d,v);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)h=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[m]|=h<>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);else if(v==="le")for(_=0,m=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);return this._strip()};function o(p,a){var d=p.charCodeAt(a);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function f(p,a,d){var v=o(p,d);return d-1>=a&&(v|=o(p,d-1)<<4),v}n.prototype._parseHex=function(a,d,v){this.length=Math.ceil((a.length-d)/6),this.words=new Array(this.length);for(var _=0;_=d;_-=2)x=f(a,d,_)<=18?(m-=18,h+=1,this.words[h]|=x>>>26):m+=8;else{var A=a.length-d;for(_=A%2===0?d+1:d;_=18?(m-=18,h+=1,this.words[h]|=x>>>26):m+=8}this._strip()};function c(p,a,d,v){for(var _=0,m=0,h=Math.min(p.length,d),x=a;x=49?m=A-49+10:A>=17?m=A-17+10:m=A,t(A>=0&&m1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,d){a=a||10,d=d|0||1;var v;if(a===16||a==="hex"){v="";for(var _=0,m=0,h=0;h>>24-_&16777215,_+=2,_>=26&&(_-=26,h--),m!==0||h!==this.length-1?v=y[6-A.length]+A+v:v=A+v}for(m!==0&&(v=m.toString(16)+v);v.length%d!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];v="";var K=this.clone();for(K.negative=0;!K.isZero();){var E=K.modrn(R).toString(a);K=K.idivn(R),K.isZero()?v=E+v:v=y[g-E.length]+E+v}for(this.isZero()&&(v="0"+v);v.length%d!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,d){return this.toArrayLike(s,a,d)}),n.prototype.toArray=function(a,d){return this.toArrayLike(Array,a,d)};var M=function(a,d){return a.allocUnsafe?a.allocUnsafe(d):new a(d)};n.prototype.toArrayLike=function(a,d,v){this._strip();var _=this.byteLength(),m=v||Math.max(1,_);t(_<=m,"byte array longer than desired length"),t(m>0,"Requested array length <= 0");var h=M(a,m),x=d==="le"?"LE":"BE";return this["_toArrayLike"+x](h,_),h},n.prototype._toArrayLikeLE=function(a,d){for(var v=0,_=0,m=0,h=0;m>8&255),v>16&255),h===6?(v>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(v=0&&(a[v--]=x>>8&255),v>=0&&(a[v--]=x>>16&255),h===6?(v>=0&&(a[v--]=x>>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(v>=0)for(a[v--]=_;v>=0;)a[v--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var d=a,v=0;return d>=4096&&(v+=13,d>>>=13),d>=64&&(v+=7,d>>>=7),d>=8&&(v+=4,d>>>=4),d>=2&&(v+=2,d>>>=2),v+d},n.prototype._zeroBits=function(a){if(a===0)return 26;var d=a,v=0;return d&8191||(v+=13,d>>>=13),d&127||(v+=7,d>>>=7),d&15||(v+=4,d>>>=4),d&3||(v+=2,d>>>=2),d&1||v++,v},n.prototype.bitLength=function(){var a=this.words[this.length-1],d=this._countBits(a);return(this.length-1)*26+d};function T(p){for(var a=new Array(p.bitLength()),d=0;d>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,d=0;da.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var d;this.length>a.length?d=a:d=this;for(var v=0;va.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var d,v;this.length>a.length?(d=this,v=a):(d=a,v=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var d=Math.ceil(a/26)|0,v=a%26;this._expand(d),v>0&&d--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-v),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,d){t(typeof a=="number"&&a>=0);var v=a/26|0,_=a%26;return this._expand(v+1),d?this.words[v]=this.words[v]|1<<_:this.words[v]=this.words[v]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var d;if(this.negative!==0&&a.negative===0)return this.negative=0,d=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,d=this.isub(a),a.negative=1,d._normSign();var v,_;this.length>a.length?(v=this,_=a):(v=a,_=this);for(var m=0,h=0;h<_.length;h++)d=(v.words[h]|0)+(_.words[h]|0)+m,this.words[h]=d&67108863,m=d>>>26;for(;m!==0&&h>>26;if(this.length=v.length,m!==0)this.words[this.length]=m,this.length++;else if(v!==this)for(;ha.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var d=this.iadd(a);return a.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var v=this.cmp(a);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,m;v>0?(_=this,m=a):(_=a,m=this);for(var h=0,x=0;x>26,this.words[x]=d&67108863;for(;h!==0&&x<_.length;x++)d=(_.words[x]|0)+h,h=d>>26,this.words[x]=d&67108863;if(h===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function O(p,a,d){d.negative=a.negative^p.negative;var v=p.length+a.length|0;d.length=v,v=v-1|0;var _=p.words[0]|0,m=a.words[0]|0,h=_*m,x=h&67108863,A=h/67108864|0;d.words[0]=x;for(var g=1;g>>26,K=A&67108863,E=Math.min(g,a.length-1),C=Math.max(0,g-p.length+1);C<=E;C++){var q=g-C|0;_=p.words[q]|0,m=a.words[C]|0,h=_*m+K,R+=h/67108864|0,K=h&67108863}d.words[g]=K|0,A=R|0}return A!==0?d.words[g]=A|0:d.length--,d._strip()}var N=function(a,d,v){var _=a.words,m=d.words,h=v.words,x=0,A,g,R,K=_[0]|0,E=K&8191,C=K>>>13,q=_[1]|0,U=q&8191,j=q>>>13,Y=_[2]|0,H=Y&8191,$=Y>>>13,te=_[3]|0,G=te&8191,X=te>>>13,Rr=_[4]|0,ne=Rr&8191,se=Rr>>>13,Tr=_[5]|0,oe=Tr&8191,ae=Tr>>>13,Dr=_[6]|0,fe=Dr&8191,ce=Dr>>>13,Nr=_[7]|0,ue=Nr&8191,he=Nr>>>13,Cr=_[8]|0,de=Cr&8191,le=Cr>>>13,Pr=_[9]|0,pe=Pr&8191,ge=Pr>>>13,Or=m[0]|0,be=Or&8191,ve=Or>>>13,Lr=m[1]|0,me=Lr&8191,ye=Lr>>>13,qr=m[2]|0,we=qr&8191,_e=qr>>>13,Fr=m[3]|0,xe=Fr&8191,Ee=Fr>>>13,Ur=m[4]|0,Se=Ur&8191,Ie=Ur>>>13,Br=m[5]|0,Me=Br&8191,Ae=Br>>>13,zr=m[6]|0,Re=zr&8191,Te=zr>>>13,kr=m[7]|0,De=kr&8191,Ne=kr>>>13,Kr=m[8]|0,Ce=Kr&8191,Pe=Kr>>>13,ur=m[9]|0,Ke=ur&8191,je=ur>>>13;v.negative=a.negative^d.negative,v.length=19,A=Math.imul(E,be),g=Math.imul(E,ve),g=g+Math.imul(C,be)|0,R=Math.imul(C,ve);var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(U,be),g=Math.imul(U,ve),g=g+Math.imul(j,be)|0,R=Math.imul(j,ve),A=A+Math.imul(E,me)|0,g=g+Math.imul(E,ye)|0,g=g+Math.imul(C,me)|0,R=R+Math.imul(C,ye)|0;var Jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,A=Math.imul(H,be),g=Math.imul(H,ve),g=g+Math.imul($,be)|0,R=Math.imul($,ve),A=A+Math.imul(U,me)|0,g=g+Math.imul(U,ye)|0,g=g+Math.imul(j,me)|0,R=R+Math.imul(j,ye)|0,A=A+Math.imul(E,we)|0,g=g+Math.imul(E,_e)|0,g=g+Math.imul(C,we)|0,R=R+Math.imul(C,_e)|0;var Wt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,A=Math.imul(G,be),g=Math.imul(G,ve),g=g+Math.imul(X,be)|0,R=Math.imul(X,ve),A=A+Math.imul(H,me)|0,g=g+Math.imul(H,ye)|0,g=g+Math.imul($,me)|0,R=R+Math.imul($,ye)|0,A=A+Math.imul(U,we)|0,g=g+Math.imul(U,_e)|0,g=g+Math.imul(j,we)|0,R=R+Math.imul(j,_e)|0,A=A+Math.imul(E,xe)|0,g=g+Math.imul(E,Ee)|0,g=g+Math.imul(C,xe)|0,R=R+Math.imul(C,Ee)|0;var Yt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,A=Math.imul(ne,be),g=Math.imul(ne,ve),g=g+Math.imul(se,be)|0,R=Math.imul(se,ve),A=A+Math.imul(G,me)|0,g=g+Math.imul(G,ye)|0,g=g+Math.imul(X,me)|0,R=R+Math.imul(X,ye)|0,A=A+Math.imul(H,we)|0,g=g+Math.imul(H,_e)|0,g=g+Math.imul($,we)|0,R=R+Math.imul($,_e)|0,A=A+Math.imul(U,xe)|0,g=g+Math.imul(U,Ee)|0,g=g+Math.imul(j,xe)|0,R=R+Math.imul(j,Ee)|0,A=A+Math.imul(E,Se)|0,g=g+Math.imul(E,Ie)|0,g=g+Math.imul(C,Se)|0,R=R+Math.imul(C,Ie)|0;var Xt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,A=Math.imul(oe,be),g=Math.imul(oe,ve),g=g+Math.imul(ae,be)|0,R=Math.imul(ae,ve),A=A+Math.imul(ne,me)|0,g=g+Math.imul(ne,ye)|0,g=g+Math.imul(se,me)|0,R=R+Math.imul(se,ye)|0,A=A+Math.imul(G,we)|0,g=g+Math.imul(G,_e)|0,g=g+Math.imul(X,we)|0,R=R+Math.imul(X,_e)|0,A=A+Math.imul(H,xe)|0,g=g+Math.imul(H,Ee)|0,g=g+Math.imul($,xe)|0,R=R+Math.imul($,Ee)|0,A=A+Math.imul(U,Se)|0,g=g+Math.imul(U,Ie)|0,g=g+Math.imul(j,Se)|0,R=R+Math.imul(j,Ie)|0,A=A+Math.imul(E,Me)|0,g=g+Math.imul(E,Ae)|0,g=g+Math.imul(C,Me)|0,R=R+Math.imul(C,Ae)|0;var un=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(un>>>26)|0,un&=67108863,A=Math.imul(fe,be),g=Math.imul(fe,ve),g=g+Math.imul(ce,be)|0,R=Math.imul(ce,ve),A=A+Math.imul(oe,me)|0,g=g+Math.imul(oe,ye)|0,g=g+Math.imul(ae,me)|0,R=R+Math.imul(ae,ye)|0,A=A+Math.imul(ne,we)|0,g=g+Math.imul(ne,_e)|0,g=g+Math.imul(se,we)|0,R=R+Math.imul(se,_e)|0,A=A+Math.imul(G,xe)|0,g=g+Math.imul(G,Ee)|0,g=g+Math.imul(X,xe)|0,R=R+Math.imul(X,Ee)|0,A=A+Math.imul(H,Se)|0,g=g+Math.imul(H,Ie)|0,g=g+Math.imul($,Se)|0,R=R+Math.imul($,Ie)|0,A=A+Math.imul(U,Me)|0,g=g+Math.imul(U,Ae)|0,g=g+Math.imul(j,Me)|0,R=R+Math.imul(j,Ae)|0,A=A+Math.imul(E,Re)|0,g=g+Math.imul(E,Te)|0,g=g+Math.imul(C,Re)|0,R=R+Math.imul(C,Te)|0;var hn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(hn>>>26)|0,hn&=67108863,A=Math.imul(ue,be),g=Math.imul(ue,ve),g=g+Math.imul(he,be)|0,R=Math.imul(he,ve),A=A+Math.imul(fe,me)|0,g=g+Math.imul(fe,ye)|0,g=g+Math.imul(ce,me)|0,R=R+Math.imul(ce,ye)|0,A=A+Math.imul(oe,we)|0,g=g+Math.imul(oe,_e)|0,g=g+Math.imul(ae,we)|0,R=R+Math.imul(ae,_e)|0,A=A+Math.imul(ne,xe)|0,g=g+Math.imul(ne,Ee)|0,g=g+Math.imul(se,xe)|0,R=R+Math.imul(se,Ee)|0,A=A+Math.imul(G,Se)|0,g=g+Math.imul(G,Ie)|0,g=g+Math.imul(X,Se)|0,R=R+Math.imul(X,Ie)|0,A=A+Math.imul(H,Me)|0,g=g+Math.imul(H,Ae)|0,g=g+Math.imul($,Me)|0,R=R+Math.imul($,Ae)|0,A=A+Math.imul(U,Re)|0,g=g+Math.imul(U,Te)|0,g=g+Math.imul(j,Re)|0,R=R+Math.imul(j,Te)|0,A=A+Math.imul(E,De)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(C,De)|0,R=R+Math.imul(C,Ne)|0;var dn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(dn>>>26)|0,dn&=67108863,A=Math.imul(de,be),g=Math.imul(de,ve),g=g+Math.imul(le,be)|0,R=Math.imul(le,ve),A=A+Math.imul(ue,me)|0,g=g+Math.imul(ue,ye)|0,g=g+Math.imul(he,me)|0,R=R+Math.imul(he,ye)|0,A=A+Math.imul(fe,we)|0,g=g+Math.imul(fe,_e)|0,g=g+Math.imul(ce,we)|0,R=R+Math.imul(ce,_e)|0,A=A+Math.imul(oe,xe)|0,g=g+Math.imul(oe,Ee)|0,g=g+Math.imul(ae,xe)|0,R=R+Math.imul(ae,Ee)|0,A=A+Math.imul(ne,Se)|0,g=g+Math.imul(ne,Ie)|0,g=g+Math.imul(se,Se)|0,R=R+Math.imul(se,Ie)|0,A=A+Math.imul(G,Me)|0,g=g+Math.imul(G,Ae)|0,g=g+Math.imul(X,Me)|0,R=R+Math.imul(X,Ae)|0,A=A+Math.imul(H,Re)|0,g=g+Math.imul(H,Te)|0,g=g+Math.imul($,Re)|0,R=R+Math.imul($,Te)|0,A=A+Math.imul(U,De)|0,g=g+Math.imul(U,Ne)|0,g=g+Math.imul(j,De)|0,R=R+Math.imul(j,Ne)|0,A=A+Math.imul(E,Ce)|0,g=g+Math.imul(E,Pe)|0,g=g+Math.imul(C,Ce)|0,R=R+Math.imul(C,Pe)|0;var ln=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(ln>>>26)|0,ln&=67108863,A=Math.imul(pe,be),g=Math.imul(pe,ve),g=g+Math.imul(ge,be)|0,R=Math.imul(ge,ve),A=A+Math.imul(de,me)|0,g=g+Math.imul(de,ye)|0,g=g+Math.imul(le,me)|0,R=R+Math.imul(le,ye)|0,A=A+Math.imul(ue,we)|0,g=g+Math.imul(ue,_e)|0,g=g+Math.imul(he,we)|0,R=R+Math.imul(he,_e)|0,A=A+Math.imul(fe,xe)|0,g=g+Math.imul(fe,Ee)|0,g=g+Math.imul(ce,xe)|0,R=R+Math.imul(ce,Ee)|0,A=A+Math.imul(oe,Se)|0,g=g+Math.imul(oe,Ie)|0,g=g+Math.imul(ae,Se)|0,R=R+Math.imul(ae,Ie)|0,A=A+Math.imul(ne,Me)|0,g=g+Math.imul(ne,Ae)|0,g=g+Math.imul(se,Me)|0,R=R+Math.imul(se,Ae)|0,A=A+Math.imul(G,Re)|0,g=g+Math.imul(G,Te)|0,g=g+Math.imul(X,Re)|0,R=R+Math.imul(X,Te)|0,A=A+Math.imul(H,De)|0,g=g+Math.imul(H,Ne)|0,g=g+Math.imul($,De)|0,R=R+Math.imul($,Ne)|0,A=A+Math.imul(U,Ce)|0,g=g+Math.imul(U,Pe)|0,g=g+Math.imul(j,Ce)|0,R=R+Math.imul(j,Pe)|0,A=A+Math.imul(E,Ke)|0,g=g+Math.imul(E,je)|0,g=g+Math.imul(C,Ke)|0,R=R+Math.imul(C,je)|0;var pn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(pn>>>26)|0,pn&=67108863,A=Math.imul(pe,me),g=Math.imul(pe,ye),g=g+Math.imul(ge,me)|0,R=Math.imul(ge,ye),A=A+Math.imul(de,we)|0,g=g+Math.imul(de,_e)|0,g=g+Math.imul(le,we)|0,R=R+Math.imul(le,_e)|0,A=A+Math.imul(ue,xe)|0,g=g+Math.imul(ue,Ee)|0,g=g+Math.imul(he,xe)|0,R=R+Math.imul(he,Ee)|0,A=A+Math.imul(fe,Se)|0,g=g+Math.imul(fe,Ie)|0,g=g+Math.imul(ce,Se)|0,R=R+Math.imul(ce,Ie)|0,A=A+Math.imul(oe,Me)|0,g=g+Math.imul(oe,Ae)|0,g=g+Math.imul(ae,Me)|0,R=R+Math.imul(ae,Ae)|0,A=A+Math.imul(ne,Re)|0,g=g+Math.imul(ne,Te)|0,g=g+Math.imul(se,Re)|0,R=R+Math.imul(se,Te)|0,A=A+Math.imul(G,De)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(X,De)|0,R=R+Math.imul(X,Ne)|0,A=A+Math.imul(H,Ce)|0,g=g+Math.imul(H,Pe)|0,g=g+Math.imul($,Ce)|0,R=R+Math.imul($,Pe)|0,A=A+Math.imul(U,Ke)|0,g=g+Math.imul(U,je)|0,g=g+Math.imul(j,Ke)|0,R=R+Math.imul(j,je)|0;var gn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(gn>>>26)|0,gn&=67108863,A=Math.imul(pe,we),g=Math.imul(pe,_e),g=g+Math.imul(ge,we)|0,R=Math.imul(ge,_e),A=A+Math.imul(de,xe)|0,g=g+Math.imul(de,Ee)|0,g=g+Math.imul(le,xe)|0,R=R+Math.imul(le,Ee)|0,A=A+Math.imul(ue,Se)|0,g=g+Math.imul(ue,Ie)|0,g=g+Math.imul(he,Se)|0,R=R+Math.imul(he,Ie)|0,A=A+Math.imul(fe,Me)|0,g=g+Math.imul(fe,Ae)|0,g=g+Math.imul(ce,Me)|0,R=R+Math.imul(ce,Ae)|0,A=A+Math.imul(oe,Re)|0,g=g+Math.imul(oe,Te)|0,g=g+Math.imul(ae,Re)|0,R=R+Math.imul(ae,Te)|0,A=A+Math.imul(ne,De)|0,g=g+Math.imul(ne,Ne)|0,g=g+Math.imul(se,De)|0,R=R+Math.imul(se,Ne)|0,A=A+Math.imul(G,Ce)|0,g=g+Math.imul(G,Pe)|0,g=g+Math.imul(X,Ce)|0,R=R+Math.imul(X,Pe)|0,A=A+Math.imul(H,Ke)|0,g=g+Math.imul(H,je)|0,g=g+Math.imul($,Ke)|0,R=R+Math.imul($,je)|0;var bn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(bn>>>26)|0,bn&=67108863,A=Math.imul(pe,xe),g=Math.imul(pe,Ee),g=g+Math.imul(ge,xe)|0,R=Math.imul(ge,Ee),A=A+Math.imul(de,Se)|0,g=g+Math.imul(de,Ie)|0,g=g+Math.imul(le,Se)|0,R=R+Math.imul(le,Ie)|0,A=A+Math.imul(ue,Me)|0,g=g+Math.imul(ue,Ae)|0,g=g+Math.imul(he,Me)|0,R=R+Math.imul(he,Ae)|0,A=A+Math.imul(fe,Re)|0,g=g+Math.imul(fe,Te)|0,g=g+Math.imul(ce,Re)|0,R=R+Math.imul(ce,Te)|0,A=A+Math.imul(oe,De)|0,g=g+Math.imul(oe,Ne)|0,g=g+Math.imul(ae,De)|0,R=R+Math.imul(ae,Ne)|0,A=A+Math.imul(ne,Ce)|0,g=g+Math.imul(ne,Pe)|0,g=g+Math.imul(se,Ce)|0,R=R+Math.imul(se,Pe)|0,A=A+Math.imul(G,Ke)|0,g=g+Math.imul(G,je)|0,g=g+Math.imul(X,Ke)|0,R=R+Math.imul(X,je)|0;var vn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(vn>>>26)|0,vn&=67108863,A=Math.imul(pe,Se),g=Math.imul(pe,Ie),g=g+Math.imul(ge,Se)|0,R=Math.imul(ge,Ie),A=A+Math.imul(de,Me)|0,g=g+Math.imul(de,Ae)|0,g=g+Math.imul(le,Me)|0,R=R+Math.imul(le,Ae)|0,A=A+Math.imul(ue,Re)|0,g=g+Math.imul(ue,Te)|0,g=g+Math.imul(he,Re)|0,R=R+Math.imul(he,Te)|0,A=A+Math.imul(fe,De)|0,g=g+Math.imul(fe,Ne)|0,g=g+Math.imul(ce,De)|0,R=R+Math.imul(ce,Ne)|0,A=A+Math.imul(oe,Ce)|0,g=g+Math.imul(oe,Pe)|0,g=g+Math.imul(ae,Ce)|0,R=R+Math.imul(ae,Pe)|0,A=A+Math.imul(ne,Ke)|0,g=g+Math.imul(ne,je)|0,g=g+Math.imul(se,Ke)|0,R=R+Math.imul(se,je)|0;var mn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(mn>>>26)|0,mn&=67108863,A=Math.imul(pe,Me),g=Math.imul(pe,Ae),g=g+Math.imul(ge,Me)|0,R=Math.imul(ge,Ae),A=A+Math.imul(de,Re)|0,g=g+Math.imul(de,Te)|0,g=g+Math.imul(le,Re)|0,R=R+Math.imul(le,Te)|0,A=A+Math.imul(ue,De)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(he,De)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(fe,Ce)|0,g=g+Math.imul(fe,Pe)|0,g=g+Math.imul(ce,Ce)|0,R=R+Math.imul(ce,Pe)|0,A=A+Math.imul(oe,Ke)|0,g=g+Math.imul(oe,je)|0,g=g+Math.imul(ae,Ke)|0,R=R+Math.imul(ae,je)|0;var yn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(yn>>>26)|0,yn&=67108863,A=Math.imul(pe,Re),g=Math.imul(pe,Te),g=g+Math.imul(ge,Re)|0,R=Math.imul(ge,Te),A=A+Math.imul(de,De)|0,g=g+Math.imul(de,Ne)|0,g=g+Math.imul(le,De)|0,R=R+Math.imul(le,Ne)|0,A=A+Math.imul(ue,Ce)|0,g=g+Math.imul(ue,Pe)|0,g=g+Math.imul(he,Ce)|0,R=R+Math.imul(he,Pe)|0,A=A+Math.imul(fe,Ke)|0,g=g+Math.imul(fe,je)|0,g=g+Math.imul(ce,Ke)|0,R=R+Math.imul(ce,je)|0;var wn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(wn>>>26)|0,wn&=67108863,A=Math.imul(pe,De),g=Math.imul(pe,Ne),g=g+Math.imul(ge,De)|0,R=Math.imul(ge,Ne),A=A+Math.imul(de,Ce)|0,g=g+Math.imul(de,Pe)|0,g=g+Math.imul(le,Ce)|0,R=R+Math.imul(le,Pe)|0,A=A+Math.imul(ue,Ke)|0,g=g+Math.imul(ue,je)|0,g=g+Math.imul(he,Ke)|0,R=R+Math.imul(he,je)|0;var iu=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(iu>>>26)|0,iu&=67108863,A=Math.imul(pe,Ce),g=Math.imul(pe,Pe),g=g+Math.imul(ge,Ce)|0,R=Math.imul(ge,Pe),A=A+Math.imul(de,Ke)|0,g=g+Math.imul(de,je)|0,g=g+Math.imul(le,Ke)|0,R=R+Math.imul(le,je)|0;var nu=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nu>>>26)|0,nu&=67108863,A=Math.imul(pe,Ke),g=Math.imul(pe,je),g=g+Math.imul(ge,Ke)|0,R=Math.imul(ge,je);var su=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(su>>>26)|0,su&=67108863,h[0]=Gt,h[1]=Jt,h[2]=Wt,h[3]=Yt,h[4]=Xt,h[5]=un,h[6]=hn,h[7]=dn,h[8]=ln,h[9]=pn,h[10]=gn,h[11]=bn,h[12]=vn,h[13]=mn,h[14]=yn,h[15]=wn,h[16]=iu,h[17]=nu,h[18]=su,x!==0&&(h[19]=x,v.length++),v};Math.imul||(N=O);function B(p,a,d){d.negative=a.negative^p.negative,d.length=p.length+a.length;for(var v=0,_=0,m=0;m>>26)|0,_+=h>>>26,h&=67108863}d.words[m]=x,v=h,h=_}return v!==0?d.words[m]=v:d.length--,d._strip()}function z(p,a,d){return B(p,a,d)}n.prototype.mulTo=function(a,d){var v,_=this.length+a.length;return this.length===10&&a.length===10?v=N(this,a,d):_<63?v=O(this,a,d):_<1024?v=B(this,a,d):v=z(this,a,d),v};function F(p,a){this.x=p,this.y=a}F.prototype.makeRBT=function(a){for(var d=new Array(a),v=n.prototype._countBits(a)-1,_=0;_>=1;return _},F.prototype.permute=function(a,d,v,_,m,h){for(var x=0;x>>1)m++;return 1<>>13,v[2*h+1]=m&8191,m=m>>>13;for(h=2*d;h<_;++h)v[h]=0;t(m===0),t((m&-8192)===0)},F.prototype.stub=function(a){for(var d=new Array(a),v=0;v>=26,v+=m/67108864|0,v+=h>>>26,this.words[_]=h&67108863}return v!==0&&(this.words[_]=v,this.length++),d?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var d=T(a);if(d.length===0)return new n(1);for(var v=this,_=0;_=0);var d=a%26,v=(a-d)/26,_=67108863>>>26-d<<26-d,m;if(d!==0){var h=0;for(m=0;m>>26-d}h&&(this.words[m]=h,this.length++)}if(v!==0){for(m=this.length-1;m>=0;m--)this.words[m+v]=this.words[m];for(m=0;m=0);var _;d?_=(d-d%26)/26:_=0;var m=a%26,h=Math.min((a-m)/26,this.length),x=67108863^67108863>>>m<h)for(this.length-=h,g=0;g=0&&(R!==0||g>=_);g--){var K=this.words[g]|0;this.words[g]=R<<26-m|K>>>m,R=K&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,d,v){return t(this.negative===0),this.iushrn(a,d,v)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var d=a%26,v=(a-d)/26,_=1<=0);var d=a%26,v=(a-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(d!==0&&v++,this.length=Math.min(v,this.length),d!==0){var _=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(A/67108864|0),this.words[m+v]=h&67108863}for(;m>26,this.words[m+v]=h&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,m=0;m>26,this.words[m]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,d){var v=this.length-a.length,_=this.clone(),m=a,h=m.words[m.length-1]|0,x=this._countBits(h);v=26-x,v!==0&&(m=m.ushln(v),_.iushln(v),h=m.words[m.length-1]|0);var A=_.length-m.length,g;if(d!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var C=(_.words[m.length+E]|0)*67108864+(_.words[m.length+E-1]|0);for(C=Math.min(C/h|0,67108863),_._ishlnsubmul(m,C,E);_.negative!==0;)C--,_.negative=0,_._ishlnsubmul(m,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=C)}return g&&g._strip(),_._strip(),d!=="div"&&v!==0&&_.iushrn(v),{div:g||null,mod:_}},n.prototype.divmod=function(a,d,v){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,m,h;return this.negative!==0&&a.negative===0?(h=this.neg().divmod(a,d),d!=="mod"&&(_=h.div.neg()),d!=="div"&&(m=h.mod.neg(),v&&m.negative!==0&&m.iadd(a)),{div:_,mod:m}):this.negative===0&&a.negative!==0?(h=this.divmod(a.neg(),d),d!=="mod"&&(_=h.div.neg()),{div:_,mod:h.mod}):this.negative&a.negative?(h=this.neg().divmod(a.neg(),d),d!=="div"&&(m=h.mod.neg(),v&&m.negative!==0&&m.isub(a)),{div:h.div,mod:m}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?d==="div"?{div:this.divn(a.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,d)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var d=this.divmod(a);if(d.mod.isZero())return d.div;var v=d.div.negative!==0?d.mod.isub(a):d.mod,_=a.ushrn(1),m=a.andln(1),h=v.cmp(_);return h<0||m===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var v=(1<<26)%a,_=0,m=this.length-1;m>=0;m--)_=(v*_+(this.words[m]|0))%a;return d?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var v=0,_=this.length-1;_>=0;_--){var m=(this.words[_]|0)+v*67108864;this.words[_]=m/a|0,v=m%a}return this._strip(),d?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var d=this,v=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),m=new n(0),h=new n(0),x=new n(1),A=0;d.isEven()&&v.isEven();)d.iushrn(1),v.iushrn(1),++A;for(var g=v.clone(),R=d.clone();!d.isZero();){for(var K=0,E=1;!(d.words[0]&E)&&K<26;++K,E<<=1);if(K>0)for(d.iushrn(K);K-- >0;)(_.isOdd()||m.isOdd())&&(_.iadd(g),m.isub(R)),_.iushrn(1),m.iushrn(1);for(var C=0,q=1;!(v.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(v.iushrn(C);C-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(g),x.isub(R)),h.iushrn(1),x.iushrn(1);d.cmp(v)>=0?(d.isub(v),_.isub(h),m.isub(x)):(v.isub(d),h.isub(_),x.isub(m))}return{a:h,b:x,gcd:v.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var d=this,v=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),m=new n(0),h=v.clone();d.cmpn(1)>0&&v.cmpn(1)>0;){for(var x=0,A=1;!(d.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(d.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(h),_.iushrn(1);for(var g=0,R=1;!(v.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(v.iushrn(g);g-- >0;)m.isOdd()&&m.iadd(h),m.iushrn(1);d.cmp(v)>=0?(d.isub(v),_.isub(m)):(v.isub(d),m.isub(_))}var K;return d.cmpn(1)===0?K=_:K=m,K.cmpn(0)<0&&K.iadd(a),K},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var d=this.clone(),v=a.clone();d.negative=0,v.negative=0;for(var _=0;d.isEven()&&v.isEven();_++)d.iushrn(1),v.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;v.isEven();)v.iushrn(1);var m=d.cmp(v);if(m<0){var h=d;d=v,v=h}else if(m===0||v.cmpn(1)===0)break;d.isub(v)}while(!0);return v.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var d=a%26,v=(a-d)/26,_=1<>>26,x&=67108863,this.words[h]=x}return m!==0&&(this.words[h]=m,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var d=a<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var v;if(this.length>1)v=1;else{d&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;v=_===a?0:_a.length)return 1;if(this.length=0;v--){var _=this.words[v]|0,m=a.words[v]|0;if(_!==m){_m&&(d=1);break}}return d},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var k={k256:null,p224:null,p192:null,p25519:null};function V(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},V.prototype.ireduce=function(a){var d=a,v;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),v=d.bitLength();while(v>this.n);var _=v0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},V.prototype.split=function(a,d){a.iushrn(this.n,0,d)},V.prototype.imulK=function(a){return a.imul(this.k)};function L(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,V),L.prototype.split=function(a,d){for(var v=4194303,_=Math.min(a.length,9),m=0;m<_;m++)d.words[m]=a.words[m];if(d.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var h=a.words[9];for(d.words[d.length++]=h&v,m=10;m>>22,h=x}h>>>=22,a.words[m-10]=h,h===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var d=0,v=0;v>>=26,a.words[v]=m,d=_}return d!==0&&(a.words[a.length++]=d),a},n._prime=function(a){if(k[a])return k[a];var d;if(a==="k256")d=new L;else if(a==="p224")d=new P;else if(a==="p192")d=new J;else if(a==="p25519")d=new D;else throw new Error("Unknown prime "+a);return k[a]=d,d};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,d){t((a.negative|d.negative)===0,"red works only with positives"),t(a.red&&a.red===d.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(u(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,d){this._verify2(a,d);var v=a.add(d);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},l.prototype.iadd=function(a,d){this._verify2(a,d);var v=a.iadd(d);return v.cmp(this.m)>=0&&v.isub(this.m),v},l.prototype.sub=function(a,d){this._verify2(a,d);var v=a.sub(d);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},l.prototype.isub=function(a,d){this._verify2(a,d);var v=a.isub(d);return v.cmpn(0)<0&&v.iadd(this.m),v},l.prototype.shl=function(a,d){return this._verify1(a),this.imod(a.ushln(d))},l.prototype.imul=function(a,d){return this._verify2(a,d),this.imod(a.imul(d))},l.prototype.mul=function(a,d){return this._verify2(a,d),this.imod(a.mul(d))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var v=this.m.add(new n(1)).iushrn(2);return this.pow(a,v)}for(var _=this.m.subn(1),m=0;!_.isZero()&&_.andln(1)===0;)m++,_.iushrn(1);t(!_.isZero());var h=new n(1).toRed(this),x=h.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),K=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),C=m;E.cmp(h)!==0;){for(var q=E,U=0;q.cmp(h)!==0;U++)q=q.redSqr();t(U=0;m--){for(var R=d.words[m],K=g-1;K>=0;K--){var E=R>>K&1;if(h!==_[0]&&(h=this.sqr(h)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==v&&(m!==0||K!==0))&&(h=this.mul(h,_[x]),A=0,x=0)}g=26}return h},l.prototype.convertTo=function(a){var d=a.umod(this.m);return d===a?d.clone():d},l.prototype.convertFrom=function(a){var d=a.clone();return d.red=null,d},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var d=this.imod(a.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(a,d){if(a.isZero()||d.isZero())return a.words[0]=0,a.length=1,a;var v=a.imul(d),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),h=m;return m.cmp(this.m)>=0?h=m.isub(this.m):m.cmpn(0)<0&&(h=m.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(a,d){if(a.isZero()||d.isZero())return new n(0)._forceRed(this);var v=a.mul(d),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),h=m;return m.cmp(this.m)>=0?h=m.isub(this.m):m.cmpn(0)<0&&(h=m.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(a){var d=this.imod(a._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof qh>"u"||qh,Gg)});var Jg,Wg=Z(()=>{Jg="bignumber/5.7.0"});function Uh(r){return new a_(r,36).toString(16)}var Yg,a_,oN,Xg=Z(()=>{"use strict";Yg=Ue(Fh());Li();Wg();a_=Yg.default.BN,oN=new ht(Jg)});var Zg=Z(()=>{Xg()});var Qg,eb=Z(()=>{Qg="strings/5.7.0"});function c_(r,e,t,i,n){return tb.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function rb(r,e,t,i,n){if(r===Nn.BAD_PREFIX||r===Nn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===Nn.OVERRUN?t.length-e-1:0}function u_(r,e,t,i,n){return r===Nn.OVERLONG?(i.push(n),0):(i.push(65533),rb(r,e,t,i,n))}function No(r,e=Do.current){e!=Do.current&&(tb.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return Xe(t)}var tb,Do,Nn,h_,ib=Z(()=>{"use strict";Dn();Li();eb();tb=new ht(Qg);(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Do||(Do={}));(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(Nn||(Nn={}));h_=Object.freeze({error:c_,ignore:rb,replace:u_})});var nb=Z(()=>{"use strict";ib()});function Cf(r){return typeof r=="string"&&(r=No(r)),ws(Oh([No(sb),No(String(r.length)),r]))}var sb,ob=Z(()=>{Dn();Nf();nb();sb=`Ethereum Signed Message: +`});var ab,fb=Z(()=>{ab="address/5.7.0"});function cb(r){pr(r,20)||Co.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=Xe(ws(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}function p_(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}function g_(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Bh[i]).join("");for(;e.length>=ub;){let i=e.substring(0,ub);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function hb(r){let e=null;if(typeof r!="string"&&Co.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=cb(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&Co.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==g_(r)&&Co.throwArgumentError("bad icap checksum","address",r),e=Uh(r.substring(4));e.length<40;)e="0"+e;e=cb("0x"+e)}else Co.throwArgumentError("invalid address","address",r);return e}var Co,l_,Bh,ub,db=Z(()=>{"use strict";Dn();Zg();Nf();Li();fb();Co=new ht(ab);l_=9007199254740991;Bh={};for(let r=0;r<10;r++)Bh[String(r)]=String(r);for(let r=0;r<26;r++)Bh[String.fromCharCode(65+r)]=String(10+r);ub=Math.floor(p_(l_))});var lb,pb=Z(()=>{lb="properties/5.7.0"});function _s(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var LN,gb=Z(()=>{"use strict";Li();pb();LN=new ht(lb)});var bb=Z(()=>{"use strict";ob()});var Fi=W((BN,mb)=>{mb.exports=vb;function vb(r,e){if(!r)throw new Error(e||"Assertion failed")}vb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var Po=W((zN,zh)=>{typeof Object.create=="function"?zh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:zh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var gr=W(He=>{"use strict";var b_=Fi(),v_=Po();He.inherits=v_;function m_(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function y_(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):m_(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}He.htonl=yb;function __(r,e){for(var t="",i=0;i>>0}return s}He.join32=x_;function E_(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}He.split32=E_;function S_(r,e){return r>>>e|r<<32-e}He.rotr32=S_;function I_(r,e){return r<>>32-e}He.rotl32=I_;function M_(r,e){return r+e>>>0}He.sum32=M_;function A_(r,e,t){return r+e+t>>>0}He.sum32_3=A_;function R_(r,e,t,i){return r+e+t+i>>>0}He.sum32_4=R_;function T_(r,e,t,i,n){return r+e+t+i+n>>>0}He.sum32_5=T_;function D_(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}He.sum64=D_;function N_(r,e,t,i){var n=e+i>>>0,s=(n>>0}He.sum64_hi=N_;function C_(r,e,t,i){var n=e+i;return n>>>0}He.sum64_lo=C_;function P_(r,e,t,i,n,s,o,f){var c=0,u=e;u=u+i>>>0,c+=u>>0,c+=u>>0,c+=u>>0}He.sum64_4_hi=P_;function O_(r,e,t,i,n,s,o,f){var c=e+i+s+f;return c>>>0}He.sum64_4_lo=O_;function L_(r,e,t,i,n,s,o,f,c,u){var b=0,y=e;y=y+i>>>0,b+=y>>0,b+=y>>0,b+=y>>0,b+=y>>0}He.sum64_5_hi=L_;function q_(r,e,t,i,n,s,o,f,c,u){var b=e+i+s+f+u;return b>>>0}He.sum64_5_lo=q_;function F_(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}He.rotr64_hi=F_;function U_(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}He.rotr64_lo=U_;function B_(r,e,t){return r>>>t}He.shr64_hi=B_;function z_(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}He.shr64_lo=z_});var xs=W(Eb=>{"use strict";var xb=gr(),k_=Fi();function Pf(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Eb.BlockHash=Pf;Pf.prototype.update=function(e,t){if(e=xb.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=xb.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var K_=gr(),Hr=K_.rotr32;function j_(r,e,t,i){if(r===0)return Sb(e,t,i);if(r===1||r===3)return Mb(e,t,i);if(r===2)return Ib(e,t,i)}vi.ft_1=j_;function Sb(r,e,t){return r&e^~r&t}vi.ch32=Sb;function Ib(r,e,t){return r&e^r&t^e&t}vi.maj32=Ib;function Mb(r,e,t){return r^e^t}vi.p32=Mb;function V_(r){return Hr(r,2)^Hr(r,13)^Hr(r,22)}vi.s0_256=V_;function $_(r){return Hr(r,6)^Hr(r,11)^Hr(r,25)}vi.s1_256=$_;function H_(r){return Hr(r,7)^Hr(r,18)^r>>>3}vi.g0_256=H_;function G_(r){return Hr(r,17)^Hr(r,19)^r>>>10}vi.g1_256=G_});var Tb=W((VN,Rb)=>{"use strict";var Es=gr(),J_=xs(),W_=kh(),Kh=Es.rotl32,Oo=Es.sum32,Y_=Es.sum32_5,X_=W_.ft_1,Ab=J_.BlockHash,Z_=[1518500249,1859775393,2400959708,3395469782];function Gr(){if(!(this instanceof Gr))return new Gr;Ab.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Es.inherits(Gr,Ab);Rb.exports=Gr;Gr.blockSize=512;Gr.outSize=160;Gr.hmacStrength=80;Gr.padLength=64;Gr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Ss=gr(),Q_=xs(),Is=kh(),ex=Fi(),br=Ss.sum32,tx=Ss.sum32_4,rx=Ss.sum32_5,ix=Is.ch32,nx=Is.maj32,sx=Is.s0_256,ox=Is.s1_256,ax=Is.g0_256,fx=Is.g1_256,Db=Q_.BlockHash,cx=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Jr(){if(!(this instanceof Jr))return new Jr;Db.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=cx,this.W=new Array(64)}Ss.inherits(Jr,Db);Nb.exports=Jr;Jr.blockSize=512;Jr.outSize=256;Jr.hmacStrength=192;Jr.padLength=64;Jr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Vh=gr(),Cb=jh();function mi(){if(!(this instanceof mi))return new mi;Cb.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Vh.inherits(mi,Cb);Pb.exports=mi;mi.blockSize=512;mi.outSize=224;mi.hmacStrength=192;mi.padLength=64;mi.prototype._digest=function(e){return e==="hex"?Vh.toHex32(this.h.slice(0,7),"big"):Vh.split32(this.h.slice(0,7),"big")}});var Gh=W((GN,Ub)=>{"use strict";var Ut=gr(),ux=xs(),hx=Fi(),Wr=Ut.rotr64_hi,Yr=Ut.rotr64_lo,Lb=Ut.shr64_hi,qb=Ut.shr64_lo,Ui=Ut.sum64,$h=Ut.sum64_hi,Hh=Ut.sum64_lo,dx=Ut.sum64_4_hi,lx=Ut.sum64_4_lo,px=Ut.sum64_5_hi,gx=Ut.sum64_5_lo,Fb=ux.BlockHash,bx=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function vr(){if(!(this instanceof vr))return new vr;Fb.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=bx,this.W=new Array(160)}Ut.inherits(vr,Fb);Ub.exports=vr;vr.blockSize=1024;vr.outSize=512;vr.hmacStrength=192;vr.padLength=128;vr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Jh=gr(),Bb=Gh();function yi(){if(!(this instanceof yi))return new yi;Bb.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Jh.inherits(yi,Bb);zb.exports=yi;yi.blockSize=1024;yi.outSize=384;yi.hmacStrength=192;yi.padLength=128;yi.prototype._digest=function(e){return e==="hex"?Jh.toHex32(this.h.slice(0,12),"big"):Jh.split32(this.h.slice(0,12),"big")}});var Kb=W(Ms=>{"use strict";Ms.sha1=Tb();Ms.sha224=Ob();Ms.sha256=jh();Ms.sha384=kb();Ms.sha512=Gh()});var Jb=W(Gb=>{"use strict";var Cn=gr(),Tx=xs(),Of=Cn.rotl32,jb=Cn.sum32,Lo=Cn.sum32_3,Vb=Cn.sum32_4,Hb=Tx.BlockHash;function Xr(){if(!(this instanceof Xr))return new Xr;Hb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Cn.inherits(Xr,Hb);Gb.ripemd160=Xr;Xr.blockSize=512;Xr.outSize=160;Xr.hmacStrength=192;Xr.padLength=64;Xr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],c=i,u=n,b=s,y=o,S=f,I=0;I<80;I++){var M=jb(Of(Vb(i,$b(I,n,s,o),e[Cx[I]+t],Dx(I)),Ox[I]),f);i=f,f=o,o=Of(s,10),s=n,n=M,M=jb(Of(Vb(c,$b(79-I,u,b,y),e[Px[I]+t],Nx(I)),Lx[I]),S),c=S,S=y,y=Of(b,10),b=u,u=M}M=Lo(this.h[1],s,y),this.h[1]=Lo(this.h[2],o,S),this.h[2]=Lo(this.h[3],f,c),this.h[3]=Lo(this.h[4],i,u),this.h[4]=Lo(this.h[0],n,b),this.h[0]=M};Xr.prototype._digest=function(e){return e==="hex"?Cn.toHex32(this.h,"little"):Cn.split32(this.h,"little")};function $b(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function Dx(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function Nx(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var Cx=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Px=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Ox=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Lx=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var Yb=W((XN,Wb)=>{"use strict";var qx=gr(),Fx=Fi();function As(r,e,t){if(!(this instanceof As))return new As(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(qx.toArray(e,t))}Wb.exports=As;As.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),Fx(e.length<=this.blockSize);for(var t=e.length;t{var yt=Xb;yt.utils=gr();yt.common=xs();yt.sha=Kb();yt.ripemd=Jb();yt.hmac=Yb();yt.sha1=yt.sha.sha1;yt.sha256=yt.sha.sha256;yt.sha224=yt.sha.sha224;yt.sha384=yt.sha.sha384;yt.sha512=yt.sha.sha512;yt.ripemd160=yt.ripemd.ripemd160});function Rs(r,e,t){return t={path:e,exports:{},require:function(i,n){return Ux(i,n??t.path)}},r(t,t.exports),t.exports}function Ux(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}function Qb(r,e){if(!r)throw new Error(e||"Assertion failed")}function zi(r,e){this.type=r,this.p=new Oe.default(e.p,16),this.red=e.prime?Oe.default.red(e.prime):Oe.default.mont(this.p),this.zero=new Oe.default(0).toRed(this.red),this.one=new Oe.default(1).toRed(this.red),this.two=new Oe.default(2).toRed(this.red),this.n=e.n&&new Oe.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function tr(r,e){this.curve=r,this.type=e,this.precomputed=null}function rr(r){Pn.call(this,"short",r),this.a=new Oe.default(r.a,16).toRed(this.red),this.b=new Oe.default(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function dt(r,e,t,i){Pn.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Oe.default(e,16),this.y=new Oe.default(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function wt(r,e,t,i){Pn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Oe.default(0)):(this.x=new Oe.default(e,16),this.y=new Oe.default(t,16),this.z=new Oe.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}function Bi(r){if(!(this instanceof Bi))return new Bi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=mr.toArray(r.entropy,r.entropyEnc||"hex"),t=mr.toArray(r.nonce,r.nonceEnc||"hex"),i=mr.toArray(r.pers,r.persEnc||"hex");Zh(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}function At(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}function Bf(r,e){if(r instanceof Bf)return r;this._importDER(r,e)||(Kx(r.r&&r.s,"Signature without r or s"),this.r=new Oe.default(r.r,16),this.s=new Oe.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}function jx(){this.place=0}function Wh(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Zb(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}function er(r){if(!(this instanceof er))return new er(r);typeof r=="string"&&(tv(Object.prototype.hasOwnProperty.call(qf,r),"Unknown curve "+r),r=qf[r]),r instanceof qf.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var Oe,Zr,Zh,mr,Kt,Ff,Bx,Uf,Pn,Qh,zx,kx,Lf,qf,ev,Xh,ed,Kx,zf,Vx,tv,$x,Hx,rv,iv=Z(()=>{Oe=Ue(Fh()),Zr=Ue(qo());Zh=Qb;Qb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};mr=Rs(function(r,e){"use strict";var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var c=[];if(typeof o!="string"){for(var u=0;u>8,S=b&255;y?c.push(y,S):c.push(S)}return c}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",c=0;c(S>>1)-1?T=(S>>1)-O:T=O,I.isubn(T)):T=0,y[M]=T,I.iushrn(1)}return y}t.getNAF=i;function n(c,u){var b=[[],[]];c=c.clone(),u=u.clone();for(var y=0,S=0,I;c.cmpn(-y)>0||u.cmpn(-S)>0;){var M=c.andln(3)+y&3,T=u.andln(3)+S&3;M===3&&(M=-1),T===3&&(T=-1);var O;M&1?(I=c.andln(7)+y&7,(I===3||I===5)&&T===2?O=-M:O=M):O=0,b[0].push(O);var N;T&1?(I=u.andln(7)+S&7,(I===3||I===5)&&M===2?N=-T:N=T):N=0,b[1].push(N),2*y===O+1&&(y=1-y),2*S===N+1&&(S=1-S),c.iushrn(1),u.iushrn(1)}return b}t.getJSF=n;function s(c,u,b){var y="_"+u;c.prototype[u]=function(){return this[y]!==void 0?this[y]:this[y]=b.call(this)}}t.cachedProperty=s;function o(c){return typeof c=="string"?t.toArray(c,"hex"):c}t.parseBytes=o;function f(c){return new Oe.default(c,"hex","le")}t.intFromLE=f}),Ff=Kt.getNAF,Bx=Kt.getJSF,Uf=Kt.assert;Pn=zi;zi.prototype.point=function(){throw new Error("Not implemented")};zi.prototype.validate=function(){throw new Error("Not implemented")};zi.prototype._fixedNafMul=function(e,t){Uf(e.precomputed);var i=e._getDoubles(),n=Ff(t,1,this._bitLength),s=(1<=f;u--)c=(c<<1)+n[u];o.push(c)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;c--){for(var u=0;c>=0&&o[c]===0;c--)u++;if(c>=0&&u++,f=f.dblp(u),c<0)break;var b=o[c];Uf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};zi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,c=this._wnafT3,u=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){c[M]=Ff(i[M],o[M],this._bitLength),c[T]=Ff(i[T],o[T],this._bitLength),u=Math.max(c[M].length,u),u=Math.max(c[T].length,u);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],B=Bx(i[M],i[T]);for(u=Math.max(B[0].length,u),c[M]=new Array(u),c[T]=new Array(u),y=0;y=0;b--){for(var L=0;b>=0;){var P=!0;for(y=0;y=0&&L++,k=k.dblp(L),b<0)break;for(y=0;y0?S=f[y][J-1>>1]:J<0&&(S=f[y][-J-1>>1].neg()),S.type==="affine"?k=k.mixedAdd(S):k=k.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};tr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=u,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};rr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),c=o.mul(n.a),u=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(c),S=u.add(b).neg();return{k1:y,k2:S}};rr.prototype.pointFromX=function(e,t){e=new Oe.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};rr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};rr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};dt.prototype.isInfinity=function(){return this.inf};dt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};dt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};dt.prototype.getX=function(){return this.x.fromRed()};dt.prototype.getY=function(){return this.y.fromRed()};dt.prototype.mul=function(e){return e=new Oe.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};dt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};dt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};dt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};dt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};dt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};Qh(wt,Pn.BasePoint);rr.prototype.jpoint=function(e,t,i){return new wt(this,e,t,i)};wt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};wt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};wt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),u=o.redSub(f);if(c.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=c.redSqr(),y=b.redMul(c),S=n.redMul(b),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),M=u.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,M,T)};wt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),c=s.redSub(o);if(f.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=f.redSqr(),b=u.redMul(f),y=i.redMul(u),S=c.redSqr().redIAdd(b).redISub(y).redISub(y),I=c.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};wt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};wt.prototype.inspect=function(){return this.isInfinity()?"":""};wt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};Lf=Rs(function(r,e){"use strict";var t=e;t.base=Pn,t.short=kx,t.mont=null,t.edwards=null}),qf=Rs(function(r,e){"use strict";var t=e,i=Kt.assert;function n(f){f.type==="short"?this.curve=new Lf.short(f):f.type==="edwards"?this.curve=new Lf.edwards(f):this.curve=new Lf.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,c){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var u=new n(c);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:u}),u}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Zr.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Zr.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Zr.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Zr.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Zr.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zr.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zr.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Zr.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});ev=Bi;Bi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Bi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=mr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};Kx=Kt.assert;zf=Bf;Bf.prototype._importDER=function(e,t){e=Kt.toArray(e,t);var i=new jx;if(e[i.place++]!==48)return!1;var n=Wh(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Wh(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var f=Wh(e,i);if(f===!1||e.length!==f+i.place)return!1;var c=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new Oe.default(o),this.s=new Oe.default(c),this.recoveryParam=null,!0};Bf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Zb(t),i=Zb(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Yh(n,t.length),n=n.concat(t),n.push(2),Yh(n,i.length);var s=n.concat(i),o=[48];return Yh(o,s.length),o=o.concat(s),Kt.encode(o,e)};Vx=function(){throw new Error("unsupported")},tv=Kt.assert;$x=er;er.prototype.keyPair=function(e){return new ed(this,e)};er.prototype.keyFromPrivate=function(e,t){return ed.fromPrivate(this,e,t)};er.prototype.keyFromPublic=function(e,t){return ed.fromPublic(this,e,t)};er.prototype.genKeyPair=function(e){e||(e={});for(var t=new ev({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Vx(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Oe.default(2));;){var s=new Oe.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};er.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};er.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Oe.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),c=new ev({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Oe.default(1)),b=0;;b++){var y=n.k?n.k(b):new Oe.default(c.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new zf({r:M,s:T,recoveryParam:O})}}}}}};er.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Oe.default(e,16)),i=this.keyFromPublic(i,n),t=new zf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),c=f.mul(e).umod(this.n),u=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};er.prototype.recoverPubKey=function(r,e,t,i){tv((3&t)===t,"The recovery param is more than two bits"),e=new zf(e,i);var n=this.n,s=new Oe.default(r),o=e.r,f=e.s,c=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};er.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new zf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};Hx=Rs(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=Kt,t.rand=function(){throw new Error("unsupported")},t.curve=Lf,t.curves=qf,t.ec=$x,t.eddsa=null}),rv=Hx.ec});var nv,sv=Z(()=>{nv="signing-key/5.7.0"});function Qr(){return td||(td=new rv("secp256k1")),td}function ov(r,e){let t=Df(e),i={r:Xe(t.r),s:Xe(t.s)};return"0x"+Qr().recoverPubKey(Xe(r),i,t.recoveryParam).encode("hex",!1)}function nd(r,e){let t=Xe(r);if(t.length===32){let i=new id(t);return e?"0x"+Qr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Mt(t):"0x"+Qr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Qr().keyFromPublic(t).getPublic(!0,"hex"):Mt(t)}return rd.throwArgumentError("invalid public or private key","key","[REDACTED]")}var rd,td,id,av=Z(()=>{"use strict";iv();Dn();gb();Li();sv();rd=new ht(nv),td=null;id=class{constructor(e){_s(this,"curve","secp256k1"),_s(this,"privateKey",Mt(e)),Rf(this.privateKey)!==32&&rd.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Qr().keyFromPrivate(Xe(this.privateKey));_s(this,"publicKey","0x"+t.getPublic(!1,"hex")),_s(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),_s(this,"_isSigningKey",!0)}_addPoint(e){let t=Qr().keyFromPublic(Xe(this.publicKey)),i=Qr().keyFromPublic(Xe(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=Qr().keyFromPrivate(Xe(this.privateKey)),i=Xe(e);i.length!==32&&rd.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return Df({recoveryParam:n.recoveryParam,r:qi("0x"+n.r.toString(16),32),s:qi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=Qr().keyFromPrivate(Xe(this.privateKey)),i=Qr().keyFromPublic(Xe(nd(e)));return qi("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}});var fv,cv=Z(()=>{fv="transactions/5.7.0"});function Gx(r){let e=nd(r);return hb(Tf(ws(Tf(e,1)),12))}function hv(r,e){return Gx(ov(Xe(r),e))}var gC,uv,dv=Z(()=>{"use strict";db();Dn();Nf();av();Li();cv();gC=new ht(fv);(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(uv||(uv={}))});var pv=W(kf=>{"use strict";Object.defineProperty(kf,"__esModule",{value:!0});var Rt=fs(),sd=Qt(),Jx=20;function Wx(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],c=t[7]<<24|t[6]<<16|t[5]<<8|t[4],u=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],N=e[11]<<24|e[10]<<16|e[9]<<8|e[8],B=e[15]<<24|e[14]<<16|e[13]<<8|e[12],z=i,F=n,k=s,V=o,L=f,P=c,J=u,D=b,l=y,w=S,p=I,a=M,d=T,v=O,_=N,m=B,h=0;h>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,F=F+P|0,v^=F,v=v>>>16|v<<16,w=w+v|0,P^=w,P=P>>>20|P<<12,k=k+J|0,_^=k,_=_>>>16|_<<16,p=p+_|0,J^=p,J=J>>>20|J<<12,V=V+D|0,m^=V,m=m>>>16|m<<16,a=a+m|0,D^=a,D=D>>>20|D<<12,k=k+J|0,_^=k,_=_>>>24|_<<8,p=p+_|0,J^=p,J=J>>>25|J<<7,V=V+D|0,m^=V,m=m>>>24|m<<8,a=a+m|0,D^=a,D=D>>>25|D<<7,F=F+P|0,v^=F,v=v>>>24|v<<8,w=w+v|0,P^=w,P=P>>>25|P<<7,z=z+L|0,d^=z,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,z=z+P|0,m^=z,m=m>>>16|m<<16,p=p+m|0,P^=p,P=P>>>20|P<<12,F=F+J|0,d^=F,d=d>>>16|d<<16,a=a+d|0,J^=a,J=J>>>20|J<<12,k=k+D|0,v^=k,v=v>>>16|v<<16,l=l+v|0,D^=l,D=D>>>20|D<<12,V=V+L|0,_^=V,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,k=k+D|0,v^=k,v=v>>>24|v<<8,l=l+v|0,D^=l,D=D>>>25|D<<7,V=V+L|0,_^=V,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,F=F+J|0,d^=F,d=d>>>24|d<<8,a=a+d|0,J^=a,J=J>>>25|J<<7,z=z+P|0,m^=z,m=m>>>24|m<<8,p=p+m|0,P^=p,P=P>>>25|P<<7;Rt.writeUint32LE(z+i|0,r,0),Rt.writeUint32LE(F+n|0,r,4),Rt.writeUint32LE(k+s|0,r,8),Rt.writeUint32LE(V+o|0,r,12),Rt.writeUint32LE(L+f|0,r,16),Rt.writeUint32LE(P+c|0,r,20),Rt.writeUint32LE(J+u|0,r,24),Rt.writeUint32LE(D+b|0,r,28),Rt.writeUint32LE(l+y|0,r,32),Rt.writeUint32LE(w+S|0,r,36),Rt.writeUint32LE(p+I|0,r,40),Rt.writeUint32LE(a+M|0,r,44),Rt.writeUint32LE(d+T|0,r,48),Rt.writeUint32LE(v+O|0,r,52),Rt.writeUint32LE(_+N|0,r,56),Rt.writeUint32LE(m+B|0,r,60)}function lv(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var Kf=W(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});function Zx(r,e,t){return~(r-1)&e|r-1&t}Ts.select=Zx;function Qx(r,e){return(r|0)-(e|0)-1>>>31&1}Ts.lessOrEqual=Qx;function gv(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Ts.compare=gv;function eE(r,e){return r.length===0||e.length===0?!1:gv(r,e)!==0}Ts.equal=eE});var vv=W(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});var tE=Kf(),jf=Qt();wi.DIGEST_LENGTH=16;var bv=function(){function r(e){this.digestLength=wi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var c=e[12]|e[13]<<8;this._r[7]=(f>>>11|c<<5)&8065;var u=e[14]|e[15]<<8;this._r[8]=(c>>>8|u<<8)&8191,this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],c=this._h[3],u=this._h[4],b=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],O=this._r[1],N=this._r[2],B=this._r[3],z=this._r[4],F=this._r[5],k=this._r[6],V=this._r[7],L=this._r[8],P=this._r[9];i>=16;){var J=e[t+0]|e[t+1]<<8;s+=J&8191;var D=e[t+2]|e[t+3]<<8;o+=(J>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;c+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;u+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;y+=(p>>>14|a<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(a>>>11|d<<5)&8191;var v=e[t+14]|e[t+15]<<8;I+=(d>>>8|v<<8)&8191,M+=v>>>5|n;var _=0,m=_;m+=s*T,m+=o*(5*P),m+=f*(5*L),m+=c*(5*V),m+=u*(5*k),_=m>>>13,m&=8191,m+=b*(5*F),m+=y*(5*z),m+=S*(5*B),m+=I*(5*N),m+=M*(5*O),_+=m>>>13,m&=8191;var h=_;h+=s*O,h+=o*T,h+=f*(5*P),h+=c*(5*L),h+=u*(5*V),_=h>>>13,h&=8191,h+=b*(5*k),h+=y*(5*F),h+=S*(5*z),h+=I*(5*B),h+=M*(5*N),_+=h>>>13,h&=8191;var x=_;x+=s*N,x+=o*O,x+=f*T,x+=c*(5*P),x+=u*(5*L),_=x>>>13,x&=8191,x+=b*(5*V),x+=y*(5*k),x+=S*(5*F),x+=I*(5*z),x+=M*(5*B),_+=x>>>13,x&=8191;var A=_;A+=s*B,A+=o*N,A+=f*O,A+=c*T,A+=u*(5*P),_=A>>>13,A&=8191,A+=b*(5*L),A+=y*(5*V),A+=S*(5*k),A+=I*(5*F),A+=M*(5*z),_+=A>>>13,A&=8191;var g=_;g+=s*z,g+=o*B,g+=f*N,g+=c*O,g+=u*T,_=g>>>13,g&=8191,g+=b*(5*P),g+=y*(5*L),g+=S*(5*V),g+=I*(5*k),g+=M*(5*F),_+=g>>>13,g&=8191;var R=_;R+=s*F,R+=o*z,R+=f*B,R+=c*N,R+=u*O,_=R>>>13,R&=8191,R+=b*T,R+=y*(5*P),R+=S*(5*L),R+=I*(5*V),R+=M*(5*k),_+=R>>>13,R&=8191;var K=_;K+=s*k,K+=o*F,K+=f*z,K+=c*B,K+=u*N,_=K>>>13,K&=8191,K+=b*O,K+=y*T,K+=S*(5*P),K+=I*(5*L),K+=M*(5*V),_+=K>>>13,K&=8191;var E=_;E+=s*V,E+=o*k,E+=f*F,E+=c*z,E+=u*B,_=E>>>13,E&=8191,E+=b*N,E+=y*O,E+=S*T,E+=I*(5*P),E+=M*(5*L),_+=E>>>13,E&=8191;var C=_;C+=s*L,C+=o*V,C+=f*k,C+=c*F,C+=u*z,_=C>>>13,C&=8191,C+=b*B,C+=y*N,C+=S*O,C+=I*T,C+=M*(5*P),_+=C>>>13,C&=8191;var q=_;q+=s*P,q+=o*L,q+=f*V,q+=c*k,q+=u*F,_=q>>>13,q&=8191,q+=b*z,q+=y*B,q+=S*N,q+=I*O,q+=M*T,_+=q>>>13,q&=8191,_=(_<<2)+_|0,_=_+m|0,m=_&8191,_=_>>>13,h+=_,s=m,o=h,f=x,c=A,u=g,b=R,y=K,S=E,I=C,M=q,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=c,this._h[4]=u,this._h[5]=b,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});var Vf=pv(),nE=vv(),Fo=Qt(),mv=fs(),sE=Kf();_i.KEY_LENGTH=32;_i.NONCE_LENGTH=12;_i.TAG_LENGTH=16;var yv=new Uint8Array(16),oE=function(){function r(e){if(this.nonceLength=_i.NONCE_LENGTH,this.tagLength=_i.TAG_LENGTH,e.length!==_i.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);Vf.stream(this._key,s,o,4);var f=t.length+this.tagLength,c;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");c=n}else c=new Uint8Array(f);return Vf.streamXOR(this._key,s,t,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),o,c.subarray(0,c.length-this.tagLength),i),Fo.wipe(s),c},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(yv.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(yv.subarray(i.length%16));var o=new Uint8Array(8);n&&mv.writeUint64LE(n.length,o),s.update(o),mv.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),c=0;c{"use strict";Object.defineProperty(od,"__esModule",{value:!0});function aE(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}od.isSerializableHash=aE});var Ev=W(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});var ei=_v(),fE=Kf(),cE=Qt(),xv=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});var Sv=Ev(),Iv=Qt(),hE=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Sv.hmac(this._hash,i,t);this._hmac=new Sv.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});var Hf=fs(),$f=Qt();ki.DIGEST_LENGTH=32;ki.BLOCK_SIZE=64;var Av=function(){function r(){this.digestLength=ki.DIGEST_LENGTH,this.blockSize=ki.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){$f.wipe(this._buffer),$f.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(fd(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=fd(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){$f.wipe(e.state),e.buffer&&$f.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();ki.SHA256=Av;var dE=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function fd(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],c=e[3],u=e[4],b=e[5],y=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=Hf.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],O=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var N=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(O+r[I-7]|0)+(N+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&b^~u&y)|0)+(S+(dE[I]+r[I]|0)|0)|0,N=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=y,y=b,b=u,u=c+O|0,c=f,f=o,o=s,s=O+N|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=c,e[4]+=u,e[5]+=b,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function lE(r){var e=new Av;e.update(r);var t=e.digest();return e.clean(),t}ki.hash=lE});var Cv=W(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.sharedKey=rt.generateKeyPair=rt.generateKeyPairFromSeed=rt.scalarMultBase=rt.scalarMult=rt.SHARED_KEY_LENGTH=rt.SECRET_KEY_LENGTH=rt.PUBLIC_KEY_LENGTH=void 0;var pE=mo(),gE=Qt();rt.PUBLIC_KEY_LENGTH=32;rt.SECRET_KEY_LENGTH=32;rt.SHARED_KEY_LENGTH=32;function ti(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,Bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function mE(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Gf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function Jf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function xi(r,e,t){let i,n,s=0,o=0,f=0,c=0,u=0,b=0,y=0,S=0,I=0,M=0,T=0,O=0,N=0,B=0,z=0,F=0,k=0,V=0,L=0,P=0,J=0,D=0,l=0,w=0,p=0,a=0,d=0,v=0,_=0,m=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],K=t[4],E=t[5],C=t[6],q=t[7],U=t[8],j=t[9],Y=t[10],H=t[11],$=t[12],te=t[13],G=t[14],X=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,c+=i*R,u+=i*K,b+=i*E,y+=i*C,S+=i*q,I+=i*U,M+=i*j,T+=i*Y,O+=i*H,N+=i*$,B+=i*te,z+=i*G,F+=i*X,i=e[1],o+=i*x,f+=i*A,c+=i*g,u+=i*R,b+=i*K,y+=i*E,S+=i*C,I+=i*q,M+=i*U,T+=i*j,O+=i*Y,N+=i*H,B+=i*$,z+=i*te,F+=i*G,k+=i*X,i=e[2],f+=i*x,c+=i*A,u+=i*g,b+=i*R,y+=i*K,S+=i*E,I+=i*C,M+=i*q,T+=i*U,O+=i*j,N+=i*Y,B+=i*H,z+=i*$,F+=i*te,k+=i*G,V+=i*X,i=e[3],c+=i*x,u+=i*A,b+=i*g,y+=i*R,S+=i*K,I+=i*E,M+=i*C,T+=i*q,O+=i*U,N+=i*j,B+=i*Y,z+=i*H,F+=i*$,k+=i*te,V+=i*G,L+=i*X,i=e[4],u+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*K,M+=i*E,T+=i*C,O+=i*q,N+=i*U,B+=i*j,z+=i*Y,F+=i*H,k+=i*$,V+=i*te,L+=i*G,P+=i*X,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*K,T+=i*E,O+=i*C,N+=i*q,B+=i*U,z+=i*j,F+=i*Y,k+=i*H,V+=i*$,L+=i*te,P+=i*G,J+=i*X,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*K,O+=i*E,N+=i*C,B+=i*q,z+=i*U,F+=i*j,k+=i*Y,V+=i*H,L+=i*$,P+=i*te,J+=i*G,D+=i*X,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*K,N+=i*E,B+=i*C,z+=i*q,F+=i*U,k+=i*j,V+=i*Y,L+=i*H,P+=i*$,J+=i*te,D+=i*G,l+=i*X,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,N+=i*K,B+=i*E,z+=i*C,F+=i*q,k+=i*U,V+=i*j,L+=i*Y,P+=i*H,J+=i*$,D+=i*te,l+=i*G,w+=i*X,i=e[9],M+=i*x,T+=i*A,O+=i*g,N+=i*R,B+=i*K,z+=i*E,F+=i*C,k+=i*q,V+=i*U,L+=i*j,P+=i*Y,J+=i*H,D+=i*$,l+=i*te,w+=i*G,p+=i*X,i=e[10],T+=i*x,O+=i*A,N+=i*g,B+=i*R,z+=i*K,F+=i*E,k+=i*C,V+=i*q,L+=i*U,P+=i*j,J+=i*Y,D+=i*H,l+=i*$,w+=i*te,p+=i*G,a+=i*X,i=e[11],O+=i*x,N+=i*A,B+=i*g,z+=i*R,F+=i*K,k+=i*E,V+=i*C,L+=i*q,P+=i*U,J+=i*j,D+=i*Y,l+=i*H,w+=i*$,p+=i*te,a+=i*G,d+=i*X,i=e[12],N+=i*x,B+=i*A,z+=i*g,F+=i*R,k+=i*K,V+=i*E,L+=i*C,P+=i*q,J+=i*U,D+=i*j,l+=i*Y,w+=i*H,p+=i*$,a+=i*te,d+=i*G,v+=i*X,i=e[13],B+=i*x,z+=i*A,F+=i*g,k+=i*R,V+=i*K,L+=i*E,P+=i*C,J+=i*q,D+=i*U,l+=i*j,w+=i*Y,p+=i*H,a+=i*$,d+=i*te,v+=i*G,_+=i*X,i=e[14],z+=i*x,F+=i*A,k+=i*g,V+=i*R,L+=i*K,P+=i*E,J+=i*C,D+=i*q,l+=i*U,w+=i*j,p+=i*Y,a+=i*H,d+=i*$,v+=i*te,_+=i*G,m+=i*X,i=e[15],F+=i*x,k+=i*A,V+=i*g,L+=i*R,P+=i*K,J+=i*E,D+=i*C,l+=i*q,w+=i*U,p+=i*j,a+=i*Y,d+=i*H,v+=i*$,_+=i*te,m+=i*G,h+=i*X,s+=38*k,o+=38*V,f+=38*L,c+=38*P,u+=38*J,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*v,N+=38*_,B+=38*m,z+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=c,r[4]=u,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=N,r[13]=B,r[14]=z,r[15]=F}function zo(r,e){xi(r,e,e)}function yE(r,e){let t=ti();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)zo(t,t),i!==2&&i!==4&&xi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function ud(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=ti(),s=ti(),o=ti(),f=ti(),c=ti(),u=ti();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,mE(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;Bo(n,s,M),Bo(o,f,M),Gf(c,n,o),Jf(n,n,o),Gf(o,s,f),Jf(s,s,f),zo(f,c),zo(u,n),xi(n,o,n),xi(o,s,c),Gf(c,n,o),Jf(n,n,o),zo(s,n),Jf(o,f,u),xi(n,o,bE),Gf(n,n,f),xi(o,o,n),xi(n,f,u),xi(f,s,i),zo(s,c),Bo(n,s,M),Bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),y=i.subarray(16);yE(b,b),xi(y,y,b);let S=new Uint8Array(32);return vE(S,y),S}rt.scalarMult=ud;function Dv(r){return ud(r,Tv)}rt.scalarMultBase=Dv;function Nv(r){if(r.length!==rt.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${rt.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:Dv(e),secretKey:e}}rt.generateKeyPairFromSeed=Nv;function wE(r){let e=(0,pE.randomBytes)(32,r),t=Nv(e);return(0,gE.wipe)(e),t}rt.generateKeyPair=wE;function _E(r,e,t=!1){if(r.length!==rt.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==rt.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=ud(r,e);if(t){let n=0;for(let s=0;s{});var Ov=Z(()=>{});var Lv=Z(()=>{pf()});var hd=Z(()=>{Pv();Zu();Ov();Ih();Sh();Lv()});var qv=W((zC,xE)=>{xE.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var ri=W((Fv,dd)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Lh().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)v=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[d]|=v<<_&67108863,this.words[d+1]=v>>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);else if(p==="le")for(a=0,d=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(d-=18,v+=1,this.words[v]|=_>>>26):d+=8;else{var m=l.length-w;for(a=m%2===0?w+1:w;a=18?(d-=18,v+=1,this.words[v]|=_>>>26):d+=8}this.strip()};function c(D,l,w,p){for(var a=0,d=Math.min(D.length,w),v=l;v=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=w)a++;a--,d=d/w|0;for(var v=l.length-p,_=v%a,m=Math.min(v,v-_)+p,h=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,d=0,v=0;v>>24-a&16777215,d!==0||v!==this.length-1?p=u[6-m.length]+m+p:p=m+p,a+=2,a>=26&&(a-=26,v--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=b[l],x=y[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=u[h-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),d=p||Math.max(1,a);t(a<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var v=w==="le",_=new l(d),m,h,x=this.clone();if(v){for(h=0;!x.isZero();h++)m=x.andln(255),x.iushrn(8),_[h]=m;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var d=0,v=0;v>>26;for(;d!==0&&v>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;vl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;p>0?(a=this,d=l):(a=l,d=this);for(var v=0,_=0;_>26,this.words[_]=w&67108863;for(;v!==0&&_>26,this.words[_]=w&67108863;if(v===0&&_>>26,A=m&67108863,g=Math.min(h,l.length-1),R=Math.max(0,h-D.length+1);R<=g;R++){var K=h-R|0;a=D.words[K]|0,d=l.words[R]|0,v=a*d+A,x+=v/67108864|0,A=v&67108863}w.words[h]=A|0,m=x|0}return m!==0?w.words[h]=m|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,d=w.words,v=p.words,_=0,m,h,x,A=a[0]|0,g=A&8191,R=A>>>13,K=a[1]|0,E=K&8191,C=K>>>13,q=a[2]|0,U=q&8191,j=q>>>13,Y=a[3]|0,H=Y&8191,$=Y>>>13,te=a[4]|0,G=te&8191,X=te>>>13,Rr=a[5]|0,ne=Rr&8191,se=Rr>>>13,Tr=a[6]|0,oe=Tr&8191,ae=Tr>>>13,Dr=a[7]|0,fe=Dr&8191,ce=Dr>>>13,Nr=a[8]|0,ue=Nr&8191,he=Nr>>>13,Cr=a[9]|0,de=Cr&8191,le=Cr>>>13,Pr=d[0]|0,pe=Pr&8191,ge=Pr>>>13,Or=d[1]|0,be=Or&8191,ve=Or>>>13,Lr=d[2]|0,me=Lr&8191,ye=Lr>>>13,qr=d[3]|0,we=qr&8191,_e=qr>>>13,Fr=d[4]|0,xe=Fr&8191,Ee=Fr>>>13,Ur=d[5]|0,Se=Ur&8191,Ie=Ur>>>13,Br=d[6]|0,Me=Br&8191,Ae=Br>>>13,zr=d[7]|0,Re=zr&8191,Te=zr>>>13,kr=d[8]|0,De=kr&8191,Ne=kr>>>13,Kr=d[9]|0,Ce=Kr&8191,Pe=Kr>>>13;p.negative=l.negative^w.negative,p.length=19,m=Math.imul(g,pe),h=Math.imul(g,ge),h=h+Math.imul(R,pe)|0,x=Math.imul(R,ge);var ur=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ur>>>26)|0,ur&=67108863,m=Math.imul(E,pe),h=Math.imul(E,ge),h=h+Math.imul(C,pe)|0,x=Math.imul(C,ge),m=m+Math.imul(g,be)|0,h=h+Math.imul(g,ve)|0,h=h+Math.imul(R,be)|0,x=x+Math.imul(R,ve)|0;var Ke=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,m=Math.imul(U,pe),h=Math.imul(U,ge),h=h+Math.imul(j,pe)|0,x=Math.imul(j,ge),m=m+Math.imul(E,be)|0,h=h+Math.imul(E,ve)|0,h=h+Math.imul(C,be)|0,x=x+Math.imul(C,ve)|0,m=m+Math.imul(g,me)|0,h=h+Math.imul(g,ye)|0,h=h+Math.imul(R,me)|0,x=x+Math.imul(R,ye)|0;var je=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(je>>>26)|0,je&=67108863,m=Math.imul(H,pe),h=Math.imul(H,ge),h=h+Math.imul($,pe)|0,x=Math.imul($,ge),m=m+Math.imul(U,be)|0,h=h+Math.imul(U,ve)|0,h=h+Math.imul(j,be)|0,x=x+Math.imul(j,ve)|0,m=m+Math.imul(E,me)|0,h=h+Math.imul(E,ye)|0,h=h+Math.imul(C,me)|0,x=x+Math.imul(C,ye)|0,m=m+Math.imul(g,we)|0,h=h+Math.imul(g,_e)|0,h=h+Math.imul(R,we)|0,x=x+Math.imul(R,_e)|0;var Gt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,m=Math.imul(G,pe),h=Math.imul(G,ge),h=h+Math.imul(X,pe)|0,x=Math.imul(X,ge),m=m+Math.imul(H,be)|0,h=h+Math.imul(H,ve)|0,h=h+Math.imul($,be)|0,x=x+Math.imul($,ve)|0,m=m+Math.imul(U,me)|0,h=h+Math.imul(U,ye)|0,h=h+Math.imul(j,me)|0,x=x+Math.imul(j,ye)|0,m=m+Math.imul(E,we)|0,h=h+Math.imul(E,_e)|0,h=h+Math.imul(C,we)|0,x=x+Math.imul(C,_e)|0,m=m+Math.imul(g,xe)|0,h=h+Math.imul(g,Ee)|0,h=h+Math.imul(R,xe)|0,x=x+Math.imul(R,Ee)|0;var Jt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,m=Math.imul(ne,pe),h=Math.imul(ne,ge),h=h+Math.imul(se,pe)|0,x=Math.imul(se,ge),m=m+Math.imul(G,be)|0,h=h+Math.imul(G,ve)|0,h=h+Math.imul(X,be)|0,x=x+Math.imul(X,ve)|0,m=m+Math.imul(H,me)|0,h=h+Math.imul(H,ye)|0,h=h+Math.imul($,me)|0,x=x+Math.imul($,ye)|0,m=m+Math.imul(U,we)|0,h=h+Math.imul(U,_e)|0,h=h+Math.imul(j,we)|0,x=x+Math.imul(j,_e)|0,m=m+Math.imul(E,xe)|0,h=h+Math.imul(E,Ee)|0,h=h+Math.imul(C,xe)|0,x=x+Math.imul(C,Ee)|0,m=m+Math.imul(g,Se)|0,h=h+Math.imul(g,Ie)|0,h=h+Math.imul(R,Se)|0,x=x+Math.imul(R,Ie)|0;var Wt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,m=Math.imul(oe,pe),h=Math.imul(oe,ge),h=h+Math.imul(ae,pe)|0,x=Math.imul(ae,ge),m=m+Math.imul(ne,be)|0,h=h+Math.imul(ne,ve)|0,h=h+Math.imul(se,be)|0,x=x+Math.imul(se,ve)|0,m=m+Math.imul(G,me)|0,h=h+Math.imul(G,ye)|0,h=h+Math.imul(X,me)|0,x=x+Math.imul(X,ye)|0,m=m+Math.imul(H,we)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul($,we)|0,x=x+Math.imul($,_e)|0,m=m+Math.imul(U,xe)|0,h=h+Math.imul(U,Ee)|0,h=h+Math.imul(j,xe)|0,x=x+Math.imul(j,Ee)|0,m=m+Math.imul(E,Se)|0,h=h+Math.imul(E,Ie)|0,h=h+Math.imul(C,Se)|0,x=x+Math.imul(C,Ie)|0,m=m+Math.imul(g,Me)|0,h=h+Math.imul(g,Ae)|0,h=h+Math.imul(R,Me)|0,x=x+Math.imul(R,Ae)|0;var Yt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,m=Math.imul(fe,pe),h=Math.imul(fe,ge),h=h+Math.imul(ce,pe)|0,x=Math.imul(ce,ge),m=m+Math.imul(oe,be)|0,h=h+Math.imul(oe,ve)|0,h=h+Math.imul(ae,be)|0,x=x+Math.imul(ae,ve)|0,m=m+Math.imul(ne,me)|0,h=h+Math.imul(ne,ye)|0,h=h+Math.imul(se,me)|0,x=x+Math.imul(se,ye)|0,m=m+Math.imul(G,we)|0,h=h+Math.imul(G,_e)|0,h=h+Math.imul(X,we)|0,x=x+Math.imul(X,_e)|0,m=m+Math.imul(H,xe)|0,h=h+Math.imul(H,Ee)|0,h=h+Math.imul($,xe)|0,x=x+Math.imul($,Ee)|0,m=m+Math.imul(U,Se)|0,h=h+Math.imul(U,Ie)|0,h=h+Math.imul(j,Se)|0,x=x+Math.imul(j,Ie)|0,m=m+Math.imul(E,Me)|0,h=h+Math.imul(E,Ae)|0,h=h+Math.imul(C,Me)|0,x=x+Math.imul(C,Ae)|0,m=m+Math.imul(g,Re)|0,h=h+Math.imul(g,Te)|0,h=h+Math.imul(R,Re)|0,x=x+Math.imul(R,Te)|0;var Xt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,m=Math.imul(ue,pe),h=Math.imul(ue,ge),h=h+Math.imul(he,pe)|0,x=Math.imul(he,ge),m=m+Math.imul(fe,be)|0,h=h+Math.imul(fe,ve)|0,h=h+Math.imul(ce,be)|0,x=x+Math.imul(ce,ve)|0,m=m+Math.imul(oe,me)|0,h=h+Math.imul(oe,ye)|0,h=h+Math.imul(ae,me)|0,x=x+Math.imul(ae,ye)|0,m=m+Math.imul(ne,we)|0,h=h+Math.imul(ne,_e)|0,h=h+Math.imul(se,we)|0,x=x+Math.imul(se,_e)|0,m=m+Math.imul(G,xe)|0,h=h+Math.imul(G,Ee)|0,h=h+Math.imul(X,xe)|0,x=x+Math.imul(X,Ee)|0,m=m+Math.imul(H,Se)|0,h=h+Math.imul(H,Ie)|0,h=h+Math.imul($,Se)|0,x=x+Math.imul($,Ie)|0,m=m+Math.imul(U,Me)|0,h=h+Math.imul(U,Ae)|0,h=h+Math.imul(j,Me)|0,x=x+Math.imul(j,Ae)|0,m=m+Math.imul(E,Re)|0,h=h+Math.imul(E,Te)|0,h=h+Math.imul(C,Re)|0,x=x+Math.imul(C,Te)|0,m=m+Math.imul(g,De)|0,h=h+Math.imul(g,Ne)|0,h=h+Math.imul(R,De)|0,x=x+Math.imul(R,Ne)|0;var un=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(un>>>26)|0,un&=67108863,m=Math.imul(de,pe),h=Math.imul(de,ge),h=h+Math.imul(le,pe)|0,x=Math.imul(le,ge),m=m+Math.imul(ue,be)|0,h=h+Math.imul(ue,ve)|0,h=h+Math.imul(he,be)|0,x=x+Math.imul(he,ve)|0,m=m+Math.imul(fe,me)|0,h=h+Math.imul(fe,ye)|0,h=h+Math.imul(ce,me)|0,x=x+Math.imul(ce,ye)|0,m=m+Math.imul(oe,we)|0,h=h+Math.imul(oe,_e)|0,h=h+Math.imul(ae,we)|0,x=x+Math.imul(ae,_e)|0,m=m+Math.imul(ne,xe)|0,h=h+Math.imul(ne,Ee)|0,h=h+Math.imul(se,xe)|0,x=x+Math.imul(se,Ee)|0,m=m+Math.imul(G,Se)|0,h=h+Math.imul(G,Ie)|0,h=h+Math.imul(X,Se)|0,x=x+Math.imul(X,Ie)|0,m=m+Math.imul(H,Me)|0,h=h+Math.imul(H,Ae)|0,h=h+Math.imul($,Me)|0,x=x+Math.imul($,Ae)|0,m=m+Math.imul(U,Re)|0,h=h+Math.imul(U,Te)|0,h=h+Math.imul(j,Re)|0,x=x+Math.imul(j,Te)|0,m=m+Math.imul(E,De)|0,h=h+Math.imul(E,Ne)|0,h=h+Math.imul(C,De)|0,x=x+Math.imul(C,Ne)|0,m=m+Math.imul(g,Ce)|0,h=h+Math.imul(g,Pe)|0,h=h+Math.imul(R,Ce)|0,x=x+Math.imul(R,Pe)|0;var hn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(hn>>>26)|0,hn&=67108863,m=Math.imul(de,be),h=Math.imul(de,ve),h=h+Math.imul(le,be)|0,x=Math.imul(le,ve),m=m+Math.imul(ue,me)|0,h=h+Math.imul(ue,ye)|0,h=h+Math.imul(he,me)|0,x=x+Math.imul(he,ye)|0,m=m+Math.imul(fe,we)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(ce,we)|0,x=x+Math.imul(ce,_e)|0,m=m+Math.imul(oe,xe)|0,h=h+Math.imul(oe,Ee)|0,h=h+Math.imul(ae,xe)|0,x=x+Math.imul(ae,Ee)|0,m=m+Math.imul(ne,Se)|0,h=h+Math.imul(ne,Ie)|0,h=h+Math.imul(se,Se)|0,x=x+Math.imul(se,Ie)|0,m=m+Math.imul(G,Me)|0,h=h+Math.imul(G,Ae)|0,h=h+Math.imul(X,Me)|0,x=x+Math.imul(X,Ae)|0,m=m+Math.imul(H,Re)|0,h=h+Math.imul(H,Te)|0,h=h+Math.imul($,Re)|0,x=x+Math.imul($,Te)|0,m=m+Math.imul(U,De)|0,h=h+Math.imul(U,Ne)|0,h=h+Math.imul(j,De)|0,x=x+Math.imul(j,Ne)|0,m=m+Math.imul(E,Ce)|0,h=h+Math.imul(E,Pe)|0,h=h+Math.imul(C,Ce)|0,x=x+Math.imul(C,Pe)|0;var dn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(dn>>>26)|0,dn&=67108863,m=Math.imul(de,me),h=Math.imul(de,ye),h=h+Math.imul(le,me)|0,x=Math.imul(le,ye),m=m+Math.imul(ue,we)|0,h=h+Math.imul(ue,_e)|0,h=h+Math.imul(he,we)|0,x=x+Math.imul(he,_e)|0,m=m+Math.imul(fe,xe)|0,h=h+Math.imul(fe,Ee)|0,h=h+Math.imul(ce,xe)|0,x=x+Math.imul(ce,Ee)|0,m=m+Math.imul(oe,Se)|0,h=h+Math.imul(oe,Ie)|0,h=h+Math.imul(ae,Se)|0,x=x+Math.imul(ae,Ie)|0,m=m+Math.imul(ne,Me)|0,h=h+Math.imul(ne,Ae)|0,h=h+Math.imul(se,Me)|0,x=x+Math.imul(se,Ae)|0,m=m+Math.imul(G,Re)|0,h=h+Math.imul(G,Te)|0,h=h+Math.imul(X,Re)|0,x=x+Math.imul(X,Te)|0,m=m+Math.imul(H,De)|0,h=h+Math.imul(H,Ne)|0,h=h+Math.imul($,De)|0,x=x+Math.imul($,Ne)|0,m=m+Math.imul(U,Ce)|0,h=h+Math.imul(U,Pe)|0,h=h+Math.imul(j,Ce)|0,x=x+Math.imul(j,Pe)|0;var ln=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ln>>>26)|0,ln&=67108863,m=Math.imul(de,we),h=Math.imul(de,_e),h=h+Math.imul(le,we)|0,x=Math.imul(le,_e),m=m+Math.imul(ue,xe)|0,h=h+Math.imul(ue,Ee)|0,h=h+Math.imul(he,xe)|0,x=x+Math.imul(he,Ee)|0,m=m+Math.imul(fe,Se)|0,h=h+Math.imul(fe,Ie)|0,h=h+Math.imul(ce,Se)|0,x=x+Math.imul(ce,Ie)|0,m=m+Math.imul(oe,Me)|0,h=h+Math.imul(oe,Ae)|0,h=h+Math.imul(ae,Me)|0,x=x+Math.imul(ae,Ae)|0,m=m+Math.imul(ne,Re)|0,h=h+Math.imul(ne,Te)|0,h=h+Math.imul(se,Re)|0,x=x+Math.imul(se,Te)|0,m=m+Math.imul(G,De)|0,h=h+Math.imul(G,Ne)|0,h=h+Math.imul(X,De)|0,x=x+Math.imul(X,Ne)|0,m=m+Math.imul(H,Ce)|0,h=h+Math.imul(H,Pe)|0,h=h+Math.imul($,Ce)|0,x=x+Math.imul($,Pe)|0;var pn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(pn>>>26)|0,pn&=67108863,m=Math.imul(de,xe),h=Math.imul(de,Ee),h=h+Math.imul(le,xe)|0,x=Math.imul(le,Ee),m=m+Math.imul(ue,Se)|0,h=h+Math.imul(ue,Ie)|0,h=h+Math.imul(he,Se)|0,x=x+Math.imul(he,Ie)|0,m=m+Math.imul(fe,Me)|0,h=h+Math.imul(fe,Ae)|0,h=h+Math.imul(ce,Me)|0,x=x+Math.imul(ce,Ae)|0,m=m+Math.imul(oe,Re)|0,h=h+Math.imul(oe,Te)|0,h=h+Math.imul(ae,Re)|0,x=x+Math.imul(ae,Te)|0,m=m+Math.imul(ne,De)|0,h=h+Math.imul(ne,Ne)|0,h=h+Math.imul(se,De)|0,x=x+Math.imul(se,Ne)|0,m=m+Math.imul(G,Ce)|0,h=h+Math.imul(G,Pe)|0,h=h+Math.imul(X,Ce)|0,x=x+Math.imul(X,Pe)|0;var gn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(gn>>>26)|0,gn&=67108863,m=Math.imul(de,Se),h=Math.imul(de,Ie),h=h+Math.imul(le,Se)|0,x=Math.imul(le,Ie),m=m+Math.imul(ue,Me)|0,h=h+Math.imul(ue,Ae)|0,h=h+Math.imul(he,Me)|0,x=x+Math.imul(he,Ae)|0,m=m+Math.imul(fe,Re)|0,h=h+Math.imul(fe,Te)|0,h=h+Math.imul(ce,Re)|0,x=x+Math.imul(ce,Te)|0,m=m+Math.imul(oe,De)|0,h=h+Math.imul(oe,Ne)|0,h=h+Math.imul(ae,De)|0,x=x+Math.imul(ae,Ne)|0,m=m+Math.imul(ne,Ce)|0,h=h+Math.imul(ne,Pe)|0,h=h+Math.imul(se,Ce)|0,x=x+Math.imul(se,Pe)|0;var bn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(bn>>>26)|0,bn&=67108863,m=Math.imul(de,Me),h=Math.imul(de,Ae),h=h+Math.imul(le,Me)|0,x=Math.imul(le,Ae),m=m+Math.imul(ue,Re)|0,h=h+Math.imul(ue,Te)|0,h=h+Math.imul(he,Re)|0,x=x+Math.imul(he,Te)|0,m=m+Math.imul(fe,De)|0,h=h+Math.imul(fe,Ne)|0,h=h+Math.imul(ce,De)|0,x=x+Math.imul(ce,Ne)|0,m=m+Math.imul(oe,Ce)|0,h=h+Math.imul(oe,Pe)|0,h=h+Math.imul(ae,Ce)|0,x=x+Math.imul(ae,Pe)|0;var vn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(vn>>>26)|0,vn&=67108863,m=Math.imul(de,Re),h=Math.imul(de,Te),h=h+Math.imul(le,Re)|0,x=Math.imul(le,Te),m=m+Math.imul(ue,De)|0,h=h+Math.imul(ue,Ne)|0,h=h+Math.imul(he,De)|0,x=x+Math.imul(he,Ne)|0,m=m+Math.imul(fe,Ce)|0,h=h+Math.imul(fe,Pe)|0,h=h+Math.imul(ce,Ce)|0,x=x+Math.imul(ce,Pe)|0;var mn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(mn>>>26)|0,mn&=67108863,m=Math.imul(de,De),h=Math.imul(de,Ne),h=h+Math.imul(le,De)|0,x=Math.imul(le,Ne),m=m+Math.imul(ue,Ce)|0,h=h+Math.imul(ue,Pe)|0,h=h+Math.imul(he,Ce)|0,x=x+Math.imul(he,Pe)|0;var yn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(yn>>>26)|0,yn&=67108863,m=Math.imul(de,Ce),h=Math.imul(de,Pe),h=h+Math.imul(le,Ce)|0,x=Math.imul(le,Pe);var wn=(_+m|0)+((h&8191)<<13)|0;return _=(x+(h>>>13)|0)+(wn>>>26)|0,wn&=67108863,v[0]=ur,v[1]=Ke,v[2]=je,v[3]=Gt,v[4]=Jt,v[5]=Wt,v[6]=Yt,v[7]=Xt,v[8]=un,v[9]=hn,v[10]=dn,v[11]=ln,v[12]=pn,v[13]=gn,v[14]=bn,v[15]=vn,v[16]=mn,v[17]=yn,v[18]=wn,_!==0&&(v[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,d=0;d>>26)|0,a+=v>>>26,v&=67108863}w.words[d]=_,p=v,v=a}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(D,l,w){var p=new N;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=O(this,l,w),p};function N(D,l){this.x=D,this.y=l}N.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},N.prototype.permute=function(l,w,p,a,d,v){for(var _=0;_>>1)d++;return 1<>>13,p[2*v+1]=d&8191,d=d>>>13;for(v=2*w;v>=26,w+=a/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,d;if(w!==0){var v=0;for(d=0;d>>26-w}v&&(this.words[d]=v,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var a;w?a=(w-w%26)/26:a=0;var d=l%26,v=Math.min((l-d)/26,this.length),_=67108863^67108863>>>d<v)for(this.length-=v,h=0;h=0&&(x!==0||h>=a);h--){var A=this.words[h]|0;this.words[h]=x<<26-d|A>>>d,x=A&_}return m&&x!==0&&(m.words[m.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(m/67108864|0),this.words[d+p]=v&67108863}for(;d>26,this.words[d+p]=v&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,d=0;d>26,this.words[d]=v&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),d=l,v=d.words[d.length-1]|0,_=this._countBits(v);p=26-_,p!==0&&(d=d.ushln(p),a.iushln(p),v=d.words[d.length-1]|0);var m=a.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=m+1,h.words=new Array(h.length);for(var x=0;x=0;g--){var R=(a.words[d.length+g]|0)*67108864+(a.words[d.length+g-1]|0);for(R=Math.min(R/v|0,67108863),a._ishlnsubmul(d,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(d,1,g),a.isZero()||(a.negative^=1);h&&(h.words[g]=R)}return h&&h.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:h||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,d,v;return this.negative!==0&&l.negative===0?(v=this.neg().divmod(l,w),w!=="mod"&&(a=v.div.neg()),w!=="div"&&(d=v.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:a,mod:d}):this.negative===0&&l.negative!==0?(v=this.divmod(l.neg(),w),w!=="mod"&&(a=v.div.neg()),{div:a,mod:v.mod}):this.negative&l.negative?(v=this.neg().divmod(l.neg(),w),w!=="div"&&(d=v.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:v.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),d=l.andln(1),v=p.cmp(a);return v<0||d===1&&v===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),v=new n(0),_=new n(1),m=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++m;for(var h=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(h),d.isub(x)),a.iushrn(1),d.iushrn(1);for(var R=0,K=1;!(p.words[0]&K)&&R<26;++R,K<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(v.isOdd()||_.isOdd())&&(v.iadd(h),_.isub(x)),v.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(v),d.isub(_)):(p.isub(w),v.isub(a),_.isub(d))}return{a:v,b:_,gcd:p.iushln(m)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),v=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,m=1;!(w.words[0]&m)&&_<26;++_,m<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(v),a.iushrn(1);for(var h=0,x=1;!(p.words[0]&x)&&h<26;++h,x<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(v),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(d)):(p.isub(w),d.isub(a))}var A;return w.cmpn(1)===0?A=a:A=d,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var v=w;w=p,p=v}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[v]=_}return d!==0&&(this.words[v]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,d=l.words[p]|0;if(a!==d){ad&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new P(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var B={k256:null,p224:null,p192:null,p25519:null};function z(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},z.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},z.prototype.split=function(l,w){l.iushrn(this.n,0,w)},z.prototype.imulK=function(l){return l.imul(this.k)};function F(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(F,z),F.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),d=0;d>>22,v=_}v>>>=22,l.words[d-10]=v,v===0&&l.length>10?l.length-=10:l.length-=9},F.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(B[l])return B[l];var w;if(l==="k256")w=new F;else if(l==="p224")w=new k;else if(l==="p192")w=new V;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return B[l]=w,w};function P(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}P.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},P.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},P.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},P.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},P.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},P.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},P.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},P.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},P.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},P.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},P.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},P.prototype.isqr=function(l){return this.imul(l,l.clone())},P.prototype.sqr=function(l){return this.mul(l,l)},P.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);t(!a.isZero());var v=new n(1).toRed(this),_=v.redNeg(),m=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,m).cmp(_)!==0;)h.redIAdd(_);for(var x=this.pow(h,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=d;g.cmp(v)!==0;){for(var K=g,E=0;K.cmp(v)!==0;E++)K=K.redSqr();t(E=0;d--){for(var x=w.words[d],A=h-1;A>=0;A--){var g=x>>A&1;if(v!==a[0]&&(v=this.sqr(v)),g===0&&_===0){m=0;continue}_<<=1,_|=g,m++,!(m!==p&&(d!==0||A!==0))&&(v=this.mul(v,a[_]),m=0,_=0)}h=26}return v},P.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},P.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new J(l)};function J(D){P.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(J,P),J.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},J.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},J.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),v=d;return d.cmp(this.m)>=0?v=d.isub(this.m):d.cmpn(0)<0&&(v=d.iadd(this.m)),v._forceRed(this)},J.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),v=d;return d.cmp(this.m)>=0?v=d.isub(this.m):d.cmpn(0)<0&&(v=d.iadd(this.m)),v._forceRed(this)},J.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof dd>"u"||dd,Fv)});var ld=W(zv=>{"use strict";var Wf=zv;function EE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}Wf.toArray=EE;function Uv(r){return r.length===1?"0"+r:r}Wf.zero2=Uv;function Bv(r){for(var e="",t=0;t{"use strict";var yr=kv,SE=ri(),IE=Fi(),Yf=ld();yr.assert=IE;yr.toArray=Yf.toArray;yr.zero2=Yf.zero2;yr.toHex=Yf.toHex;yr.encode=Yf.encode;function ME(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-c:f=c,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}yr.getNAF=ME;function AE(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var c;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?c=-o:c=o):c=0,t[0].push(c);var u;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?u=-f:u=f):u=0,t[1].push(u),2*i===c+1&&(i=1-i),2*n===u+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}yr.getJSF=AE;function RE(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}yr.cachedProperty=RE;function TE(r){return typeof r=="string"?yr.toArray(r,"hex"):r}yr.parseBytes=TE;function DE(r){return new SE(r,"hex","le")}yr.intFromLE=DE});var vd=W((jC,bd)=>{var pd;bd.exports=function(e){return pd||(pd=new Ki(null)),pd.generate(e)};function Ki(r){this.rand=r}bd.exports.Rand=Ki;Ki.prototype.generate=function(e){return this._rand(e)};Ki.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var On=ri(),ko=jt(),Xf=ko.getNAF,NE=ko.getJSF,Zf=ko.assert;function ji(r,e){this.type=r,this.p=new On(e.p,16),this.red=e.prime?On.red(e.prime):On.mont(this.p),this.zero=new On(0).toRed(this.red),this.one=new On(1).toRed(this.red),this.two=new On(2).toRed(this.red),this.n=e.n&&new On(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Kv.exports=ji;ji.prototype.point=function(){throw new Error("Not implemented")};ji.prototype.validate=function(){throw new Error("Not implemented")};ji.prototype._fixedNafMul=function(e,t){Zf(e.precomputed);var i=e._getDoubles(),n=Xf(t,1,this._bitLength),s=(1<=f;u--)c=(c<<1)+n[u];o.push(c)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;c--){for(var u=0;c>=0&&o[c]===0;c--)u++;if(c>=0&&u++,f=f.dblp(u),c<0)break;var b=o[c];Zf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};ji.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,c=this._wnafT3,u=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){c[M]=Xf(i[M],o[M],this._bitLength),c[T]=Xf(i[T],o[T],this._bitLength),u=Math.max(c[M].length,u),u=Math.max(c[T].length,u);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],B=NE(i[M],i[T]);for(u=Math.max(B[0].length,u),c[M]=new Array(u),c[T]=new Array(u),y=0;y=0;b--){for(var L=0;b>=0;){var P=!0;for(y=0;y=0&&L++,k=k.dblp(L),b<0)break;for(y=0;y0?S=f[y][J-1>>1]:J<0&&(S=f[y][-J-1>>1].neg()),S.type==="affine"?k=k.mixedAdd(S):k=k.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};ir.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var CE=jt(),it=ri(),md=Po(),Ds=Ko(),PE=CE.assert;function nr(r){Ds.call(this,"short",r),this.a=new it(r.a,16).toRed(this.red),this.b=new it(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}md(nr,Ds);jv.exports=nr;nr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new it(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new it(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],PE(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new it(f.a,16),b:new it(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};nr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:it.mont(e),i=new it(2).toRed(t).redInvm(),n=i.redNeg(),s=new it(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};nr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new it(1),o=new it(0),f=new it(0),c=new it(1),u,b,y,S,I,M,T,O=0,N,B;i.cmpn(0)!==0;){var z=n.div(i);N=n.sub(z.mul(i)),B=f.sub(z.mul(s));var F=c.sub(z.mul(o));if(!y&&N.cmp(t)<0)u=T.neg(),b=s,y=N.neg(),S=B;else if(y&&++O===2)break;T=N,n=i,i=N,f=s,s=B,c=o,o=F}I=N.neg(),M=B;var k=y.sqr().add(S.sqr()),V=I.sqr().add(M.sqr());return V.cmp(k)>=0&&(I=u,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};nr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),c=o.mul(n.a),u=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(c),S=u.add(b).neg();return{k1:y,k2:S}};nr.prototype.pointFromX=function(e,t){e=new it(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};nr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};nr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};lt.prototype.isInfinity=function(){return this.inf};lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};lt.prototype.getX=function(){return this.x.fromRed()};lt.prototype.getY=function(){return this.y.fromRed()};lt.prototype.mul=function(e){return e=new it(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};lt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};lt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};lt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function _t(r,e,t,i){Ds.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new it(0)):(this.x=new it(e,16),this.y=new it(t,16),this.z=new it(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}md(_t,Ds.BasePoint);nr.prototype.jpoint=function(e,t,i){return new _t(this,e,t,i)};_t.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};_t.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};_t.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),u=o.redSub(f);if(c.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=c.redSqr(),y=b.redMul(c),S=n.redMul(b),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),M=u.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,M,T)};_t.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),c=s.redSub(o);if(f.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=f.redSqr(),b=u.redMul(f),y=i.redMul(u),S=c.redSqr().redIAdd(b).redISub(y).redISub(y),I=c.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};_t.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};_t.prototype.inspect=function(){return this.isInfinity()?"":""};_t.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Gv=W((HC,Hv)=>{"use strict";var Ns=ri(),$v=Po(),Qf=Ko(),OE=jt();function Cs(r){Qf.call(this,"mont",r),this.a=new Ns(r.a,16).toRed(this.red),this.b=new Ns(r.b,16).toRed(this.red),this.i4=new Ns(4).toRed(this.red).redInvm(),this.two=new Ns(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}$v(Cs,Qf);Hv.exports=Cs;Cs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function pt(r,e,t){Qf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Ns(e,16),this.z=new Ns(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}$v(pt,Qf.BasePoint);Cs.prototype.decodePoint=function(e,t){return this.point(OE.toArray(e,t),1)};Cs.prototype.point=function(e,t){return new pt(this,e,t)};Cs.prototype.pointFromJSON=function(e){return pt.fromJSON(this,e)};pt.prototype.precompute=function(){};pt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};pt.fromJSON=function(e,t){return new pt(e,t[0],t[1]||e.one)};pt.prototype.inspect=function(){return this.isInfinity()?"":""};pt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};pt.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};pt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};pt.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),c=s.redMul(n),u=t.z.redMul(f.redAdd(c).redSqr()),b=t.x.redMul(f.redISub(c).redSqr());return this.curve.point(u,b)};pt.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};pt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};pt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};pt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};pt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};pt.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Yv=W((GC,Wv)=>{"use strict";var LE=jt(),Ei=ri(),Jv=Po(),ec=Ko(),qE=LE.assert;function ii(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,ec.call(this,"edwards",r),this.a=new Ei(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Ei(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Ei(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),qE(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Jv(ii,ec);Wv.exports=ii;ii.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};ii.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};ii.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};ii.prototype.pointFromX=function(e,t){e=new Ei(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=f.fromRed().isOdd();return(t&&!c||!t&&c)&&(f=f.redNeg()),this.point(e,f)};ii.prototype.pointFromY=function(e,t){e=new Ei(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};ii.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function We(r,e,t,i,n){ec.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Ei(e,16),this.y=new Ei(t,16),this.z=i?new Ei(i,16):this.curve.one,this.t=n&&new Ei(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Jv(We,ec.BasePoint);ii.prototype.pointFromJSON=function(e){return We.fromJSON(this,e)};ii.prototype.point=function(e,t,i,n){return new We(this,e,t,i,n)};We.fromJSON=function(e,t){return new We(e,t[0],t[1],t[2])};We.prototype.inspect=function(){return this.isInfinity()?"":""};We.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};We.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),c=n.redSub(t),u=s.redMul(f),b=o.redMul(c),y=s.redMul(c),S=f.redMul(o);return this.curve.point(u,b,S,y)};We.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,c,u;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(c=this.z.redSqr(),u=b.redSub(c).redISub(c),n=e.redSub(t).redISub(i).redMul(u),s=b.redMul(f.redSub(i)),o=b.redMul(u))}else f=t.redAdd(i),c=this.curve._mulC(this.z).redSqr(),u=f.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(f)).redMul(u),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(u);return this.curve.point(n,s,o)};We.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};We.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),c=s.redAdd(n),u=i.redAdd(t),b=o.redMul(f),y=c.redMul(u),S=o.redMul(u),I=f.redMul(c);return this.curve.point(b,y,I,S)};We.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),c=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(u),y,S;return this.curve.twisted?(y=t.redMul(c).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(c)):(y=t.redMul(c).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(c)),this.curve.point(b,y,S)};We.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};We.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};We.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};We.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};We.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};We.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};We.prototype.getX=function(){return this.normalize(),this.x.fromRed()};We.prototype.getY=function(){return this.normalize(),this.y.fromRed()};We.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};We.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};We.prototype.toP=We.prototype.normalize;We.prototype.mixedAdd=We.prototype.add});var yd=W(Xv=>{"use strict";var tc=Xv;tc.base=Ko();tc.short=Vv();tc.mont=Gv();tc.edwards=Yv()});var Qv=W((WC,Zv)=>{Zv.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var rc=W(rm=>{"use strict";var _d=rm,Vi=qo(),wd=yd(),FE=jt(),em=FE.assert;function tm(r){r.type==="short"?this.curve=new wd.short(r):r.type==="edwards"?this.curve=new wd.edwards(r):this.curve=new wd.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,em(this.g.validate(),"Invalid curve"),em(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}_d.PresetCurve=tm;function $i(r,e){Object.defineProperty(_d,r,{configurable:!0,enumerable:!0,get:function(){var t=new tm(e);return Object.defineProperty(_d,r,{configurable:!0,enumerable:!0,value:t}),t}})}$i("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vi.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});$i("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vi.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});$i("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vi.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});$i("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vi.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});$i("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vi.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});$i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vi.sha256,gRed:!1,g:["9"]});$i("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vi.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var xd;try{xd=Qv()}catch{xd=void 0}$i("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vi.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",xd]})});var sm=W((XC,nm)=>{"use strict";var UE=qo(),Ln=ld(),im=Fi();function Hi(r){if(!(this instanceof Hi))return new Hi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Ln.toArray(r.entropy,r.entropyEnc||"hex"),t=Ln.toArray(r.nonce,r.nonceEnc||"hex"),i=Ln.toArray(r.pers,r.persEnc||"hex");im(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}nm.exports=Hi;Hi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Hi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Ln.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var BE=ri(),zE=jt(),Ed=zE.assert;function Tt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}om.exports=Tt;Tt.fromPublic=function(e,t,i){return t instanceof Tt?t:new Tt(e,{pub:t,pubEnc:i})};Tt.fromPrivate=function(e,t,i){return t instanceof Tt?t:new Tt(e,{priv:t,privEnc:i})};Tt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Tt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};Tt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Tt.prototype._importPrivate=function(e,t){this.priv=new BE(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};Tt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Ed(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Ed(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};Tt.prototype.derive=function(e){return e.validate()||Ed(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Tt.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};Tt.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};Tt.prototype.inspect=function(){return""}});var um=W((QC,cm)=>{"use strict";var ic=ri(),Md=jt(),kE=Md.assert;function nc(r,e){if(r instanceof nc)return r;this._importDER(r,e)||(kE(r.r&&r.s,"Signature without r or s"),this.r=new ic(r.r,16),this.s=new ic(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}cm.exports=nc;function KE(){this.place=0}function Sd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function fm(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}nc.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=fm(t),i=fm(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Id(n,t.length),n=n.concat(t),n.push(2),Id(n,i.length);var s=n.concat(i),o=[48];return Id(o,s.length),o=o.concat(s),Md.encode(o,e)}});var pm=W((eP,lm)=>{"use strict";var qn=ri(),hm=sm(),jE=jt(),Ad=rc(),VE=vd(),dm=jE.assert,Rd=am(),sc=um();function sr(r){if(!(this instanceof sr))return new sr(r);typeof r=="string"&&(dm(Object.prototype.hasOwnProperty.call(Ad,r),"Unknown curve "+r),r=Ad[r]),r instanceof Ad.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}lm.exports=sr;sr.prototype.keyPair=function(e){return new Rd(this,e)};sr.prototype.keyFromPrivate=function(e,t){return Rd.fromPrivate(this,e,t)};sr.prototype.keyFromPublic=function(e,t){return Rd.fromPublic(this,e,t)};sr.prototype.genKeyPair=function(e){e||(e={});for(var t=new hm({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||VE(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new qn(2));;){var s=new qn(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};sr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};sr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new qn(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),c=new hm({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new qn(1)),b=0;;b++){var y=n.k?n.k(b):new qn(c.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new sc({r:M,s:T,recoveryParam:O})}}}}}};sr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new qn(e,16)),i=this.keyFromPublic(i,n),t=new sc(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),c=f.mul(e).umod(this.n),u=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};sr.prototype.recoverPubKey=function(r,e,t,i){dm((3&t)===t,"The recovery param is more than two bits"),e=new sc(e,i);var n=this.n,s=new qn(r),o=e.r,f=e.s,c=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};sr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new sc(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var mm=W((tP,vm)=>{"use strict";var jo=jt(),bm=jo.assert,gm=jo.parseBytes,Ps=jo.cachedProperty;function gt(r,e){this.eddsa=r,this._secret=gm(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=gm(e.pub)}gt.fromPublic=function(e,t){return t instanceof gt?t:new gt(e,{pub:t})};gt.fromSecret=function(e,t){return t instanceof gt?t:new gt(e,{secret:t})};gt.prototype.secret=function(){return this._secret};Ps(gt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});Ps(gt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});Ps(gt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});Ps(gt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});Ps(gt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});Ps(gt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});gt.prototype.sign=function(e){return bm(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};gt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};gt.prototype.getSecret=function(e){return bm(this._secret,"KeyPair is public only"),jo.encode(this.secret(),e)};gt.prototype.getPublic=function(e){return jo.encode(this.pubBytes(),e)};vm.exports=gt});var _m=W((rP,wm)=>{"use strict";var $E=ri(),oc=jt(),ym=oc.assert,ac=oc.cachedProperty,HE=oc.parseBytes;function Fn(r,e){this.eddsa=r,typeof e!="object"&&(e=HE(e)),Array.isArray(e)&&(ym(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),ym(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof $E&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}ac(Fn,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});ac(Fn,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});ac(Fn,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});ac(Fn,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Fn.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Fn.prototype.toHex=function(){return oc.encode(this.toBytes(),"hex").toUpperCase()};wm.exports=Fn});var Mm=W((iP,Im)=>{"use strict";var GE=qo(),JE=rc(),Os=jt(),WE=Os.assert,Em=Os.parseBytes,Sm=mm(),xm=_m();function Bt(r){if(WE(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Bt))return new Bt(r);r=JE[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=GE.sha512}Im.exports=Bt;Bt.prototype.sign=function(e,t){e=Em(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})};Bt.prototype.verify=function(e,t,i){if(e=Em(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Bt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Un=Am;Un.version=qv().version;Un.utils=jt();Un.rand=vd();Un.curve=yd();Un.curves=rc();Un.ec=pm();Un.eddsa=Mm()});var Tm,Dm=Z(()=>{Tm={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}}});function Go(r){let[e,t]=r.split(YE);return{namespace:e,reference:t}}function $m(r,e){return r.includes(":")?[r]:e.chains||[]}function Jo(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function kn(){return!(0,Ii.getDocument)()&&!!(0,Ii.getNavigator)()&&navigator.product===e9}function Fs(){return!Jo()&&!!(0,Ii.getNavigator)()&&!!(0,Ii.getDocument)()}function Wo(){return kn()?zt.reactNative:Jo()?zt.node:Fs()?zt.browser:zt.unknown}function Hm(){var r;try{return kn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function r9(r,e){let t=Ls.parse(r);return t=Pm(Pm({},t),e),r=Ls.stringify(t),r}function Us(){return(0,Km.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function i9(){if(Wo()===zt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){let{OS:t,Version:i}=global.Platform;return[t,i].join("-")}let r=ug();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function n9(){var r;let e=Wo();return e===zt.browser?[e,((r=(0,Ii.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function Nd(r,e,t){let i=i9(),n=n9();return[[r,e].join("-"),[t9,t].join("-"),i,n].join("/")}function Gm({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){let c=t.split("?"),u=Nd(r,e,i),b={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},y=r9(c[1]||"",b);return c[0]+"?"+y}function Bn(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Cd(r){return Object.fromEntries(r.entries())}function Pd(r){return new Map(Object.entries(r))}function Mi(r=Si.FIVE_MINUTES,e){let t=(0,Si.toMiliseconds)(r||Si.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Kn(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Jm(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Wm(r){return Jm("topic",r)}function Ym(r){return Jm("id",r)}function uc(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ft(r,e){return(0,Si.fromMiliseconds)((e||Date.now())+(0,Si.toMiliseconds)(r))}function ni(r){return Date.now()>=(0,Si.toMiliseconds)(r)}function Le(r,e){return`${r}${e?`:${e}`:""}`}function s9(r=[],e=[]){return[...new Set([...r,...e])]}async function Xm({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=o9(s,r,e),f=Wo();if(f===zt.browser){if(!((i=(0,Ii.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,a9()?"_blank":"_self","noreferrer noopener")}else f===zt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function o9(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${f9(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Zm(r,e){let t="";try{if(Fs()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Od(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ld(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Yo(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function a9(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function f9(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Qm(r){return Buffer.from(r,"base64").toString("utf-8")}async function u9(r,e,t,i,n,s){switch(t.t){case"eip191":return h9(r,e,t.s);case"eip1271":return await d9(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function h9(r,e,t){return hv(Cf(e),t).toLowerCase()===r.toLowerCase()}async function d9(r,e,t,i,n,s){let o=Go(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let f="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),y=Cf(e).substring(2),S=f+y+c+u+b,I=await fetch(`${s||c9}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:l9(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:M}=await I.json();return M?M.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function l9(){return Date.now()+Math.floor(Math.random()*1e3)}async function Fd(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Ud(n,n.iss),o=Xo(n.iss);return await u9(o,s,i,hc(n.iss),t)}function E9(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function S9(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function zn(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function I9(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:M9(e,t,i)}}}function M9(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function ey(r){return zn(r),`urn:recap:${E9(r).replace(/=/g,"")}`}function $o(r){let e=S9(r.replace("urn:recap:",""));return zn(e),e}function ty(r,e,t){let i=I9(r,e,t);return ey(i)}function A9(r){return r&&r.includes("urn:recap:")}function ry(r,e){let t=$o(r),i=$o(e),n=R9(t,i);return ey(n)}function R9(r,e){zn(r),zn(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,c)=>f.localeCompare(c)).forEach(f=>{var c,u;i.att[n]=w9(y9({},i.att[n]),{[f]:((c=r.att[n])==null?void 0:c[f])||((u=e.att[n])==null?void 0:u[f])})})}),i}function T9(r="",e){zn(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(f=>{let c=Object.keys(e.att[f]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));c.sort((y,S)=>y.action.localeCompare(S.action));let u={};c.forEach(y=>{u[y.ability]||(u[y.ability]=[]),u[y.ability].push(y.action)});let b=Object.keys(u).map(y=>(n++,`(${n}) '${y}': '${u[y].join("', '")}' for '${f}'.`));i.push(b.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Bd(r){var e;let t=$o(r);zn(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function zd(r){let e=$o(r);zn(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Zo(r){if(!r)return;let e=r?.[r.length-1];return A9(e)?e:void 0}function sy(){let r=cc.generateKeyPair();return{privateKey:tt(r.secretKey,Dt),publicKey:tt(r.publicKey,Dt)}}function dc(){let r=(0,Ho.randomBytes)(kd);return tt(r,Dt)}function oy(r,e){let t=cc.sharedKey(st(r,Dt),st(e,Dt),!0),i=new jm.HKDF(qs.SHA256,t).expand(kd);return tt(i,Dt)}function ks(r){let e=(0,qs.hash)(st(r,Dt));return tt(e,Dt)}function _r(r){let e=(0,qs.hash)(st(r,Qo));return tt(e,Dt)}function ay(r){return st(`${r}`,iy)}function Gi(r){return Number(tt(r,iy))}function fy(r){let e=ay(typeof r.type<"u"?r.type:ny);if(Gi(e)===wr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?st(r.senderPublicKey,Dt):void 0,i=typeof r.iv<"u"?st(r.iv,Dt):(0,Ho.randomBytes)(Vo),n=new Dd.ChaCha20Poly1305(st(r.symKey,Dt)).seal(i,st(r.message,Qo));return dy({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function cy(r,e){let t=ay(zs),i=(0,Ho.randomBytes)(Vo),n=st(r,Qo);return dy({type:t,sealed:n,iv:i,encoding:e})}function uy(r){let e=new Dd.ChaCha20Poly1305(st(r.symKey,Dt)),{sealed:t,iv:i}=Ks({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return tt(n,Qo)}function hy(r,e){let{sealed:t}=Ks({encoded:r,encoding:e});return tt(t,Qo)}function dy(r){let{encoding:e=si}=r;if(Gi(r.type)===zs)return tt(An([r.type,r.sealed]),e);if(Gi(r.type)===wr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return tt(An([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return tt(An([r.type,r.iv,r.sealed]),e)}function Ks(r){let{encoded:e,encoding:t=si}=r,i=st(e,t),n=i.slice(D9,qm),s=qm;if(Gi(n)===wr){let u=s+kd,b=u+Vo,y=i.slice(s,u),S=i.slice(u,b),I=i.slice(b);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(Gi(n)===zs){let u=i.slice(s),b=(0,Ho.randomBytes)(Vo);return{type:n,sealed:u,iv:b}}let o=s+Vo,f=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:f}}function ly(r,e){let t=Ks({encoded:r,encoding:e?.encoding});return Kd({type:Gi(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?tt(t.senderPublicKey,Dt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Kd(r){let e=r?.type||ny;if(e===wr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function jd(r){return r.type===wr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Vd(r){return r.type===zs}function N9(r){return new Vm.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function C9(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function P9(r){return Buffer.from(C9(r),"base64")}function py(r,e){let[t,i,n]=r.split("."),s=P9(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),c=`${t}.${i}`,u=new qs.SHA256().update(Buffer.from(c)).digest(),b=N9(e),y=Buffer.from(u).toString("hex");if(!b.verify(y,{r:o,s:f}))throw new Error("Invalid signature");return vs(r).payload}function lc(r){return r?.relay||{protocol:O9}}function js(r){let e=Tm[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}function k9(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function $d(r){if(!r.includes("wc:")){let c=Qm(r);c!=null&&c.includes("wc:")&&(r=c)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=Ls.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:K9(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:k9(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function K9(r){return r.startsWith("//")?r.substring(2):r}function j9(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function Hd(r){return`${r.protocol}:${r.topic}@${r.version}?`+Ls.stringify(Bm(z9(Bm({symKey:r.symKey},j9(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function ea(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Vs(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function V9(r){let e=[];return Object.values(r).forEach(t=>{e.push(...Vs(t.accounts))}),e}function $9(r,e){let t=[];return Object.values(r).forEach(i=>{Vs(i.accounts).includes(e)&&t.push(...i.methods)}),t}function H9(r,e){let t=[];return Object.values(r).forEach(i=>{Vs(i.accounts).includes(e)&&t.push(...i.events)}),t}function G9(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Gd(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=G9(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=s9(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}function Q(r,e){let{message:t,code:i}=W9[r];return{message:e?`${t} ${e}`:t,code:i}}function Be(r,e){let{message:t,code:i}=J9[r];return{message:e?`${t} ${e}`:t,code:i}}function Wi(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function ta(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function xt(r){return typeof r>"u"}function Qe(r,e){return e&&xt(r)?!0:typeof r=="string"&&!!r.trim().length}function Jd(r,e){return e&&xt(r)?!0:typeof r=="number"&&!isNaN(r)}function gy(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return Bn(n,i)?(i.forEach(o=>{let{accounts:f,methods:c,events:u}=r.namespaces[o],b=Vs(f),y=t[o];(!Bn($m(o,y),b)||!Bn(y.methods,c)||!Bn(y.events,u))&&(s=!1)}),s):!1}function fc(r){return Qe(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function Y9(r){if(Qe(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&fc(t)}}return!1}function by(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Qe(r,!1)){if(e(r))return!0;let t=Qm(r);return e(t)}}catch{}return!1}function vy(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function my(r){return r?.topic}function yy(r,e){let t=null;return Qe(r?.publicKey,!1)||(t=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function zm(r){let e=!0;return Wi(r)?r.length&&(e=r.every(t=>Qe(t,!1))):e=!1,e}function X9(r,e,t){let i=null;return Wi(e)&&e.length?e.forEach(n=>{i||fc(n)||(i=Be("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):fc(r)||(i=Be("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Z9(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=X9(n,$m(n,s),`${e} ${t}`);o&&(i=o)}),i}function Q9(r,e){let t=null;return Wi(r)?r.forEach(i=>{t||Y9(i)||(t=Be("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Be("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function e7(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=Q9(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function t7(r,e){let t=null;return zm(r?.methods)?zm(r?.events)||(t=Be("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Be("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function wy(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=t7(i,`${e}, namespace`);n&&(t=n)}),t}function _y(r,e,t){let i=null;if(r&&ta(r)){let n=wy(r,e);n&&(i=n);let s=Z9(r,e,t);s&&(i=s)}else i=Q("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function pc(r,e){let t=null;if(r&&ta(r)){let i=wy(r,e);i&&(t=i);let n=e7(r,e);n&&(t=n)}else t=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Wd(r){return Qe(r.protocol,!0)}function xy(r,e){let t=!1;return e&&!r?t=!0:r&&Wi(r)&&r.length&&r.forEach(i=>{t=Wd(i)}),t}function Ey(r){return typeof r=="number"}function Nt(r){return typeof r<"u"&&typeof r!==null}function Sy(r){return!(!r||typeof r!="object"||!r.code||!Jd(r.code,!1)||!r.message||!Qe(r.message,!1))}function Iy(r){return!(xt(r)||!Qe(r.method,!1))}function My(r){return!(xt(r)||xt(r.result)&&xt(r.error)||!Jd(r.id,!1)||!Qe(r.jsonrpc,!1))}function Ay(r){return!(xt(r)||!Qe(r.name,!1))}function Yd(r,e){return!(!fc(e)||!V9(r).includes(e))}function Ry(r,e,t){return Qe(t,!1)?$9(r,e).includes(t):!1}function Ty(r,e,t){return Qe(t,!1)?H9(r,e).includes(t):!1}function Xd(r,e,t){let i=null,n=r7(r),s=i7(e),o=Object.keys(n),f=Object.keys(s),c=km(Object.keys(r)),u=km(Object.keys(e)),b=c.filter(y=>!u.includes(y));return b.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. + Required: ${b.toString()} + Received: ${Object.keys(e).toString()}`)),Bn(o,f)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. + Required: ${o.toString()} + Approved: ${f.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=Vs(e[y].accounts);S.includes(y)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} + Required: ${y} + Approved: ${S.toString()}`))}),o.forEach(y=>{i||(Bn(n[y].methods,s[y].methods)?Bn(n[y].events,s[y].events)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function r7(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function km(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function i7(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Vs(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Dy(r,e){return Jd(r,!1)&&r<=e.max&&r>=e.min}function Zd(){let r=Wo();return new Promise(e=>{switch(r){case zt.browser:e(n7());break;case zt.reactNative:e(s7());break;case zt.node:e(o7());break;default:e(!0)}})}function n7(){return Fs()&&navigator?.onLine}async function s7(){return kn()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function o7(){return!0}function Ny(r){switch(Wo()){case zt.browser:a7(r);break;case zt.reactNative:f7(r);break;case zt.node:break}}function a7(r){!kn()&&Fs()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function f7(r){kn()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>r(e?.isConnected))}var Si,Ii,Km,Ls,Dd,jm,Ho,qs,cc,Vm,YE,XE,Nm,ZE,QE,Cm,Pm,e9,zt,t9,c9,p9,g9,b9,Om,v9,m9,Lm,y9,w9,_9,qd,x9,hc,Xo,Ud,iy,Dt,si,Bs,Qo,ny,wr,zs,D9,qm,Vo,kd,O9,L9,q9,F9,Fm,U9,B9,Um,Bm,z9,J9,W9,Td,Ji,ra=Z(()=>{hg();Si=Ue(ns()),Ii=Ue(Sf()),Km=Ue(lg()),Ls=Ue(Cg());bb();dv();Dd=Ue(wv()),jm=Ue(Mv()),Ho=Ue(mo()),qs=Ue(Rv()),cc=Ue(Cv());hd();Vm=Ue(Rm());Ef();Dm();YE=":";XE=Object.defineProperty,Nm=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,Cm=(r,e,t)=>e in r?XE(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Pm=(r,e)=>{for(var t in e||(e={}))ZE.call(e,t)&&Cm(r,t,e[t]);if(Nm)for(var t of Nm(e))QE.call(e,t)&&Cm(r,t,e[t]);return r},e9="ReactNative",zt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},t9="js";c9="https://rpc.walletconnect.org/v1";p9=Object.defineProperty,g9=Object.defineProperties,b9=Object.getOwnPropertyDescriptors,Om=Object.getOwnPropertySymbols,v9=Object.prototype.hasOwnProperty,m9=Object.prototype.propertyIsEnumerable,Lm=(r,e,t)=>e in r?p9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y9=(r,e)=>{for(var t in e||(e={}))v9.call(e,t)&&Lm(r,t,e[t]);if(Om)for(var t of Om(e))m9.call(e,t)&&Lm(r,t,e[t]);return r},w9=(r,e)=>g9(r,b9(e)),_9="did:pkh:",qd=r=>r?.split(":"),x9=r=>{let e=r&&qd(r);if(e)return r.includes(_9)?e[3]:e[1]},hc=r=>{let e=r&&qd(r);if(e)return e[2]+":"+e[3]},Xo=r=>{let e=r&&qd(r);if(e)return e.pop()};Ud=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Xo(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${x9(e)}`,c=`Nonce: ${r.nonce}`,u=`Issued At: ${r.iat}`,b=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(T=>` +- ${T}`).join("")}`:void 0,M=Zo(r.resources);if(M){let T=$o(M);n=T9(n,T)}return[t,i,"",n,"",s,o,f,c,u,b,y,S,I].filter(T=>T!=null).join(` +`)};iy="base10",Dt="base16",si="base64pad",Bs="base64url",Qo="utf8",ny=0,wr=1,zs=2,D9=0,qm=1,Vo=12,kd=32;O9="irn";L9=Object.defineProperty,q9=Object.defineProperties,F9=Object.getOwnPropertyDescriptors,Fm=Object.getOwnPropertySymbols,U9=Object.prototype.hasOwnProperty,B9=Object.prototype.propertyIsEnumerable,Um=(r,e,t)=>e in r?L9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bm=(r,e)=>{for(var t in e||(e={}))U9.call(e,t)&&Um(r,t,e[t]);if(Fm)for(var t of Fm(e))B9.call(e,t)&&Um(r,t,e[t]);return r},z9=(r,e)=>q9(r,F9(e));J9={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},W9={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};Td={},Ji=class{static get(e){return Td[e]}static set(e,t){Td[e]=t}static delete(e){delete Td[e]}}});var Cy,Py,Oy,Ly,gc,ia,Qd,bc,Yi,na,vc=Z(()=>{Cy="PARSE_ERROR",Py="INVALID_REQUEST",Oy="METHOD_NOT_FOUND",Ly="INVALID_PARAMS",gc="INTERNAL_ERROR",ia="SERVER_ERROR",Qd=[-32700,-32600,-32601,-32602,-32603],bc=[-32e3,-32099],Yi={[Cy]:{code:-32700,message:"Parse error"},[Py]:{code:-32600,message:"Invalid Request"},[Oy]:{code:-32601,message:"Method not found"},[Ly]:{code:-32602,message:"Invalid params"},[gc]:{code:-32603,message:"Internal error"},[ia]:{code:-32e3,message:"Server error"}},na=ia});function c7(r){return r<=bc[0]&&r>=bc[1]}function mc(r){return Qd.includes(r)}function qy(r){return typeof r=="number"}function yc(r){return Object.keys(Yi).includes(r)?Yi[r]:Yi[na]}function wc(r){let e=Object.values(Yi).find(t=>t.code===r);return e||Yi[na]}function u7(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!qy(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(mc(r.error.code)){let e=wc(r.error.code);if(e.message!==Yi[na].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function el(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var tl=Z(()=>{vc()});var Uy=W(Xi=>{"use strict";Object.defineProperty(Xi,"__esModule",{value:!0});Xi.isBrowserCryptoAvailable=Xi.getSubtleCrypto=Xi.getBrowerCrypto=void 0;function rl(){return(global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}Xi.getBrowerCrypto=rl;function Fy(){let r=rl();return r.subtle||r.webkitSubtle}Xi.getSubtleCrypto=Fy;function h7(){return!!rl()&&!!Fy()}Xi.isBrowserCryptoAvailable=h7});var ky=W(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.isBrowser=Zi.isNode=Zi.isReactNative=void 0;function By(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Zi.isReactNative=By;function zy(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Zi.isNode=zy;function d7(){return!By()&&!zy()}Zi.isBrowser=d7});var il=W(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var Ky=(es(),so(Qn));Ky.__exportStar(Uy(),_c);Ky.__exportStar(ky(),_c)});var Ct={};vt(Ct,{isNodeJs:()=>Vy});var jy,Vy,$y=Z(()=>{jy=Ue(il());Lt(Ct,Ue(il()));Vy=jy.isNode});function oi(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function xr(r=6){return BigInt(oi(r))}function Er(r,e,t){return{id:t||oi(),jsonrpc:"2.0",method:r,params:e}}function $s(r,e){return{id:r,jsonrpc:"2.0",result:e}}function jn(r,e,t){return{id:r,jsonrpc:"2.0",error:Hy(e,t)}}function Hy(r,e){return typeof r>"u"?yc(gc):(typeof r=="string"&&(r=Object.assign(Object.assign({},yc(ia)),{message:r})),typeof e<"u"&&(r.data=e),mc(r.code)&&(r=wc(r.code)),r)}var Gy=Z(()=>{tl();vc()});function l7(r){return r.includes("*")?Ec(r):!/\W/g.test(r)}function xc(r){return r==="*"}function Ec(r){return xc(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function p7(r){return!xc(r)&&Ec(r)&&!r.split("*")[0].trim()}function g7(r){return!xc(r)&&Ec(r)&&!r.split("*")[1].trim()}var Jy=Z(()=>{});var sa,nl,Sc,oa,Wy=Z(()=>{sa=class{},nl=class extends sa{constructor(e){super()}},Sc=class extends sa{constructor(){super()}},oa=class extends Sc{constructor(e){super()}}});var Yy=Z(()=>{Wy()});function m7(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Xy(r,e){let t=m7(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function y7(r){return Xy(r,b7)}function Ic(r){return Xy(r,v7)}function sl(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}var b7,v7,Zy=Z(()=>{b7="^https?:",v7="^wss?:"});function ol(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Hs(r){return ol(r)&&"method"in r}function Qi(r){return ol(r)&&(Vt(r)||Pt(r))}function Vt(r){return"result"in r}function Pt(r){return"error"in r}function w7(r){return"error"in r&&r.valid===!1}var Qy=Z(()=>{});var $t={};vt($t,{DEFAULT_ERROR:()=>na,IBaseJsonRpcProvider:()=>Sc,IEvents:()=>sa,IJsonRpcConnection:()=>nl,IJsonRpcProvider:()=>oa,INTERNAL_ERROR:()=>gc,INVALID_PARAMS:()=>Ly,INVALID_REQUEST:()=>Py,METHOD_NOT_FOUND:()=>Oy,PARSE_ERROR:()=>Cy,RESERVED_ERROR_CODES:()=>Qd,SERVER_ERROR:()=>ia,SERVER_ERROR_CODE_RANGE:()=>bc,STANDARD_ERROR_MAP:()=>Yi,formatErrorMessage:()=>Hy,formatJsonRpcError:()=>jn,formatJsonRpcRequest:()=>Er,formatJsonRpcResult:()=>$s,getBigIntRpcId:()=>xr,getError:()=>yc,getErrorByCode:()=>wc,isHttpUrl:()=>y7,isJsonRpcError:()=>Pt,isJsonRpcPayload:()=>ol,isJsonRpcRequest:()=>Hs,isJsonRpcResponse:()=>Qi,isJsonRpcResult:()=>Vt,isJsonRpcValidationInvalid:()=>w7,isLocalhostUrl:()=>sl,isNodeJs:()=>Vy,isReservedErrorCode:()=>mc,isServerErrorCode:()=>c7,isValidDefaultRoute:()=>xc,isValidErrorCode:()=>qy,isValidLeadingWildcardRoute:()=>p7,isValidRoute:()=>l7,isValidTrailingWildcardRoute:()=>g7,isValidWildcardRoute:()=>Ec,isWsUrl:()=>Ic,parseConnectionError:()=>el,payloadId:()=>oi,validateJsonRpcError:()=>u7});var aa=Z(()=>{vc();tl();$y();Lt($t,Ct);Gy();Jy();Yy();Zy();Qy()});var e2,Mc,t2=Z(()=>{e2=Ue(_n());aa();Mc=class extends oa{constructor(e){super(e),this.events=new e2.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Er(e.method,e.params||[],e.id||xr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Pt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Qi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}});var i2=W((BP,r2)=>{"use strict";r2.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var o2,_7,x7,n2,s2,E7,Ac,a2=Z(()=>{o2=Ue(_n());ss();aa();_7=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:i2(),x7=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",n2=r=>r.split("?")[0],s2=10,E7=_7(),Ac=class{constructor(e){if(this.url=e,this.events=new o2.EventEmitter,this.registering=!1,!Ic(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Zt(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Ic(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,$t.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!sl(e)},o=new E7(e,[],s);x7()?o.onerror=f=>{let c=f;i(this.emitError(c.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?jr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=jn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return el(e,n2(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>s2&&this.events.setMaxListeners(s2)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${n2(this.url)}`));return this.events.emit("register_error",t),t}}});var K2=W((fa,Js)=>{var S7=200,vl="__lodash_hash_undefined__",Lc=1,y2=2,w2=9007199254740991,Rc="[object Arguments]",ul="[object Array]",I7="[object AsyncFunction]",_2="[object Boolean]",x2="[object Date]",E2="[object Error]",S2="[object Function]",M7="[object GeneratorFunction]",Tc="[object Map]",I2="[object Number]",A7="[object Null]",Gs="[object Object]",f2="[object Promise]",R7="[object Proxy]",M2="[object RegExp]",Dc="[object Set]",A2="[object String]",T7="[object Symbol]",D7="[object Undefined]",hl="[object WeakMap]",R2="[object ArrayBuffer]",Nc="[object DataView]",N7="[object Float32Array]",C7="[object Float64Array]",P7="[object Int8Array]",O7="[object Int16Array]",L7="[object Int32Array]",q7="[object Uint8Array]",F7="[object Uint8ClampedArray]",U7="[object Uint16Array]",B7="[object Uint32Array]",z7=/[\\^$.*+?()[\]{}|]/g,k7=/^\[object .+?Constructor\]$/,K7=/^(?:0|[1-9]\d*)$/,Ze={};Ze[N7]=Ze[C7]=Ze[P7]=Ze[O7]=Ze[L7]=Ze[q7]=Ze[F7]=Ze[U7]=Ze[B7]=!0;Ze[Rc]=Ze[ul]=Ze[R2]=Ze[_2]=Ze[Nc]=Ze[x2]=Ze[E2]=Ze[S2]=Ze[Tc]=Ze[I2]=Ze[Gs]=Ze[M2]=Ze[Dc]=Ze[A2]=Ze[hl]=!1;var T2=typeof global=="object"&&global&&global.Object===Object&&global,j7=typeof self=="object"&&self&&self.Object===Object&&self,Ai=T2||j7||Function("return this")(),D2=typeof fa=="object"&&fa&&!fa.nodeType&&fa,c2=D2&&typeof Js=="object"&&Js&&!Js.nodeType&&Js,N2=c2&&c2.exports===D2,al=N2&&T2.process,u2=function(){try{return al&&al.binding&&al.binding("util")}catch{}}(),h2=u2&&u2.isTypedArray;function V7(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function wS(r,e){var t=this.__data__,i=Fc(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}Ri.prototype.clear=bS;Ri.prototype.delete=vS;Ri.prototype.get=mS;Ri.prototype.has=yS;Ri.prototype.set=wS;function Hn(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var u=s.get(r);if(u&&s.get(e))return u==e;var b=-1,y=!0,S=t&y2?new Pc:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=w2}function z2(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function ha(r){return r!=null&&typeof r=="object"}var k2=h2?J7(h2):FS;function XS(r){return WS(r)?PS(r):US(r)}function ZS(){return[]}function QS(){return!1}Js.exports=YS});function LI(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,F=new Uint8Array(z);N!==B;){for(var k=M[N],V=0,L=z-1;(k!==0||V>>0,F[L]=k%f>>>0,k=k/f>>>0;if(k!==0)throw new Error("Non-zero carry");O=V,N++}for(var P=z-O;P!==z&&F[P]===0;)P++;for(var J=c.repeat(T);P>>0,z=new Uint8Array(B);M[T];){var F=t[M.charCodeAt(T)];if(F===255)return;for(var k=0,V=B-1;(F!==0||k>>0,z[V]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");N=k,T++}if(M[T]!==" "){for(var L=B-N;L!==B&&z[L]===0;)L++;for(var P=new Uint8Array(O+(B-L)),J=O;L!==B;)P[J++]=z[L++];return P}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}function xM(r){return r.reduce((e,t)=>(e+=wM[t],e),"")}function EM(r){let e=[];for(let t of r){let i=_M[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}function y3(r,e,t){e=e||[],t=t||0;for(var i=t;r>=TM;)e[t++]=r&255|$2,r/=128;for(;r&RM;)e[t++]=r&255|$2,r>>>=7;return e[t]=r|0,y3.bytes=t-i+1,e}function Il(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw Il.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&H2)<=NM);return Il.bytes=s-i,t}function YM(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function I3(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}function ZM(r,e="utf8"){let t=XM[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}var Ti,ie,u3,h3,d3,l3,jl,ui,eI,tI,rI,j2,iI,nI,sI,oI,aI,fI,cI,Vl,uI,p3,hI,Ot,dI,or,lI,wl,Ge,pI,gI,V2,fi,bI,vI,mI,yI,wI,la,rn,Sr,_I,xI,EI,Ht,SI,II,MI,g3,Ys,AI,RI,TI,DI,Ir,ci,ar,nn,sn,Xs,NI,CI,PI,OI,qI,FI,b3,UI,BI,_l,xl,El,v3,Sl,Bc,ba,zI,kI,Et,KI,jI,VI,$I,HI,GI,JI,WI,YI,XI,ZI,QI,eM,tM,rM,iM,nM,sM,oM,aM,fM,cM,uM,hM,dM,lM,pM,gM,bM,vM,mM,yM,m3,wM,_M,SM,IM,MM,$2,AM,RM,TM,DM,NM,H2,CM,PM,OM,LM,qM,FM,UM,BM,zM,kM,KM,w3,G2,J2,Ml,Al,_3,Rl,x3,jM,VM,$M,E3,HM,S3,GM,JM,WM,W2,Y2,ml,XM,Tl,Dl,Nl,Cl,Pl,QM,eA,tA,X2,rA,iA,Z2,pa,yl,Ol,nA,Q2,sA,oA,e3,t3,Ll,aA,r3,fA,cA,i3,n3,hi,ql,Fl,Ul,Bl,zl,uA,s3,hA,dA,o3,ga,kl,lA,a3,pA,gA,f3,c3,Kl,M3,A3=Z(()=>{Ti=Ue(_n());np();_p();Tu();Du();ie=Ue(ns());ss();Ef();Ef();ra();hd();t2();aa();a2();u3=Ue(K2()),h3=Ue(Sf()),d3="wc",l3=2,jl="core",ui=`${d3}@2:${jl}:`,eI={name:jl,logger:"error"},tI={database:":memory:"},rI="crypto",j2="client_ed25519_seed",iI=ie.ONE_DAY,nI="keychain",sI="0.3",oI="messages",aI="0.3",fI=ie.SIX_HOURS,cI="publisher",Vl="irn",uI="error",p3="wss://relay.walletconnect.org",hI="relayer",Ot={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},dI="_subscription",or={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},lI=.1,wl="2.17.1",Ge={link_mode:"link_mode",relay:"relay"},pI="0.3",gI="WALLETCONNECT_CLIENT_ID",V2="WALLETCONNECT_LINK_MODE_APPS",fi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},bI="subscription",vI="0.3",mI=ie.FIVE_SECONDS*1e3,yI="pairing",wI="0.3",la={wc_pairingDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:0},res:{ttl:ie.ONE_DAY,prompt:!1,tag:0}}},rn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Sr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},_I="history",xI="0.3",EI="expirer",Ht={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},SI="0.3",II="verify-api",MI="https://verify.walletconnect.com",g3="https://verify.walletconnect.org",Ys=g3,AI=`${Ys}/v3`,RI=[MI,g3],TI="echo",DI="https://echo.walletconnect.com",Ir={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ci={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ar={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},nn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},sn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Xs={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},NI=.1,CI="event-client",PI=86400,OI="https://pulse.walletconnect.org/batch";qI=LI,FI=qI,b3=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},UI=r=>new TextEncoder().encode(r),BI=r=>new TextDecoder().decode(r),_l=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},xl=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return v3(this,e)}},El=class{constructor(e){this.decoders=e}or(e){return v3(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},v3=(r,e)=>new El({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Sl=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new _l(e,t,i),this.decoder=new xl(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Bc=({name:r,prefix:e,encode:t,decode:i})=>new Sl(r,e,t,i),ba=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=FI(t,e);return Bc({prefix:r,name:e,encode:i,decode:s=>b3(n(s))})},zI=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[u++]=255&c>>f)}if(f>=t||255&c<<8-f)throw new SyntaxError("Unexpected end of data");return o},kI=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Bc({prefix:e,name:r,encode(n){return kI(n,i,t)},decode(n){return zI(n,i,t,r)}}),KI=Bc({prefix:"\0",name:"identity",encode:r=>BI(r),decode:r=>UI(r)}),jI=Object.freeze({__proto__:null,identity:KI}),VI=Et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$I=Object.freeze({__proto__:null,base2:VI}),HI=Et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),GI=Object.freeze({__proto__:null,base8:HI}),JI=ba({prefix:"9",name:"base10",alphabet:"0123456789"}),WI=Object.freeze({__proto__:null,base10:JI}),YI=Et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),XI=Et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ZI=Object.freeze({__proto__:null,base16:YI,base16upper:XI}),QI=Et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),eM=Et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tM=Et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),rM=Et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),iM=Et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nM=Et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),sM=Et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oM=Et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),aM=Et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),fM=Object.freeze({__proto__:null,base32:QI,base32upper:eM,base32pad:tM,base32padupper:rM,base32hex:iM,base32hexupper:nM,base32hexpad:sM,base32hexpadupper:oM,base32z:aM}),cM=ba({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),uM=ba({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),hM=Object.freeze({__proto__:null,base36:cM,base36upper:uM}),dM=ba({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lM=ba({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),pM=Object.freeze({__proto__:null,base58btc:dM,base58flickr:lM}),gM=Et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bM=Et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vM=Et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mM=Et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),yM=Object.freeze({__proto__:null,base64:gM,base64pad:bM,base64url:vM,base64urlpad:mM}),m3=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),wM=m3.reduce((r,e,t)=>(r[t]=e,r),[]),_M=m3.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);SM=Bc({prefix:"\u{1F680}",name:"base256emoji",encode:xM,decode:EM}),IM=Object.freeze({__proto__:null,base256emoji:SM}),MM=y3,$2=128,AM=127,RM=~AM,TM=Math.pow(2,31);DM=Il,NM=128,H2=127;CM=Math.pow(2,7),PM=Math.pow(2,14),OM=Math.pow(2,21),LM=Math.pow(2,28),qM=Math.pow(2,35),FM=Math.pow(2,42),UM=Math.pow(2,49),BM=Math.pow(2,56),zM=Math.pow(2,63),kM=function(r){return r(w3.encode(r,e,t),e),J2=r=>w3.encodingLength(r),Ml=(r,e)=>{let t=e.byteLength,i=J2(r),n=i+J2(t),s=new Uint8Array(n+t);return G2(r,s,0),G2(t,s,i),s.set(e,n),new Al(r,t,e,s)},Al=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},_3=({name:r,code:e,encode:t})=>new Rl(r,e,t),Rl=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ml(this.code,t):t.then(i=>Ml(this.code,i))}else throw Error("Unknown type, must be binary type")}},x3=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),jM=_3({name:"sha2-256",code:18,encode:x3("SHA-256")}),VM=_3({name:"sha2-512",code:19,encode:x3("SHA-512")}),$M=Object.freeze({__proto__:null,sha256:jM,sha512:VM}),E3=0,HM="identity",S3=b3,GM=r=>Ml(E3,S3(r)),JM={code:E3,name:HM,encode:S3,digest:GM},WM=Object.freeze({__proto__:null,identity:JM});new TextEncoder,new TextDecoder;W2={...jI,...$I,...GI,...WI,...ZI,...fM,...hM,...pM,...yM,...IM};({...$M,...WM});Y2=I3("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ml=I3("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=YM(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=mt(t,this.name)}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Cd(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Pd(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Dl=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=rI,this.randomSessionIdentifier=dc(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=Ah(n);return xf(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=sy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=Ah(s),f=this.randomSessionIdentifier;return await ig(f,n,iI,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let f=this.getPrivateKey(n),c=oy(f,s);return this.setSymKey(c,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||ks(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let f=Kd(o),c=Zt(s);if(Vd(f))return cy(c,o?.encoding);if(jd(f)){let S=f.senderPublicKey,I=f.receiverPublicKey;n=await this.generateSharedKey(S,I)}let u=this.getSymKey(n),{type:b,senderPublicKey:y}=f;return fy({type:b,symKey:u,message:c,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let f=ly(s,o);if(Vd(f)){let c=hy(s,o?.encoding);return jr(c)}if(jd(f)){let c=f.receiverPublicKey,u=f.senderPublicKey;n=await this.generateSharedKey(c,u)}try{let c=this.getSymKey(n),u=uy({symKey:c,encoded:s,encoding:o?.encoding});return jr(u)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(n,s=si)=>{let o=Ks({encoded:n,encoding:s});return Gi(o.type)},this.getPayloadSenderPublicKey=(n,s=si)=>{let o=Ks({encoded:n,encoding:s});return o.senderPublicKey?tt(o.senderPublicKey,Dt):void 0},this.core=e,this.logger=mt(t,this.name),this.keychain=i||new Tl(this.core,this.logger)}get context(){return St(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(j2)}catch{e=dc(),await this.keychain.set(j2,e)}return ZM(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Nl=class extends Ya{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=oI,this.version=aI,this.initialized=!1,this.storagePrefix=ui,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=_r(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=_r(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=mt(e,this.name),this.core=t}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Cd(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Pd(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Cl=class extends Xa{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Ti.EventEmitter,this.name=cI,this.queue=new Map,this.publishTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.failedPublishTimeout=(0,ie.toMiliseconds)(ie.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let f=s?.ttl||fI,c=lc(s),u=s?.prompt||!1,b=s?.tag||0,y=s?.id||xr().toString(),S={topic:i,message:n,opts:{ttl:f,relay:c,prompt:u,tag:b,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${b}`,M=Date.now(),T,O=1;try{for(;T===void 0;){if(Date.now()-M>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:O},`publisher.publish - attempt ${O}`),T=await await Kn(this.rpcPublish(i,n,f,c,u,b,y,s?.attestation).catch(N=>this.logger.warn(N)),this.publishTimeout,I),O++,T||await new Promise(N=>setTimeout(N,this.failedPublishTimeout))}this.relayer.events.emit(Ot.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw N;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=mt(t,this.name),this.registerEventListeners()}get context(){return St(this.logger)}rpcPublish(e,t,i,n,s,o,f,c){var u,b,y,S;let I={method:js(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:c},id:f};return xt((u=I.params)==null?void 0:u.prompt)&&((b=I.params)==null||delete b.prompt),xt((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ot.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ot.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Pl=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},QM=Object.defineProperty,eA=Object.defineProperties,tA=Object.getOwnPropertyDescriptors,X2=Object.getOwnPropertySymbols,rA=Object.prototype.hasOwnProperty,iA=Object.prototype.propertyIsEnumerable,Z2=(r,e,t)=>e in r?QM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pa=(r,e)=>{for(var t in e||(e={}))rA.call(e,t)&&Z2(r,t,e[t]);if(X2)for(var t of X2(e))iA.call(e,t)&&Z2(r,t,e[t]);return r},yl=(r,e)=>eA(r,tA(e)),Ol=class extends ef{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Pl,this.events=new Ti.EventEmitter,this.name=bI,this.version=vI,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ui,this.subscribeTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=lc(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let f=new ie.Watch;f.start(n);let c=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(c),f.stop(n),s(!0)),f.elapsed(n)>=mI&&(clearInterval(c),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=mt(t,this.name),this.clientId=""}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=lc(i);await this.rpcUnsubscribe(e,t,n);let s=Be("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===Ge.relay&&await this.restartToComplete();let s={method:js(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let f=_r(e+this.clientId);if(i?.transportType===Ge.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},(0,ie.toMiliseconds)(ie.ONE_SECOND)),f;let c=await Kn(this.relayer.request(s).catch(u=>this.logger.warn(u)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ot.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:js(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Kn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ot.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:js(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Kn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ot.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:js(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,yl(pa({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,pa({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,pa({},t)),this.topicMap.set(t.topic,e),this.events.emit(fi.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(fi.deleted,yl(pa({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(fi.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);Wi(t)&&this.onBatchSubscribe(t.map((i,n)=>yl(pa({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,async()=>{await this.checkPending()}),this.events.on(fi.created,async e=>{let t=fi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(fi.deleted,async e=>{let t=fi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},nA=Object.defineProperty,Q2=Object.getOwnPropertySymbols,sA=Object.prototype.hasOwnProperty,oA=Object.prototype.propertyIsEnumerable,e3=(r,e,t)=>e in r?nA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,t3=(r,e)=>{for(var t in e||(e={}))sA.call(e,t)&&e3(r,t,e[t]);if(Q2)for(var t of Q2(e))oA.call(e,t)&&e3(r,t,e[t]);return r},Ll=class extends Za{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ti.EventEmitter,this.name=hI,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ie.toMiliseconds)(ie.THIRTY_SECONDS+ie.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||xr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let f=await new Promise(async(c,u)=>{let b=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(or.disconnect,b);let y=await o;this.provider.off(or.disconnect,b),c(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Jo())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ot.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Ot.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(or.payload,this.onPayloadHandler),this.provider.on(or.connect,this.onConnectHandler),this.provider.on(or.disconnect,this.onDisconnectHandler),this.provider.on(or.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?mt(e.logger,this.name):(0,go.default)(vo({level:e.logger||uI})),this.messages=new Nl(this.logger,e.core),this.subscriber=new Ol(this,this.logger),this.publisher=new Cl(this,this.logger),this.relayUrl=e?.relayUrl||p3,this.projectId=e.projectId,this.bundleId=Hm(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return St(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Ge.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c,u=b=>{b.topic===e&&(this.subscriber.off(fi.created,u),c())};return await Promise.all([new Promise(b=>{c=b,this.subscriber.on(fi.created,u)}),new Promise(async(b,y)=>{f=await this.subscriber.subscribe(e,t3({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||f,b()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await Kn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(or.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(or.disconnect,n),await Kn(this.provider.connect(),(0,ie.toMiliseconds)(ie.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Zd())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=ft(ie.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ot.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Jo())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Mc(new Ac(Gm({sdkVersion:wl,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Hs(e)){if(!e.method.endsWith(dI))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:Ge.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(t3({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Qi(e)&&this.events.emit(Ot.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ot.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=$s(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(or.payload,this.onPayloadHandler),this.provider.off(or.connect,this.onConnectHandler),this.provider.off(or.disconnect,this.onDisconnectHandler),this.provider.off(or.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Zd();Ny(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ot.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ie.toMiliseconds)(lI))))}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},aA=Object.defineProperty,r3=Object.getOwnPropertySymbols,fA=Object.prototype.hasOwnProperty,cA=Object.prototype.propertyIsEnumerable,i3=(r,e,t)=>e in r?aA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,n3=(r,e)=>{for(var t in e||(e={}))fA.call(e,t)&&i3(r,t,e[t]);if(r3)for(var t of r3(e))cA.call(e,t)&&i3(r,t,e[t]);return r},hi=class extends Qa{constructor(e,t,i,n=ui,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=pI,this.cached=[],this.initialized=!1,this.storagePrefix=ui,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!xt(o)?this.map.set(this.getKey(o),o):vy(o)?this.map.set(o.id,o):my(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(c=>(0,u3.default)(f[c],o[c]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});let c=n3(n3({},this.getData(o)),f);this.map.set(o,c),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=mt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},ql=class{constructor(e,t){this.core=e,this.logger=t,this.name=yI,this.version=wI,this.events=new Ti.default,this.initialized=!1,this.storagePrefix=ui,this.ignoredPayloadTypes=[wr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=dc(),s=await this.core.crypto.setSymKey(n),o=ft(ie.FIVE_MINUTES),f={protocol:Vl},c={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},u=Hd({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(rn.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Ir.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:f,expiryTimestamp:c,methods:u}=$d(i.uri);n.props.properties.topic=s,n.addTrace(Ir.pairing_uri_validation_success),n.addTrace(Ir.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(Ir.existing_pairing),b.active)throw n.setError(ci.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Ir.pairing_not_expired)}let y=c||ft(ie.FIVE_MINUTES),S={topic:s,relay:f,expiry:y,active:!1,methods:u};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(Ir.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(rn.create,S),n.addTrace(Ir.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Ir.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ci.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(I){throw n.setError(ci.subscribe_pairing_topic_failure),I}return n.addTrace(Ir.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=ft(ie.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:c}=Mi();this.events.once(Le("pairing_ping",s),({error:u})=>{u?c(u):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Be("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:f}=i,c=this.core.crypto.keychain.get(n);return Hd({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{let o=Er(n,s),f=await this.core.crypto.encode(i,o),c=la[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,c),o.id},this.sendResult=async(i,n,s)=>{let o=$s(i,s),f=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),u=la[c.request.method].res;await this.core.relayer.publish(n,f,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=jn(i,s),f=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),u=la[c.request.method]?la[c.request.method].res:la.unregistered_method.res;await this.core.relayer.publish(n,f,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Be("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>ni(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(rn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{Vt(n)?this.events.emit(Le("pairing_ping",s),{}):Pt(n)&&this.events.emit(Le("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(rn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let f=Be("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Be("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Nt(i)){let{message:f}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(!by(i.uri)){let{message:f}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ci.malformed_pairing_uri),new Error(f)}let o=$d(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:f}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){let{message:f}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&(0,ie.toMiliseconds)(o?.expiryTimestamp){if(!Nt(i)){let{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Nt(i)){let{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!Qe(i,!1)){let{message:n}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(ni(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=mt(t,this.name),this.pairings=new hi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return St(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ot.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===Ge.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{Hs(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Qi(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Ht.expired,async e=>{let{topic:t}=uc(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(rn.expire,{topic:t}))})}},Fl=class extends Wa{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Ti.EventEmitter,this.name=_I,this.version=xI,this.cached=[],this.initialized=!1,this.storagePrefix=ui,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:ft(ie.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Sr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Pt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Sr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Sr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=mt(t,this.name)}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:Er(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Sr.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Sr.created,e=>{let t=Sr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Sr.updated,e=>{let t=Sr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Sr.deleted,e=>{let t=Sr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(xn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,ie.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Sr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Ul=class extends tf{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Ti.EventEmitter,this.name=EI,this.version=SI,this.cached=[],this.initialized=!1,this.storagePrefix=ui,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Ht.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Ht.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=mt(t,this.name)}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Wm(e);if(typeof e=="number")return Ym(e);let{message:t}=Q("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ht.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,ie.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ht.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(xn.pulse,()=>this.checkExpirations()),this.events.on(Ht.created,e=>{let t=Ht.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ht.expired,e=>{let t=Ht.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ht.deleted,e=>{let t=Ht.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Bl=class extends rf{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=II,this.verifyUrlV3=AI,this.storagePrefix=ui,this.version=l3,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ie.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!Fs()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:f}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{let u=(0,h3.getDocument)(),b=this.startAbortTimer(ie.ONE_SECOND*5),y=await new Promise((S,I)=>{let M=()=>{window.removeEventListener("message",O),u.body.removeChild(T),I("attestation aborted")};this.abortController.signal.addEventListener("abort",M);let T=u.createElement("iframe");T.src=c,T.style.display="none",T.addEventListener("error",M,{signal:this.abortController.signal});let O=N=>{if(N.data&&typeof N.data=="string")try{let B=JSON.parse(N.data);if(B.type==="verify_attestation"){if(vs(B.attestation).payload.id!==o)return;clearInterval(b),u.body.removeChild(T),this.abortController.signal.removeEventListener("abort",M),window.removeEventListener("message",O),S(B.attestation===null?"":B.attestation)}}catch(B){this.logger.warn(B)}};u.body.appendChild(T),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(vs(s).payload.id!==f)return;let u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;let c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(ie.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||Ys;return RI.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Ys}`),s=Ys),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(ie.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=py(n,s.publicKey),f={hasExpired:(0,ie.toMiliseconds)(o.exp)this.abortController.abort(),(0,ie.toMiliseconds)(e))}},zl=class extends nf{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=TI,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,c=`${DI}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=mt(t,this.context)}},uA=Object.defineProperty,s3=Object.getOwnPropertySymbols,hA=Object.prototype.hasOwnProperty,dA=Object.prototype.propertyIsEnumerable,o3=(r,e,t)=>e in r?uA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ga=(r,e)=>{for(var t in e||(e={}))hA.call(e,t)&&o3(r,t,e[t]);if(s3)for(var t of s3(e))dA.call(e,t)&&o3(r,t,e[t]);return r},kl=class extends sf{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=CI,this.storagePrefix=ui,this.storageVersion=NI,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Yo())try{let n={eventId:Ld(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Nd(this.core.relayer.protocol,this.core.relayer.version,wl)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:f,trace:c}}=n,u=Ld(),b=this.core.projectId||"",y=Date.now(),S=ga({eventId:u,timestamp:y,props:{event:s,type:o,properties:{topic:f,trace:c}},bundleId:b,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let f=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(f)return ga(ga({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(xn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,ie.fromMiliseconds)(Date.now())-(0,ie.fromMiliseconds)(n.timestamp)>PI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,ga(ga({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${OI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${wl}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Us().url,this.logger=mt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},lA=Object.defineProperty,a3=Object.getOwnPropertySymbols,pA=Object.prototype.hasOwnProperty,gA=Object.prototype.propertyIsEnumerable,f3=(r,e,t)=>e in r?lA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c3=(r,e)=>{for(var t in e||(e={}))pA.call(e,t)&&f3(r,t,e[t]);if(a3)for(var t of a3(e))gA.call(e,t)&&f3(r,t,e[t]);return r},Kl=class r extends Ja{constructor(e){var t;super(e),this.protocol=d3,this.version=l3,this.name=jl,this.events=new Ti.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:c})=>{if(!o||!f)return;let u={topic:o,message:f,publishedAt:Date.now(),transportType:Ge.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:c})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||p3,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=vo({level:typeof e?.logger=="string"&&e.logger?e.logger:eI.logger}),{logger:n,chunkLoggerController:s}=Dp({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=mt(n,this.name),this.heartbeat=new Ua,this.crypto=new Dl(this,this.logger,e?.keychain),this.history=new Fl(this,this.logger),this.expirer=new Ul(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new ka(c3(c3({},tI),e?.storageOptions)),this.relayer=new Ll({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new ql(this,this.logger),this.verify=new Bl(this,this.logger,this.storage),this.echoClient=new zl(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new kl(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(gI,i),t}get context(){return St(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(V2,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(V2)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},M3=Kl});var Kc,Fe,N3,C3,P3,t0,$l,R3,bA,vA,mA,Zs,yA,bt,Hl,di,wA,_A,xA,EA,SA,IA,MA,jc,zc,AA,RA,TA,T3,DA,NA,D3,nt,Mr,Gl,Jl,Wl,Yl,Xl,Zl,Ql,e0,kc,O3=Z(()=>{A3();Tu();Du();ra();Kc=Ue(_n()),Fe=Ue(ns());aa();N3="wc",C3=2,P3="client",t0=`${N3}@${C3}:${P3}:`,$l={name:P3,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},R3="WALLETCONNECT_DEEPLINK_CHOICE",bA="proposal",vA="Proposal expired",mA="session",Zs=Fe.SEVEN_DAYS,yA="engine",bt={wc_sessionPropose:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Fe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Fe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1119}}},Hl={min:Fe.FIVE_MINUTES,max:Fe.SEVEN_DAYS},di={idle:"IDLE",active:"ACTIVE"},wA="request",_A=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],xA="wc",EA="auth",SA="authKeys",IA="pairingTopics",MA="requests",jc=`${xA}@${1.5}:${EA}:`,zc=`${jc}:PUB_KEY`,AA=Object.defineProperty,RA=Object.defineProperties,TA=Object.getOwnPropertyDescriptors,T3=Object.getOwnPropertySymbols,DA=Object.prototype.hasOwnProperty,NA=Object.prototype.propertyIsEnumerable,D3=(r,e,t)=>e in r?AA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nt=(r,e)=>{for(var t in e||(e={}))DA.call(e,t)&&D3(r,t,e[t]);if(T3)for(var t of T3(e))NA.call(e,t)&&D3(r,t,e[t]);return r},Mr=(r,e)=>RA(r,TA(e)),Gl=class extends af{constructor(e){super(e),this.name=yA,this.events=new Kc.default,this.initialized=!1,this.requestQueue={state:di.idle,queue:[]},this.sessionRequestQueue={state:di.idle,queue:[]},this.requestQueueDelay=Fe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(bt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=Mr(nt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:c}=i,u=n,b,y=!1;try{u&&(y=this.client.core.pairing.pairings.get(u).active)}catch(F){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),F}if(!u||!y){let{topic:F,uri:k}=await this.client.core.pairing.create();u=F,b=k}if(!u){let{message:F}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(F)}let S=await this.client.core.crypto.generateKeyPair(),I=bt.wc_sessionPropose.req.ttl||Fe.FIVE_MINUTES,M=ft(I),T=nt({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:Vl}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:M,pairingTopic:u},f&&{sessionProperties:f}),{reject:O,resolve:N,done:B}=Mi(I,vA);this.events.once(Le("session_connect"),async({error:F,session:k})=>{if(F)O(F);else if(k){k.self.publicKey=S;let V=Mr(nt({},k),{pairingTopic:T.pairingTopic,requiredNamespaces:T.requiredNamespaces,optionalNamespaces:T.optionalNamespaces,transportType:Ge.relay});await this.client.session.set(k.topic,V),await this.setExpiry(k.topic,k.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:k.peer.metadata}),this.cleanupDuplicatePairings(V),N(V)}});let z=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:T,throwOnFailedPublish:!0});return await this.setProposal(z,nt({id:z},T)),{uri:b,approval:B}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[ar.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(P){throw o.setError(nn.no_internet_connection),P}try{await this.isValidProposalId(t?.id)}catch(P){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(nn.proposal_not_found),P}try{await this.isValidApprove(t)}catch(P){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(nn.session_approve_namespace_validation_failure),P}let{id:f,relayProtocol:c,namespaces:u,sessionProperties:b,sessionConfig:y}=t,S=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:M,requiredNamespaces:T,optionalNamespaces:O}=S,N=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});N||(N=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:ar.session_approve_started,properties:{topic:I,trace:[ar.session_approve_started,ar.session_namespaces_validation_success]}}));let B=await this.client.core.crypto.generateKeyPair(),z=M.publicKey,F=await this.client.core.crypto.generateSharedKey(B,z),k=nt(nt({relay:{protocol:c??"irn"},namespaces:u,controller:{publicKey:B,metadata:this.client.metadata},expiry:ft(Zs)},b&&{sessionProperties:b}),y&&{sessionConfig:y}),V=Ge.relay;N.addTrace(ar.subscribing_session_topic);try{await this.client.core.relayer.subscribe(F,{transportType:V})}catch(P){throw N.setError(nn.subscribe_session_topic_failure),P}N.addTrace(ar.subscribe_session_topic_success);let L=Mr(nt({},k),{topic:F,requiredNamespaces:T,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:k.controller,peer:{publicKey:M.publicKey,metadata:M.metadata},controller:B,transportType:Ge.relay});await this.client.session.set(F,L),N.addTrace(ar.store_session);try{N.addTrace(ar.publishing_session_settle),await this.sendRequest({topic:F,method:"wc_sessionSettle",params:k,throwOnFailedPublish:!0}).catch(P=>{throw N?.setError(nn.session_settle_publish_failure),P}),N.addTrace(ar.session_settle_publish_success),N.addTrace(ar.publishing_session_approve),await this.sendResult({id:f,topic:I,result:{relay:{protocol:c??"irn"},responderPublicKey:B},throwOnFailedPublish:!0}).catch(P=>{throw N?.setError(nn.session_approve_publish_failure),P}),N.addTrace(ar.session_approve_publish_success)}catch(P){throw this.client.logger.error(P),this.client.session.delete(F,Be("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(F),P}return this.client.core.eventClient.deleteEvent({eventId:N.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:M.metadata}),await this.client.proposal.delete(f,Be("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(F,ft(Zs)),{topic:F,acknowledged:()=>Promise.resolve(this.client.session.get(F))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:bt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Be("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=Mi(),c=oi(),u=xr().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Le("session_update",c),({error:y})=>{y?f(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:u}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:b}),f(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}let{topic:i}=t,n=oi(),{done:s,resolve:o,reject:f}=Mi();return this.events.once(Le("session_extend",n),({error:c})=>{c?f(c):o()}),await this.setExpiry(i,ft(Zs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{f(c)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(M){throw this.client.logger.error("request() -> isValidRequest() failed"),M}let{chainId:i,request:n,topic:s,expiry:o=bt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===Ge.relay&&await this.confirmOnlineStateOrThrow();let c=oi(),u=xr().toString(),{done:b,resolve:y,reject:S}=Mi(o,"Request expired. Please try again.");this.events.once(Le("session_request",c),({error:M,result:T})=>{M?S(M):y(T)});let I=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return I?(await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Mr(nt({},n),{expiryTimestamp:ft(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(M=>S(M)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await b()):await Promise.all([new Promise(async M=>{await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Mr(nt({},n),{expiryTimestamp:ft(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(T=>S(T)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),M()}),new Promise(async M=>{var T;if(!((T=f.sessionConfig)!=null&&T.disableDeepLink)){let O=await Zm(this.client.core.storage,R3);await Xm({id:c,topic:s,wcDeepLink:O})}M()}),b()]).then(M=>M[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===Ge.relay&&await this.confirmOnlineStateOrThrow();let f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Vt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):Pt(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=oi(),s=xr().toString(),{done:o,resolve:f,reject:c}=Mi();this.events.once(Le("session_ping",n),({error:u})=>{u?c(u):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=xr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Be("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gy(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?Ge.link_mode:Ge.relay;o===Ge.relay&&await this.confirmOnlineStateOrThrow();let{chains:f,statement:c="",uri:u,domain:b,nonce:y,type:S,exp:I,nbf:M,methods:T=[],expiry:O}=t,N=[...t.resources||[]],{topic:B,uri:z}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:B,uri:z}});let F=await this.client.core.crypto.generateKeyPair(),k=ks(F);if(await Promise.all([this.client.auth.authKeys.set(zc,{responseTopic:k,publicKey:F}),this.client.auth.pairingTopics.set(k,{topic:k,pairingTopic:B})]),await this.client.core.relayer.subscribe(k,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${B}`),T.length>0){let{namespace:m}=Go(f[0]),h=ty(m,"request",T);Zo(N)&&(h=ry(h,N.pop())),N.push(h)}let V=O&&O>bt.wc_sessionAuthenticate.req.ttl?O:bt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:f,statement:c,aud:u,domain:b,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:M,resources:N},requester:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:ft(V)},P={eip155:{chains:f,methods:[...new Set(["personal_sign",...T])],events:["chainChanged","accountsChanged"]}},J={requiredNamespaces:{},optionalNamespaces:P,relays:[{protocol:"irn"}],pairingTopic:B,proposer:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:ft(bt.wc_sessionPropose.req.ttl)},{done:D,resolve:l,reject:w}=Mi(V,"Request expired"),p=async({error:m,session:h})=>{if(this.events.off(Le("session_request",d),a),m)w(m);else if(h){h.self.publicKey=F,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),B&&await this.client.core.pairing.updateMetadata({topic:B,metadata:h.peer.metadata});let x=this.client.session.get(h.topic);await this.deleteProposal(v),l({session:x})}},a=async m=>{var h,x,A;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),m.error){let U=Be("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return m.error.code===U.code?void 0:(this.events.off(Le("session_connect"),p),w(m.error.message))}await this.deleteProposal(v),this.events.off(Le("session_connect"),p);let{cacaos:g,responder:R}=m.result,K=[],E=[];for(let U of g){await Fd({cacao:U,projectId:this.client.core.projectId})||(this.client.logger.error(U,"Signature verification failed"),w(Be("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:j}=U,Y=Zo(j.resources),H=[hc(j.iss)],$=Xo(j.iss);if(Y){let te=Bd(Y),G=zd(Y);K.push(...te),H.push(...G)}for(let te of H)E.push(`${te}:${$}`)}let C=await this.client.core.crypto.generateSharedKey(F,R.publicKey),q;K.length>0&&(q={topic:C,acknowledged:!0,self:{publicKey:F,metadata:this.client.metadata},peer:R,controller:R.publicKey,expiry:ft(Zs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:B,namespaces:Gd([...new Set(K)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(C,{transportType:o}),await this.client.session.set(C,q),B&&await this.client.core.pairing.updateMetadata({topic:B,metadata:R.metadata}),q=this.client.session.get(C)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(x=R.metadata.redirect)!=null&&x.linkMode&&(A=R.metadata.redirect)!=null&&A.universal&&i&&(this.client.core.addLinkModeSupportedApp(R.metadata.redirect.universal),this.client.session.update(C,{transportType:Ge.link_mode})),l({auths:g,session:q})},d=oi(),v=oi();this.events.once(Le("session_connect"),p),this.events.once(Le("session_request",d),a);let _;try{if(s){let m=Er("wc_sessionAuthenticate",L,d);this.client.core.history.set(B,m);let h=await this.client.core.crypto.encode("",m,{type:zs,encoding:Bs});_=ea(i,B,h)}else await Promise.all([this.sendRequest({topic:B,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:B,method:"wc_sessionPropose",params:J,expiry:bt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:v})])}catch(m){throw this.events.off(Le("session_connect"),p),this.events.off(Le("session_request",d),a),m}return await this.setProposal(v,nt({id:v},J)),await this.setAuthRequest(d,{request:Mr(nt({},L),{verifyContext:{}}),pairingTopic:B,transportType:o}),{uri:_??z,response:D}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[sn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(Xs.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Xs.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let f=o.transportType||Ge.relay;f===Ge.relay&&await this.confirmOnlineStateOrThrow();let c=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),b=ks(c),y={type:wr,receiverPublicKey:c,senderPublicKey:u},S=[],I=[];for(let O of n){if(!await Fd({cacao:O,projectId:this.client.core.projectId})){s.setError(Xs.invalid_cacao);let k=Be("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:k,encodeOpts:y}),new Error(k.message)}s.addTrace(sn.cacaos_verified);let{p:N}=O,B=Zo(N.resources),z=[hc(N.iss)],F=Xo(N.iss);if(B){let k=Bd(B),V=zd(B);S.push(...k),z.push(...V)}for(let k of z)I.push(`${k}:${F}`)}let M=await this.client.core.crypto.generateSharedKey(u,c);s.addTrace(sn.create_authenticated_session_topic);let T;if(S?.length>0){T={topic:M,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:ft(Zs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Gd([...new Set(S)],[...new Set(I)]),transportType:f},s.addTrace(sn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(M,{transportType:f})}catch(O){throw s.setError(Xs.subscribe_authenticated_session_topic_failure),O}s.addTrace(sn.subscribe_authenticated_session_topic_success),await this.client.session.set(M,T),s.addTrace(sn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(sn.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(O){throw s.setError(Xs.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:T}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===Ge.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),c=ks(o),u={type:wr,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:c,error:n,encodeOpts:u,rpcOpts:bt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Be("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return Ud(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Be("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(R3).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,Be("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=di.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(nn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Be("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=di.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,ft(bt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=Ge.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||ft(bt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:c,throwOnFailedPublish:u,appLink:b}=t,y=Er(n,s,c),S,I=!!b;try{let O=I?Bs:si;S=await this.client.core.crypto.encode(i,y,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let M;if(_A.includes(n)){let O=_r(JSON.stringify(y)),N=_r(S);M=await this.client.core.verify.register({id:N,decryptedId:O})}let T=bt[n].req;if(T.attestation=M,o&&(T.ttl=o),f&&(T.id=f),this.client.core.history.set(i,y),I){let O=ea(b,i,S);await global.Linking.openURL(O,this.client.name)}else{let O=bt[n].req;o&&(O.ttl=o),f&&(O.id=f),u?(O.internal=Mr(nt({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(N=>this.client.logger.error(N))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:c}=t,u=$s(i,s),b,y=c&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?Bs:si;b=await this.client.core.crypto.encode(n,u,Mr(nt({},f||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=ea(c,n,b);await global.Linking.openURL(I,this.client.name)}else{let I=bt[S.request.method].res;o?(I.internal=Mr(nt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,I)):this.client.core.relayer.publish(n,b,I).catch(M=>this.client.logger.error(M))}await this.client.core.history.resolve(u)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:c}=t,u=jn(i,s),b,y=c&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?Bs:si;b=await this.client.core.crypto.encode(n,u,Mr(nt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=ea(c,n,b);await global.Linking.openURL(I,this.client.name)}else{let I=f||bt[S.request.method].res;this.client.core.relayer.publish(n,b,I)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;ni(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{ni(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===di.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=di.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=di.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:c}=n;try{let u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(nt({},n.params));let b=f.expiryTimestamp||ft(bt.wc_sessionPropose.req.ttl),y=nt({id:c,pairingTopic:i,expiryTimestamp:b},f);await this.setProposal(c,y);let S=await this.getVerifyContext({attestationId:s,hash:_r(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(ci.proposal_listener_not_found)),u?.addTrace(Ir.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:y,verifyContext:S})}catch(u){await this.sendError({id:c,topic:i,error:u,rpcOpts:bt.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(Vt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});let c=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});let u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});let b=await this.client.core.crypto.generateSharedKey(c,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});let y=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(Pt(i)){await this.client.proposal.delete(s,Be("USER_DISCONNECTED"));let o=Le("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Le("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:f,expiry:c,namespaces:u,sessionProperties:b,sessionConfig:y}=i.params,S=Mr(nt(nt({topic:t,relay:o,expiry:c,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},b&&{sessionProperties:b}),y&&{sessionConfig:y}),{transportType:Ge.relay}),I=Le("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Le("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;Vt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Le("session_approve",n),{})):Pt(i)&&(await this.client.session.delete(t,Be("USER_DISCONNECTED")),this.events.emit(Le("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,f=Ji.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:Be("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(nt({topic:t},n));try{Ji.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(c){throw Ji.delete(o),c}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Le("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Vt(i)?this.events.emit(Le("session_update",n),{}):Pt(i)&&this.events.emit(Le("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,ft(Zs)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Le("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Vt(i)?this.events.emit(Le("session_extend",n),{}):Pt(i)&&this.events.emit(Le("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Le("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Vt(i)?this.events.emit(Le("session_ping",n),{}):Pt(i)&&this.events.emit(Le("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ot.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Be("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:f,attestation:c,encryptedId:u,transportType:b}=t,{id:y,params:S}=f;try{await this.isValidRequest(nt({topic:o},S));let I=this.client.session.get(o),M=await this.getVerifyContext({attestationId:c,hash:_r(JSON.stringify(Er("wc_sessionRequest",S,y))),encryptedId:u,metadata:I.peer.metadata,transportType:b}),T={id:y,topic:o,params:S,verifyContext:M};await this.setPendingSessionRequest(T),b===Ge.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(T):(this.addSessionRequestToSessionRequestQueue(T),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Le("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Vt(i)?this.events.emit(Le("session_request",n),{result:i.result}):Pt(i)&&this.events.emit(Le("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,f=Ji.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(nt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),Ji.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Vt(i)?this.events.emit(Le("session_request",n),{result:i.result}):Pt(i)&&this.events.emit(Le("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:f,transportType:c}=t;try{let{requester:u,authPayload:b,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:_r(JSON.stringify(s)),encryptedId:f,metadata:u.metadata,transportType:c}),I={requester:u,pairingTopic:n,id:s.id,authPayload:b,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:c}),c===Ge.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(u){this.client.logger.error(u);let b=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,c),I={type:wr,receiverPublicKey:b,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:I,rpcOpts:bt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=di.idle,this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,f=Le("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Le("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===di.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=di.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Er("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Nt(t)){let{message:c}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(c)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(xt(i)||await this.isValidPairingTopic(i),!xy(f,!0)){let{message:c}=Q("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(c)}!xt(n)&&ta(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!xt(s)&&ta(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),xt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=_y(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Nt(t))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let f=this.client.proposal.get(i),c=pc(n,"approve()");if(c)throw new Error(c.message);let u=Xd(f.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!Qe(s,!0)){let{message:b}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}xt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Nt(t)){let{message:s}=Q("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Sy(n)){let{message:s}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Nt(t)){let{message:u}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(u)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Wd(i)){let{message:u}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}let f=yy(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);let c=pc(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(ni(o)){let{message:u}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async t=>{if(!Nt(t)){let{message:c}=Q("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(c)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=pc(n,"update()");if(o)throw new Error(o.message);let f=Xd(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!Nt(t)){let{message:n}=Q("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Nt(t)){let{message:c}=Q("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(c)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:f}=this.client.session.get(i);if(!Yd(f,s)){let{message:c}=Q("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!Iy(n)){let{message:c}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!Ry(f,s,n.method)){let{message:c}=Q("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!Dy(o,Hl)){let{message:c}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Hl.min} and ${Hl.max}`);throw new Error(c)}},this.isValidRespond=async t=>{var i;if(!Nt(t)){let{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!My(s)){let{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Nt(t)){let{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Nt(t)){let{message:f}=Q("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!Yd(o,s)){let{message:f}=Q("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!Ay(n)){let{message:f}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!Ty(o,s,n.name)){let{message:f}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!Nt(t)){let{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Qe(n,!1))throw new Error("uri is required parameter");if(!Qe(s,!1))throw new Error("domain is required parameter");if(!Qe(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>Go(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:f}=Go(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,c={verified:{verifyUrl:o.verifyUrl||Ys,validation:"UNKNOWN",origin:o.url||""}};try{if(f===Ge.link_mode){let b=this.getAppLinkIfEnabled(o,f);return c.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",c}let u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(c.verified.origin=u.origin,c.verified.isScam=u.isScam,c.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!Qe(n,!1)){let{message:s}=Q("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,c,u,b,y,S;return!t||i!==Ge.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((u=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:u.universal)!==""&&((b=t?.redirect)==null?void 0:b.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=Od(t,"topic")||"",n=decodeURIComponent(Od(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:Ge.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Yo()||kn()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ot.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(zc)?this.client.auth.authKeys.get(zc):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===Ge.link_mode?Bs:si});try{Hs(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:_r(i)})):Qi(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(Ht.expired,async e=>{let{topic:t,id:i}=uc(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(rn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(rn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Qe(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(ni(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Qe(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(ni(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=Q("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=Q("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Qe(e,!1)){let{message:t}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Ey(e)){let{message:t}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(ni(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},Jl=class extends hi{constructor(e,t){super(e,t,bA,t0),this.core=e,this.logger=t}},Wl=class extends hi{constructor(e,t){super(e,t,mA,t0),this.core=e,this.logger=t}},Yl=class extends hi{constructor(e,t){super(e,t,wA,t0,i=>i.id),this.core=e,this.logger=t}},Xl=class extends hi{constructor(e,t){super(e,t,SA,jc,()=>zc),this.core=e,this.logger=t}},Zl=class extends hi{constructor(e,t){super(e,t,IA,jc),this.core=e,this.logger=t}},Ql=class extends hi{constructor(e,t){super(e,t,MA,jc,i=>i.id),this.core=e,this.logger=t}},e0=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new Xl(this.core,this.logger),this.pairingTopics=new Zl(this.core,this.logger),this.requests=new Ql(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},kc=class r extends of{constructor(e){super(e),this.protocol=N3,this.version=C3,this.name=$l.name,this.events=new Kc.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||$l.name,this.metadata=e?.metadata||Us(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,go.default)(vo({level:e?.logger||$l.logger}));this.core=e?.core||new M3(e),this.logger=mt(t,this.name),this.session=new Wl(this.core,this.logger),this.proposal=new Jl(this.core,this.logger),this.pendingRequest=new Yl(this.core,this.logger),this.engine=new Gl(this),this.auth=new e0(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return St(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}});var L3,Ar,r0=Z(()=>{"use strict";L3=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],Ar="mvx"});var va=Z(()=>{"use strict"});function Vc(r){return r[Math.floor(Math.random()*r.length)]}var ma,q3,i0,Qs=Z(()=>{"use strict";ma=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);q3="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",i0=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;ti.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Di(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=s0(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function F3(r){return!!r}function o0(r){let e=r.namespaces[Ar];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function a0({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,f=r.guardian;if(f&&f!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=i0(t),i&&(r.guardianSignature=i0(i)),r}function U3(r){if(r)return{...r,url:Us().url}}async function B3(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var z3=Z(()=>{"use strict";ra();r0();va();Qs()});var fr,ya=Z(()=>{"use strict";O3();ra();z3();r0();va();fr=class{constructor(e,t,i,n,s,o,f,c){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.Message=s,this.Transaction=o,this.TransactionsConverter=f,this.options=c}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:U3(this.options?.metadata)}:{},t=await kc.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=n0(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await B3(500);let i=o0(t),s=t.namespaces[Ar].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Di(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:Be("USER_DISCONNECTED")});else{let t=Di(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:Be("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return a0({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];a0({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Di(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?F3(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=o0(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&Di(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=s0(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!Wi(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}}});var k3={};vt(k3,{initMobileProvider:()=>OA});var OA,K3=Z(()=>{"use strict";ya();Qs();OA=async(r,e,t,i,n,s,o,f)=>{if(!o||!r.initOptions.chainType)return;let c={onClientLogin:()=>{},onClientLogout:()=>e(r),onClientEvent:y=>{console.log("wc2 session event: ",y)}},u=Vc(f),b=new fr(c,t[r.initOptions.chainType].shortId,u,o,i,n,s);try{return await b.init(),b}catch{console.warn("Can't initialize the Dapp Provider!")}}});var V3=W((MO,j3)=>{j3.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var on=W(Jn=>{var f0,LA=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Jn.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};Jn.getSymbolTotalCodewords=function(e){return LA[e]};Jn.getBCHDigit=function(r){let e=0;for(;r!==0;)e++,r>>>=1;return e};Jn.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');f0=e};Jn.isKanjiModeEnabled=function(){return typeof f0<"u"};Jn.toSJIS=function(e){return f0(e)}});var $c=W(cr=>{cr.L={bit:1};cr.M={bit:0};cr.Q={bit:3};cr.H={bit:2};function qA(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return cr.L;case"m":case"medium":return cr.M;case"q":case"quartile":return cr.Q;case"h":case"high":return cr.H;default:throw new Error("Unknown EC Level: "+r)}}cr.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4};cr.from=function(e,t){if(cr.isValid(e))return e;try{return qA(e)}catch{return t}}});var G3=W((TO,H3)=>{function $3(){this.buffer=[],this.length=0}$3.prototype={get:function(r){let e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(let t=0;t>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};H3.exports=$3});var W3=W((DO,J3)=>{function wa(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}wa.prototype.set=function(r,e,t,i){let n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};wa.prototype.get=function(r,e){return this.data[r*this.size+e]};wa.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};wa.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};J3.exports=wa});var Y3=W(Hc=>{var FA=on().getSymbolSize;Hc.getRowColCoords=function(e){if(e===1)return[];let t=Math.floor(e/7)+2,i=FA(e),n=i===145?26:Math.ceil((i-13)/(2*t-2))*2,s=[i-7];for(let o=1;o{var UA=on().getSymbolSize,X3=7;Z3.getPositions=function(e){let t=UA(e);return[[0,0],[t-X3,0],[0,t-X3]]}});var e6=W(Ye=>{Ye.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var Wn={N1:3,N2:3,N3:40,N4:10};Ye.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7};Ye.from=function(e){return Ye.isValid(e)?parseInt(e,10):void 0};Ye.getPenaltyN1=function(e){let t=e.size,i=0,n=0,s=0,o=null,f=null;for(let c=0;c=5&&(i+=Wn.N1+(n-5)),o=b,n=1),b=e.get(u,c),b===f?s++:(s>=5&&(i+=Wn.N1+(s-5)),f=b,s=1)}n>=5&&(i+=Wn.N1+(n-5)),s>=5&&(i+=Wn.N1+(s-5))}return i};Ye.getPenaltyN2=function(e){let t=e.size,i=0;for(let n=0;n=10&&(n===1488||n===93)&&i++,s=s<<1&2047|e.get(f,o),f>=10&&(s===1488||s===93)&&i++}return i*Wn.N3};Ye.getPenaltyN4=function(e){let t=0,i=e.data.length;for(let s=0;s{var an=$c(),Gc=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Jc=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];c0.getBlocksCount=function(e,t){switch(t){case an.L:return Gc[(e-1)*4+0];case an.M:return Gc[(e-1)*4+1];case an.Q:return Gc[(e-1)*4+2];case an.H:return Gc[(e-1)*4+3];default:return}};c0.getTotalCodewordsCount=function(e,t){switch(t){case an.L:return Jc[(e-1)*4+0];case an.M:return Jc[(e-1)*4+1];case an.Q:return Jc[(e-1)*4+2];case an.H:return Jc[(e-1)*4+3];default:return}}});var t6=W(Yc=>{var _a=new Uint8Array(512),Wc=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)_a[t]=e,Wc[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)_a[t]=_a[t-255]})();Yc.log=function(e){if(e<1)throw new Error("log("+e+")");return Wc[e]};Yc.exp=function(e){return _a[e]};Yc.mul=function(e,t){return e===0||t===0?0:_a[Wc[e]+Wc[t]]}});var r6=W(xa=>{var h0=t6();xa.mul=function(e,t){let i=new Uint8Array(e.length+t.length-1);for(let n=0;n=0;){let n=i[0];for(let o=0;o{var i6=r6();function d0(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}d0.prototype.initialize=function(e){this.degree=e,this.genPoly=i6.generateECPolynomial(this.degree)};d0.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let i=i6.mod(t,this.genPoly),n=this.degree-i.length;if(n>0){let s=new Uint8Array(this.degree);return s.set(i,n),s}return i};n6.exports=d0});var l0=W(o6=>{o6.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}});var p0=W(Ni=>{var a6="[0-9]+",zA="[A-Z $%*+\\-./:]+",Ea="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ea=Ea.replace(/u/g,"\\u");var kA="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ea+`)(?:.|[\r +]))+`;Ni.KANJI=new RegExp(Ea,"g");Ni.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Ni.BYTE=new RegExp(kA,"g");Ni.NUMERIC=new RegExp(a6,"g");Ni.ALPHANUMERIC=new RegExp(zA,"g");var KA=new RegExp("^"+Ea+"$"),jA=new RegExp("^"+a6+"$"),VA=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Ni.testKanji=function(e){return KA.test(e)};Ni.testNumeric=function(e){return jA.test(e)};Ni.testAlphanumeric=function(e){return VA.test(e)}});var fn=W(ct=>{var $A=l0(),g0=p0();ct.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};ct.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};ct.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};ct.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};ct.MIXED={bit:-1};ct.getCharCountIndicator=function(e,t){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!$A.isValid(t))throw new Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]};ct.getBestModeForData=function(e){return g0.testNumeric(e)?ct.NUMERIC:g0.testAlphanumeric(e)?ct.ALPHANUMERIC:g0.testKanji(e)?ct.KANJI:ct.BYTE};ct.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")};ct.isValid=function(e){return e&&e.bit&&e.ccBits};function HA(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return ct.NUMERIC;case"alphanumeric":return ct.ALPHANUMERIC;case"kanji":return ct.KANJI;case"byte":return ct.BYTE;default:throw new Error("Unknown mode: "+r)}}ct.from=function(e,t){if(ct.isValid(e))return e;try{return HA(e)}catch{return t}}});var d6=W(Yn=>{var Xc=on(),GA=u0(),f6=$c(),cn=fn(),b0=l0(),u6=7973,c6=Xc.getBCHDigit(u6);function JA(r,e,t){for(let i=1;i<=40;i++)if(e<=Yn.getCapacity(i,t,r))return i}function h6(r,e){return cn.getCharCountIndicator(r,e)+4}function WA(r,e){let t=0;return r.forEach(function(i){let n=h6(i.mode,e);t+=n+i.getBitsLength()}),t}function YA(r,e){for(let t=1;t<=40;t++)if(WA(r,t)<=Yn.getCapacity(t,e,cn.MIXED))return t}Yn.from=function(e,t){return b0.isValid(e)?parseInt(e,10):t};Yn.getCapacity=function(e,t,i){if(!b0.isValid(e))throw new Error("Invalid QR Code version");typeof i>"u"&&(i=cn.BYTE);let n=Xc.getSymbolTotalCodewords(e),s=GA.getTotalCodewordsCount(e,t),o=(n-s)*8;if(i===cn.MIXED)return o;let f=o-h6(i,e);switch(i){case cn.NUMERIC:return Math.floor(f/10*3);case cn.ALPHANUMERIC:return Math.floor(f/11*2);case cn.KANJI:return Math.floor(f/13);case cn.BYTE:default:return Math.floor(f/8)}};Yn.getBestVersionForData=function(e,t){let i,n=f6.from(t,f6.M);if(Array.isArray(e)){if(e.length>1)return YA(e,n);if(e.length===0)return 1;i=e[0]}else i=e;return JA(i.mode,i.getLength(),n)};Yn.getEncodedBits=function(e){if(!b0.isValid(e)||e<7)throw new Error("Invalid QR Code version");let t=e<<12;for(;Xc.getBCHDigit(t)-c6>=0;)t^=u6<{var v0=on(),p6=1335,XA=21522,l6=v0.getBCHDigit(p6);g6.getEncodedBits=function(e,t){let i=e.bit<<3|t,n=i<<10;for(;v0.getBCHDigit(n)-l6>=0;)n^=p6<{var ZA=fn();function eo(r){this.mode=ZA.NUMERIC,this.data=r.toString()}eo.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};eo.prototype.getLength=function(){return this.data.length};eo.prototype.getBitsLength=function(){return eo.getBitsLength(this.data.length)};eo.prototype.write=function(e){let t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);let s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};v6.exports=eo});var w6=W((VO,y6)=>{var QA=fn(),m0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function to(r){this.mode=QA.ALPHANUMERIC,this.data=r}to.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};to.prototype.getLength=function(){return this.data.length};to.prototype.getBitsLength=function(){return to.getBitsLength(this.data.length)};to.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let i=m0.indexOf(this.data[t])*45;i+=m0.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(m0.indexOf(this.data[t]),6)};y6.exports=to});var x6=W(($O,_6)=>{var eR=fn();function ro(r){this.mode=eR.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}ro.getBitsLength=function(e){return e*8};ro.prototype.getLength=function(){return this.data.length};ro.prototype.getBitsLength=function(){return ro.getBitsLength(this.data.length)};ro.prototype.write=function(r){for(let e=0,t=this.data.length;e{var tR=fn(),rR=on();function io(r){this.mode=tR.KANJI,this.data=r}io.getBitsLength=function(e){return e*13};io.prototype.getLength=function(){return this.data.length};io.prototype.getBitsLength=function(){return io.getBitsLength(this.data.length)};io.prototype.write=function(r){let e;for(e=0;e=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` +Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};E6.exports=io});var I6=W((GO,y0)=>{"use strict";var Sa={single_source_shortest_paths:function(r,e,t){var i={},n={};n[e]=0;var s=Sa.PriorityQueue.make();s.push(e,0);for(var o,f,c,u,b,y,S,I,M;!s.empty();){o=s.pop(),f=o.value,u=o.cost,b=r[f]||{};for(c in b)b.hasOwnProperty(c)&&(y=b[c],S=u+y,I=n[c],M=typeof n[c]>"u",(M||I>S)&&(n[c]=S,s.push(c,S),i[c]=f))}if(typeof t<"u"&&typeof n[t]>"u"){var T=["Could not find a path from ",e," to ",t,"."].join("");throw new Error(T)}return i},extract_shortest_path_from_predecessor_list:function(r,e){for(var t=[],i=e,n;i;)t.push(i),n=r[i],i=r[i];return t.reverse(),t},find_path:function(r,e,t){var i=Sa.single_source_shortest_paths(r,e,t);return Sa.extract_shortest_path_from_predecessor_list(i,t)},PriorityQueue:{make:function(r){var e=Sa.PriorityQueue,t={},i;r=r||{};for(i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.queue=[],t.sorter=r.sorter||e.default_sorter,t},default_sorter:function(r,e){return r.cost-e.cost},push:function(r,e){var t={value:r,cost:e};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof y0<"u"&&(y0.exports=Sa)});var P6=W(no=>{var ke=fn(),R6=m6(),T6=w6(),D6=x6(),N6=S6(),Ia=p0(),Zc=on(),iR=I6();function M6(r){return unescape(encodeURIComponent(r)).length}function Ma(r,e,t){let i=[],n;for(;(n=r.exec(t))!==null;)i.push({data:n[0],index:n.index,mode:e,length:n[0].length});return i}function C6(r){let e=Ma(Ia.NUMERIC,ke.NUMERIC,r),t=Ma(Ia.ALPHANUMERIC,ke.ALPHANUMERIC,r),i,n;return Zc.isKanjiModeEnabled()?(i=Ma(Ia.BYTE,ke.BYTE,r),n=Ma(Ia.KANJI,ke.KANJI,r)):(i=Ma(Ia.BYTE_KANJI,ke.BYTE,r),n=[]),e.concat(t,i,n).sort(function(o,f){return o.index-f.index}).map(function(o){return{data:o.data,mode:o.mode,length:o.length}})}function w0(r,e){switch(e){case ke.NUMERIC:return R6.getBitsLength(r);case ke.ALPHANUMERIC:return T6.getBitsLength(r);case ke.KANJI:return N6.getBitsLength(r);case ke.BYTE:return D6.getBitsLength(r)}}function nR(r){return r.reduce(function(e,t){let i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function sR(r){let e=[];for(let t=0;t{var eu=on(),_0=$c(),aR=G3(),fR=W3(),cR=Y3(),uR=Q3(),S0=e6(),I0=u0(),hR=s6(),Qc=d6(),dR=b6(),lR=fn(),x0=P6();function pR(r,e){let t=r.size,i=uR.getPositions(e);for(let n=0;n=0&&f<=6&&(c===0||c===6)||c>=0&&c<=6&&(f===0||f===6)||f>=2&&f<=4&&c>=2&&c<=4?r.set(s+f,o+c,!0,!0):r.set(s+f,o+c,!1,!0))}}function gR(r){let e=r.size;for(let t=8;t>f&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function E0(r,e,t){let i=r.size,n=dR.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function mR(r,e){let t=r.size,i=-1,n=t-1,s=7,o=0;for(let f=t-1;f>0;f-=2)for(f===6&&f--;;){for(let c=0;c<2;c++)if(!r.isReserved(n,f-c)){let u=!1;o>>s&1)===1),r.set(n,f-c,u),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function yR(r,e,t){let i=new aR;t.forEach(function(c){i.put(c.mode.bit,4),i.put(c.getLength(),lR.getCharCountIndicator(c.mode,r)),c.write(i)});let n=eu.getSymbolTotalCodewords(r),s=I0.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);let f=(o-i.getLengthInBits())/8;for(let c=0;c=7&&vR(c,e),mR(c,o),isNaN(i)&&(i=S0.getBestMask(c,E0.bind(null,c,t))),S0.applyMask(i,c),E0(c,t,i),{modules:c,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}O6.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");let i=_0.M,n,s;return typeof t<"u"&&(i=_0.from(t.errorCorrectionLevel,_0.M),n=Qc.from(t.version),s=S0.from(t.maskPattern),t.toSJISFunc&&eu.setToSJISFunction(t.toSJISFunc)),_R(e,n,i,s)}});var M0=W(Xn=>{function q6(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let e=r.slice().replace("#","").split("");if(e.length<3||e.length===5||e.length>8)throw new Error("Invalid hex color: "+r);(e.length===3||e.length===4)&&(e=Array.prototype.concat.apply([],e.map(function(i){return[i,i]}))),e.length===6&&e.push("F","F");let t=parseInt(e.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+e.slice(0,6).join("")}}Xn.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=typeof e.margin>"u"||e.margin===null||e.margin<0?4:e.margin,i=e.width&&e.width>=21?e.width:void 0,n=e.scale||4;return{width:i,scale:i?4:n,margin:t,color:{dark:q6(e.color.dark||"#000000ff"),light:q6(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}};Xn.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale};Xn.getImageWidth=function(e,t){let i=Xn.getScale(e,t);return Math.floor((e+t.margin*2)*i)};Xn.qrToImageData=function(e,t,i){let n=t.modules.size,s=t.modules.data,o=Xn.getScale(n,i),f=Math.floor((n+i.margin*2)*o),c=i.margin*o,u=[i.color.light,i.color.dark];for(let b=0;b=c&&y>=c&&b{var A0=M0();function xR(r,e,t){r.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=t,e.width=t,e.style.height=t+"px",e.style.width=t+"px"}function ER(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}tu.render=function(e,t,i){let n=i,s=t;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),t||(s=ER()),n=A0.getOptions(n);let o=A0.getImageWidth(e.modules.size,n),f=s.getContext("2d"),c=f.createImageData(o,o);return A0.qrToImageData(c.data,e,n),xR(f,s,o),f.putImageData(c,0,0),s};tu.renderToDataURL=function(e,t,i){let n=i;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),n||(n={});let s=tu.render(e,t,n),o=n.type||"image/png",f=n.rendererOpts||{};return s.toDataURL(o,f.quality)}});var z6=W(B6=>{var SR=M0();function U6(r,e){let t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function R0(r,e,t){let i=r+e;return typeof t<"u"&&(i+=" "+t),i}function IR(r,e,t){let i="",n=0,s=!1,o=0;for(let f=0;f0&&c>0&&r[f-1]||(i+=s?R0("M",c+t,.5+u+t):R0("m",n,0),n=0,s=!1),c+1':"",u="',b='viewBox="0 0 '+f+" "+f+'"',S=''+c+u+` +`;return typeof i=="function"&&i(null,S),S}});var K6=W(Aa=>{var MR=V3(),T0=L6(),k6=F6(),AR=z6();function D0(r,e,t,i,n){let s=[].slice.call(arguments,1),o=s.length,f=typeof s[o-1]=="function";if(!f&&!MR())throw new Error("Callback required as last argument");if(f){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(c,u){try{let b=T0.create(t,i);c(r(b,e,i))}catch(b){u(b)}})}try{let c=T0.create(t,i);n(null,r(c,e,i))}catch(c){n(c)}}Aa.create=T0.create;Aa.toCanvas=D0.bind(null,k6.render);Aa.toDataURL=D0.bind(null,k6.renderToDataURL);Aa.toString=D0.bind(null,function(r,e,t){return AR.render(r,t)})});var j6,TR,DR,NR,CR,N0,PR,ru,OR,LR,qR,FR,UR,V6,$6=Z(()=>{"use strict";j6=Ue(K6(),1);ya();Qs();Qs();va();TR=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},DR=r=>{let e=`${q3}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},NR=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},CR=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},N0={},PR=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",N0[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:N0[r.topic].signal}),t},ru={},OR=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=PR(r,e);return i.appendChild(s),ru[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:ru[r.topic].signal}),i},LR=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},qR=r=>{if(!r)return;document.getElementById(r)?.remove()},FR=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),UR=async r=>r?await(0,j6.toString)(r,{type:"svg"}):void 0,V6=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=await UR(e),o;if(s&&(o=TR(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),FR()&&n.appendChild(DR(e))),n&&t instanceof fr){let f=t.pairings,c=async b=>{try{b&&(await t.logout({topic:b}),qR(b))}catch(y){let S=ma(y);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{ru[b].abort()}},u=async b=>{try{let{approval:y}=await t.connect({topic:b,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(b)?.after(LR()),await t.login({approval:y,token:i})}catch(y){let S=ma(y);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let y of Object.values(ru))y?.abort();for(let y of Object.values(N0))y?.abort()}};if(f&&f.length>0){let b=NR();n.appendChild(b);let y=CR();b.appendChild(y);for(let S of f){let I=OR(S,c,u);b.appendChild(I)}}}return n}});var H6={};vt(H6,{loginWithMobile:()=>BR});var BR,G6=Z(()=>{"use strict";Qs();$6();ya();va();BR=async(r,e,t,i,n,s,o,f,c,u,b,y,S,I,M)=>{if(!M)throw new Error("You haven't provided the QR code container DOM element id");let T=Vc(I);if(!T||!r.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!S)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!r.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let O,N={onClientLogin:async()=>{if(r.dappProvider instanceof fr){let z=await r.dappProvider.getAddress(),F=await r.dappProvider.getSignature();i.set("address",z),i.set("loginMethod","mobile"),i.set("expires",s()),await o(r),F&&i.set("signature",F),i.set("loginToken",e);let k=t.getToken(z,e,F);i.set("accessToken",k),f.run("onLoginSuccess"),O?.replaceChildren()}},onClientLogout:async()=>{r.dappProvider instanceof fr&&await n(r)},onClientEvent:z=>{console.log("wc2 session event: ",z)}},B=new fr(N,c[r.initOptions.chainType].shortId,T,S,u,b,y);try{if(B){r.dappProvider=B,f.run("onQrPending"),await B.init();let{uri:z,approval:F}=await B.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),k=e?`${z}&token=${e}`:z;return M&&k&&(O=await V6(M,k,B,e),f.run("onQrLoaded")),await B.login({approval:F,token:e}),B}}catch(z){let F=ma(z);console.warn(`Something went wrong trying to login the user: ${F}`),f.run("onLoginFailure",F)}}});ya();var J6=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:t,qrCodeContainer:i}){this.WalletConnectV2Provider=fr;this.initMobileProvider=async(e,t,i,n,s,o)=>{let{initMobileProvider:f}=await Promise.resolve().then(()=>(K3(),k3));return f(e,t,i,n,s,o,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses)};this.loginWithMobile=async(e,t,i,n,s,o,f,c,u,b,y,S)=>{let{loginWithMobile:I}=await Promise.resolve().then(()=>(G6(),H6));return I(e,t,i,n,s,o,f,c,u,b,y,S,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses,this.qrCodeContainer)};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=t,this.qrCodeContainer=i}};export{J6 as MobileSigningProvider}; +/*! Bundled license information: + +tslib/tslib.es6.js: + (*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** *) + +js-sha3/src/sha3.js: + (** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.8.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2018 + * @license MIT + *) +*/ diff --git a/package-lock.json b/package-lock.json index d65d8a9..e133f18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5086,19 +5086,19 @@ "packages/elven.js": { "version": "1.0.0", "devDependencies": { - "@types/qrcode": "1.5.5", - "@walletconnect/sign-client": "2.17.1", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", - "esbuild": "0.24.0", - "qrcode": "1.5.4" + "esbuild": "0.24.0" } }, "packages/mobile-signing-provider": { "name": "@elven.js/mobile-signing-provider", "version": "1.0.0", "devDependencies": { - "esbuild": "0.24.0" + "@types/qrcode": "1.5.5", + "@walletconnect/sign-client": "2.17.1", + "@walletconnect/types": "2.17.1", + "@walletconnect/utils": "2.17.1", + "esbuild": "0.24.0", + "qrcode": "1.5.4" } } } diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json index 730e5c6..2bb6d98 100644 --- a/packages/elven.js/package.json +++ b/packages/elven.js/package.json @@ -22,11 +22,6 @@ "clean": "rimraf build node_modules" }, "devDependencies": { - "@types/qrcode": "1.5.5", - "@walletconnect/sign-client": "2.17.1", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", - "esbuild": "0.24.0", - "qrcode": "1.5.4" + "esbuild": "0.24.0" } } \ No newline at end of file diff --git a/packages/elven.js/src/main.ts b/packages/elven.js/src/main.ts index 2f11373..919eff3 100644 --- a/packages/elven.js/src/main.ts +++ b/packages/elven.js/src/main.ts @@ -1,12 +1,10 @@ import { Transaction } from './core/transaction'; import { initExtensionProvider } from './auth/init-extension-provider'; import { ExtensionProvider } from './core/browser-extension-signing'; -import { WalletConnectV2Provider } from './core/walletconnect-signing'; import { WalletProvider } from './core/web-wallet-signing'; import { NativeAuthClient } from './core/native-auth-client'; import { WebviewProvider } from './core/webview-signing'; import { Message } from './core/message'; -import { initMobileProvider } from './auth/init-mobile-provider'; import { initWebWalletProvider } from './auth/init-web-wallet-provider'; import { ls } from './utils/ls-helpers'; import { @@ -19,20 +17,19 @@ import { LoginOptions, InitOptions, EventStoreEvents, + MobileSigningProvider, } from './types'; import { logout } from './auth/logout'; import { loginWithExtension } from './auth/login-with-extension'; -import { loginWithMobile } from './auth/login-with-mobile'; import { loginWithWebWallet } from './auth/login-with-web-wallet'; import { accountSync } from './auth/account-sync'; import { errorParse } from './utils/error-parse'; -import { isLoginExpired } from './auth/expires-at'; +import { getNewLoginExpiresTimestamp, isLoginExpired } from './auth/expires-at'; import { EventsStore } from './events-store'; import { networkConfig, defaultApiEndpoint, defaultChainTypeConfig, - defaultWalletConnectV2RelayAddresses, } from './utils/constants'; import { getParamFromUrl } from './utils/get-param-from-url'; import { postSendTx } from './interaction/post-send-tx'; @@ -48,11 +45,13 @@ import { loginWithNativeAuthToken } from './auth/login-with-native-auth-token'; import { initializeEventsStore } from './initialize-events-store'; import { withLoginEvents } from './utils/with-login-events'; import { bytesToHex, stringToBytes } from './core/utils'; +import { TransactionsConverter } from './core/transaction-converter'; export class ElvenJS { private static initOptions: InitOptions | undefined; static dappProvider: DappProvider; static networkProvider: ApiNetworkProvider | undefined; + static mobileProvider: MobileSigningProvider | undefined; /** * Initialization of the Elven.js @@ -70,13 +69,19 @@ export class ElvenJS { chainType: defaultChainTypeConfig, apiUrl: defaultApiEndpoint, apiTimeout: 10000, - walletConnectV2ProjectId: '', - walletConnectV2RelayAddresses: defaultWalletConnectV2RelayAddresses, ...options, }; this.networkProvider = new ApiNetworkProvider(this.initOptions); + // Initialize the optional mobile provider + this.mobileProvider = this.initOptions?.externalSigningProviders?.mobile + ?.provider + ? new this.initOptions.externalSigningProviders.mobile.provider( + this.initOptions.externalSigningProviders.mobile.config + ) + : undefined; + initializeEventsStore(this.initOptions); // Catch the nativeAuthToken and login with it (for example within xPortal Hub) @@ -100,8 +105,18 @@ export class ElvenJS { if (state.loginMethod === LoginMethodsEnum.browserExtension) { this.dappProvider = await initExtensionProvider(); } - if (state.loginMethod === LoginMethodsEnum.mobile) { - this.dappProvider = await initMobileProvider(this); + if ( + state.loginMethod === LoginMethodsEnum.mobile && + this.mobileProvider + ) { + this.dappProvider = await this.mobileProvider?.initMobileProvider( + this, + logout, + networkConfig, + Message, + Transaction, + TransactionsConverter + ); } if (state.loginMethod === LoginMethodsEnum.webview) { this.dappProvider = new WebviewProvider(); @@ -187,13 +202,21 @@ export class ElvenJS { this.dappProvider = dappProvider; } - // Login with mobile app - if (loginMethod === LoginMethodsEnum.mobile) { - const dappProvider = await loginWithMobile( + // Login with optional mobile provider + if (loginMethod === LoginMethodsEnum.mobile && this.mobileProvider) { + const dappProvider = await this.mobileProvider?.loginWithMobile( this, loginToken, nativeAuthClient, - options?.qrCodeContainer + ls, + logout, + getNewLoginExpiresTimestamp, + accountSync, + EventsStore, + networkConfig, + Message, + Transaction, + TransactionsConverter ); this.dappProvider = dappProvider; } @@ -271,7 +294,10 @@ export class ElvenJS { if (this.dappProvider instanceof ExtensionProvider) { signedTx = await this.dappProvider.signTransaction(transaction); } - if (this.dappProvider instanceof WalletConnectV2Provider) { + if ( + this.mobileProvider && + this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider + ) { signedTx = await this.dappProvider.signTransaction(transaction); } if (this.dappProvider instanceof WebviewProvider) { @@ -345,16 +371,20 @@ export class ElvenJS { new Message({ data: stringToBytes(message) }) ); - if (signedMessage?.signature) { + if (typeof signedMessage !== 'string' && signedMessage?.signature) { messageSignature = bytesToHex(signedMessage.signature); } } - if (this.dappProvider instanceof WalletConnectV2Provider) { + + if ( + this.mobileProvider && + this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider + ) { const signedMessage = await this.dappProvider.signMessage( new Message({ data: stringToBytes(message) }) ); - if (signedMessage?.signature) { + if (typeof signedMessage !== 'string' && signedMessage?.signature) { messageSignature = bytesToHex(signedMessage.signature); } } @@ -364,7 +394,7 @@ export class ElvenJS { new Message({ data: stringToBytes(message) }) ); - if (signedMessage?.signature) { + if (typeof signedMessage !== 'string' && signedMessage?.signature) { messageSignature = bytesToHex(signedMessage.signature); } } diff --git a/packages/elven.js/src/types.ts b/packages/elven.js/src/types.ts index 7de4704..f4fba7a 100644 --- a/packages/elven.js/src/types.ts +++ b/packages/elven.js/src/types.ts @@ -1,19 +1,71 @@ import { ExtensionProvider } from './core/browser-extension-signing'; import { Transaction } from './core/transaction'; -import { WalletConnectV2Provider } from './core/walletconnect-signing'; import { WalletProvider } from './core/web-wallet-signing'; import { WebviewProvider } from './core/webview-signing'; import { SmartContractQueryArgs, SmartContractQueryResponse, } from './core/network-provider'; +import { NativeAuthClient } from './core/native-auth-client'; +import { Message } from './core/message'; +import { TransactionsConverter } from './core/transaction-converter'; +import { NetworkType } from './utils/constants'; +import { ls } from './utils/ls-helpers'; +import { EventsStore } from './events-store'; + +export interface MobileSigningProviderConfig { + walletConnectV2ProjectId: string; + walletConnectV2RelayAddresses: string[]; + qrCodeContainer: string | HTMLElement; +} + +export interface WalletConnectV2Provider + extends Omit { + signTransaction(transaction: Transaction): Promise; +} + +export interface MobileSigningProvider { + initMobileProvider: ( + elvenJS: any, + logout: typeof import('./auth/logout').logout, + networkConfig: typeof import('./utils/constants').networkConfig, + Message: typeof import('./core/message').Message, + Transaction: typeof import('./core/transaction').Transaction, + TransactionsConverter: typeof import('./core/transaction-converter').TransactionsConverter + ) => Promise; + loginWithMobile: ( + celvenJS: any, + loginToken: string, + nativeAuthClient: NativeAuthClient, + storage: typeof ls, + logout: (elven: any) => Promise, + getNewLoginExpiresTimestamp: () => number, + accountSync: (elven: any) => Promise, + EventsStoreClass: typeof EventsStore, + networkConfig: Record, + MessageClass: typeof Message, + TransactionClass: typeof Transaction, + TransactionsConverterClass: typeof TransactionsConverter + ) => Promise; + WalletConnectV2Provider: { + new (...args: any[]): WalletConnectV2Provider; + }; +} + +export interface MobileProvider { + new (config: MobileSigningProviderConfig): MobileSigningProvider; +} export interface InitOptions { apiUrl?: string; chainType?: string; apiTimeout?: number; - walletConnectV2ProjectId?: string; - walletConnectV2RelayAddresses?: string[]; + externalSigningProviders?: { + mobile?: { + provider: MobileProvider; + config: MobileSigningProviderConfig; + }; + }; // Login onLoginStart?: () => void; onLoginSuccess?: () => void; @@ -78,7 +130,6 @@ export enum LoginMethodsEnum { export type DappProvider = | ExtensionProvider - | WalletConnectV2Provider | WalletProvider | WebviewProvider | undefined; diff --git a/packages/elven.js/src/utils/constants.ts b/packages/elven.js/src/utils/constants.ts index 66b09b7..1e1b352 100644 --- a/packages/elven.js/src/utils/constants.ts +++ b/packages/elven.js/src/utils/constants.ts @@ -1,4 +1,4 @@ -interface NetworkType { +export interface NetworkType { id: string; shortId: string; name: string; diff --git a/packages/mobile-signing-provider/package.json b/packages/mobile-signing-provider/package.json index 37f7747..5806162 100644 --- a/packages/mobile-signing-provider/package.json +++ b/packages/mobile-signing-provider/package.json @@ -22,6 +22,14 @@ "clean": "rimraf build node_modules" }, "devDependencies": { - "esbuild": "0.24.0" + "@types/qrcode": "1.5.5", + "@walletconnect/sign-client": "2.17.1", + "@walletconnect/types": "2.17.1", + "@walletconnect/utils": "2.17.1", + "esbuild": "0.24.0", + "qrcode": "1.5.4" + }, + "peerDependencies": { + "elven.js": "*" } } \ No newline at end of file diff --git a/packages/mobile-signing-provider/src/components/constants.ts b/packages/mobile-signing-provider/src/components/constants.ts new file mode 100644 index 0000000..b39e794 --- /dev/null +++ b/packages/mobile-signing-provider/src/components/constants.ts @@ -0,0 +1,7 @@ +export const WALLETCONNECT_MULTIVERSX_METHODS = [ + 'mvx_signTransaction', + 'mvx_signTransactions', + 'mvx_signMessage', +]; +export const WALLETCONNECT_MULTIVERSX_NAMESPACE = 'mvx'; +export const WALLETCONNECT_SIGN_LOGIN_DELAY = 500; diff --git a/packages/elven.js/src/auth/init-mobile-provider.ts b/packages/mobile-signing-provider/src/components/init-mobile-provider.ts similarity index 56% rename from packages/elven.js/src/auth/init-mobile-provider.ts rename to packages/mobile-signing-provider/src/components/init-mobile-provider.ts index 7bfbad2..7ec0d1d 100644 --- a/packages/elven.js/src/auth/init-mobile-provider.ts +++ b/packages/mobile-signing-provider/src/components/init-mobile-provider.ts @@ -1,16 +1,20 @@ import { SessionEventTypes, WalletConnectV2Provider, -} from '../core/walletconnect-signing'; -import { networkConfig } from '../utils/constants'; -import { logout } from './logout'; -import { getRandomAddressFromNetwork } from '../utils/get-random-address-from-network'; +} from './walletconnect-signing'; +import { getRandomAddressFromNetwork } from './utils'; -export const initMobileProvider = async (elven: any) => { - if ( - !elven.initOptions.walletConnectV2ProjectId || - !elven.initOptions.chainType - ) { +export const initMobileProvider = async ( + elven: any, + logout: any, + networkConfig: any, + Message: any, + Transaction: any, + TransactionsConverter: any, + walletConnectV2ProjectId: string, + walletConnectV2RelayAddresses: string[] +) => { + if (!walletConnectV2ProjectId || !elven.initOptions.chainType) { return undefined; } @@ -23,14 +27,17 @@ export const initMobileProvider = async (elven: any) => { }; const relayAddress = getRandomAddressFromNetwork( - elven.initOptions.walletConnectV2RelayAddresses + walletConnectV2RelayAddresses ); const dappProviderInstance = new WalletConnectV2Provider( providerHandlers, networkConfig[elven.initOptions.chainType].shortId, relayAddress, - elven.initOptions.walletConnectV2ProjectId + walletConnectV2ProjectId, + Message, + Transaction, + TransactionsConverter ); try { diff --git a/packages/elven.js/src/auth/login-with-mobile.ts b/packages/mobile-signing-provider/src/components/login-with-mobile.ts similarity index 78% rename from packages/elven.js/src/auth/login-with-mobile.ts rename to packages/mobile-signing-provider/src/components/login-with-mobile.ts index f6646fc..5bd8971 100644 --- a/packages/elven.js/src/auth/login-with-mobile.ts +++ b/packages/mobile-signing-provider/src/components/login-with-mobile.ts @@ -1,25 +1,32 @@ -import { errorParse } from '../utils/error-parse'; +import { errorParse, getRandomAddressFromNetwork } from './utils'; import { qrCodeAndPairingsBuilder } from './qr-code-and-pairings-builder'; -import { networkConfig } from '../utils/constants'; -import { getRandomAddressFromNetwork } from '../utils/get-random-address-from-network'; import { WalletConnectV2Provider, SessionEventTypes, -} from '../core/walletconnect-signing'; -import { EventStoreEvents, LoginMethodsEnum } from '../types'; -import { ls } from '../utils/ls-helpers'; -import { logout } from './logout'; -import { getNewLoginExpiresTimestamp } from './expires-at'; -import { accountSync } from './account-sync'; -import { EventsStore } from '../events-store'; -import { DappCoreWCV2CustomMethodsEnum } from '../types'; -import { NativeAuthClient } from '../core/native-auth-client'; +} from './walletconnect-signing'; +import { + EventStoreEvents, + LoginMethodsEnum, + DappCoreWCV2CustomMethodsEnum, +} from './types'; +// TODO: think how to handle types export const loginWithMobile = async ( elven: any, loginToken: string, - nativeAuthClient: NativeAuthClient, - qrCodeContainer?: string | HTMLElement + nativeAuthClient: any, + ls: any, + logout: any, + getNewLoginExpiresTimestamp: any, + accountSync: any, + EventsStore: any, + networkConfig: any, + Message: any, + Transaction: any, + TransactionsConverter: any, + walletConnectV2ProjectId: string, + walletConnectV2RelayAddresses: string[], + qrCodeContainer: string | HTMLElement ) => { if (!qrCodeContainer) { throw new Error( @@ -28,7 +35,7 @@ export const loginWithMobile = async ( } const relayAddress = getRandomAddressFromNetwork( - elven.initOptions.walletConnectV2RelayAddresses + walletConnectV2RelayAddresses ); if (!relayAddress || !elven.networkProvider) { @@ -37,7 +44,7 @@ export const loginWithMobile = async ( ); } - if (!elven.initOptions.walletConnectV2ProjectId) { + if (!walletConnectV2ProjectId) { throw new Error( 'Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)' ); @@ -92,7 +99,10 @@ export const loginWithMobile = async ( providerHandlers, networkConfig[elven.initOptions.chainType].shortId, relayAddress, - elven.initOptions.walletConnectV2ProjectId + walletConnectV2ProjectId, + Message, + Transaction, + TransactionsConverter ); try { diff --git a/packages/elven.js/src/auth/qr-code-and-pairings-builder.ts b/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts similarity index 95% rename from packages/elven.js/src/auth/qr-code-and-pairings-builder.ts rename to packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts index 9754a05..670548b 100644 --- a/packages/elven.js/src/auth/qr-code-and-pairings-builder.ts +++ b/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts @@ -1,11 +1,8 @@ import { toString } from 'qrcode'; -import { - WalletConnectV2Provider, - PairingTypes, -} from '../core/walletconnect-signing'; -import { walletConnectDeepLink } from '../utils/constants'; -import { errorParse } from '../utils/error-parse'; -import { DappProvider, DappCoreWCV2CustomMethodsEnum } from '../types'; +import { WalletConnectV2Provider, PairingTypes } from './walletconnect-signing'; +import { walletConnectDeepLink } from './utils'; +import { errorParse } from './utils'; +import { DappCoreWCV2CustomMethodsEnum } from './types'; const htmlStringToElement = (htmlString: string) => { const template = document.createElement('template'); @@ -134,7 +131,7 @@ const generateQRCode = async (walletConnectUri: string) => { export const qrCodeAndPairingsBuilder = async ( qrCodeContainer: string | HTMLElement, walletConnectUri: string, - dappProvider: DappProvider, + dappProvider: any, token?: string ) => { if (!qrCodeContainer) diff --git a/packages/mobile-signing-provider/src/components/types.ts b/packages/mobile-signing-provider/src/components/types.ts new file mode 100644 index 0000000..a152f38 --- /dev/null +++ b/packages/mobile-signing-provider/src/components/types.ts @@ -0,0 +1,67 @@ +export enum EventStoreEvents { + // Login + onLoginStart = 'onLoginStart', + onLoginSuccess = 'onLoginSuccess', + onLoginFailure = 'onLoginFailure', + // Logout + onLogoutStart = 'onLogoutStart', + onLogoutSuccess = 'onLogoutSuccess', + onLogoutFailure = 'onLogoutFailure', + // Qr + onQrPending = 'onQrPending', + onQrLoaded = 'onQrLoaded', + // Transaction + onTxStart = 'onTxStart', + onTxSent = 'onTxSent', + onTxFinalized = 'onTxFinalized', + onTxFailure = 'onTxFailure', + // Signing + onSignMsgStart = 'onSignMsgStart', + onSignMsgFinalized = 'onSignMsgFinalized', + onSignMsgFailure = 'onSignMsgFailure', + // Query + onQueryStart = 'onQueryStart', + onQueryFinalized = 'onQueryFinalized', + onQueryFailure = 'onQueryFailure', +} + +export enum LoginMethodsEnum { + ledger = 'ledger', + mobile = 'mobile', + webWallet = 'web-wallet', + browserExtension = 'browser-extension', + xAlias = 'x-alias', + webview = 'webview', +} + +export enum DappCoreWCV2CustomMethodsEnum { + mvx_cancelAction = 'mvx_cancelAction', + mvx_signNativeAuthToken = 'mvx_signNativeAuthToken', +} + +export enum WalletConnectV2ProviderErrorMessagesEnum { + unableToInit = 'WalletConnect is unable to init', + notInitialized = 'WalletConnect is not initialized', + unableToConnect = 'WalletConnect is unable to connect', + unableToConnectExisting = 'WalletConnect is unable to connect to existing pairing', + unableToSignLoginToken = 'WalletConnect could not sign login token', + unableToSign = 'WalletConnect could not sign the message', + unableToLogin = 'WalletConnect is unable to login', + unableToHandleTopic = 'WalletConnect: Unable to handle topic update', + unableToHandleEvent = 'WalletConnect: Unable to handle events', + unableToHandleCleanup = 'WalletConnect: Unable to handle cleanup', + sessionNotConnected = 'WalletConnect Session is not connected', + sessionDeleted = 'WalletConnect Session Deleted', + sessionExpired = 'WalletConnect Session Expired', + alreadyLoggedOut = 'WalletConnect: Already logged out', + pingFailed = 'WalletConnect Ping Failed', + invalidAddress = 'WalletConnect: Invalid address', + requestDifferentChain = 'WalletConnect: Request Chain Id different than Connection Chain Id', + invalidMessageResponse = 'WalletConnect could not sign the message: invalid message response', + invalidMessageSignature = 'WalletConnect: Invalid message signature', + invalidTransactionResponse = 'WalletConnect could not sign the transactions. Invalid signatures', + invalidCustomRequestResponse = 'WalletConnect could not send the custom request', + transactionError = 'Transaction canceled', + connectionError = 'WalletConnect could not establish a connection', + invalidGuardian = 'WalletConnect: Invalid Guardian', +} diff --git a/packages/mobile-signing-provider/src/components/utils.ts b/packages/mobile-signing-provider/src/components/utils.ts new file mode 100644 index 0000000..13512cc --- /dev/null +++ b/packages/mobile-signing-provider/src/components/utils.ts @@ -0,0 +1,26 @@ +export const errorParse = (err: unknown) => { + if (typeof err === 'string') { + return err.toUpperCase(); + } else if (err instanceof Error) { + return err.message; + } + return JSON.stringify(err); +}; + +export function getRandomAddressFromNetwork(addresses: string[]) { + return addresses[Math.floor(Math.random() * addresses.length)]; +} + +export const walletConnectDeepLink = + 'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/'; + +export const hexToBytes = (hex: string): Uint8Array => { + if (!/^[0-9a-fA-F]+$/.test(hex) || hex.length % 2 !== 0) { + throw new Error('Invalid hex string'); + } + const bytes = new Uint8Array(hex.length / 2); + for (let i = 0; i < bytes.length; i++) { + bytes[i] = parseInt(hex.substr(i * 2, 2), 16); + } + return bytes; +}; diff --git a/packages/elven.js/src/core/walletconnect-signing.ts b/packages/mobile-signing-provider/src/components/walletconnect-signing.ts similarity index 96% rename from packages/elven.js/src/core/walletconnect-signing.ts rename to packages/mobile-signing-provider/src/components/walletconnect-signing.ts index 590a1ae..4bfeb3e 100644 --- a/packages/elven.js/src/core/walletconnect-signing.ts +++ b/packages/mobile-signing-provider/src/components/walletconnect-signing.ts @@ -1,7 +1,5 @@ // Based on Multiversx sdk WalletConnect signing provider with modifications -import { Message } from './message'; -import { Transaction } from './transaction'; import Client from '@walletconnect/sign-client'; import { EngineTypes, @@ -10,11 +8,6 @@ import { SignClientTypes, } from '@walletconnect/types'; import { getSdkError, isValidArray } from '@walletconnect/utils'; -import { - WALLETCONNECT_MULTIVERSX_NAMESPACE, - WALLETCONNECT_SIGN_LOGIN_DELAY, -} from './constants'; -import { WalletConnectV2ProviderErrorMessagesEnum } from './types'; import { applyTransactionSignature, addressIsValid, @@ -27,7 +20,12 @@ import { TransactionResponse, sleep, } from './walletconnect-utils'; -import { TransactionsConverter } from './transaction-converter'; + +import { + WALLETCONNECT_MULTIVERSX_NAMESPACE, + WALLETCONNECT_SIGN_LOGIN_DELAY, +} from './constants'; +import { WalletConnectV2ProviderErrorMessagesEnum } from './types'; enum Operation { SIGN_TRANSACTION = 'mvx_signTransaction', @@ -81,6 +79,9 @@ export class WalletConnectV2Provider { pairings: PairingTypes.Struct[] | undefined; processingTopic: string = ''; options: SignClientTypes.Options | undefined = {}; + Message: any; + Transaction: any; + TransactionsConverter: any; private onClientConnect: IClientConnect; private account: IProviderAccount = { address: '' }; @@ -90,12 +91,18 @@ export class WalletConnectV2Provider { chainId: string, walletConnectV2Relay: string, walletConnectV2ProjectId: string, + Message: any, + Transaction: any, + TransactionsConverter: any, options?: SignClientTypes.Options ) { this.onClientConnect = onClientConnect; this.chainId = chainId; this.walletConnectV2Relay = walletConnectV2Relay; this.walletConnectV2ProjectId = walletConnectV2ProjectId; + this.Message = Message; + this.Transaction = Transaction; + this.TransactionsConverter = TransactionsConverter; this.options = options; } @@ -385,8 +392,10 @@ export class WalletConnectV2Provider { * Signs a message and returns it signed * @param message */ - async signMessage(messageToSign: Message): Promise { - const message = new Message({ + async signMessage( + messageToSign: typeof this.Message + ): Promise { + const message = new this.Message({ data: Buffer.from(messageToSign.data), address: messageToSign.address ?? this.account.address, signer: 'wallet-connect-v2', @@ -453,7 +462,9 @@ export class WalletConnectV2Provider { * Signs a transaction and returns it signed * @param transaction */ - async signTransaction(transaction: Transaction): Promise { + async signTransaction( + transaction: typeof this.Transaction + ): Promise { if (typeof this.walletConnector === 'undefined') { console.error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); throw new Error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); @@ -470,7 +481,7 @@ export class WalletConnectV2Provider { } const plainTransaction = - TransactionsConverter.transactionToPlainObject(transaction); + this.TransactionsConverter.transactionToPlainObject(transaction); if (this.chainId !== transaction.chainID) { console.error( @@ -505,7 +516,9 @@ export class WalletConnectV2Provider { * Signs an array of transactions and returns it signed * @param transactions */ - async signTransactions(transactions: Transaction[]): Promise { + async signTransactions( + transactions: (typeof this.Transaction)[] + ): Promise<(typeof this.Transaction)[]> { if (typeof this.walletConnector === 'undefined') { console.error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); throw new Error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); @@ -530,7 +543,7 @@ export class WalletConnectV2Provider { WalletConnectV2ProviderErrorMessagesEnum.requestDifferentChain ); } - return TransactionsConverter.transactionToPlainObject(transaction); + return this.TransactionsConverter.transactionToPlainObject(transaction); }); try { diff --git a/packages/elven.js/src/core/walletconnect-utils.ts b/packages/mobile-signing-provider/src/components/walletconnect-utils.ts similarity index 98% rename from packages/elven.js/src/core/walletconnect-utils.ts rename to packages/mobile-signing-provider/src/components/walletconnect-utils.ts index 219cd1c..0576ecc 100644 --- a/packages/elven.js/src/core/walletconnect-utils.ts +++ b/packages/mobile-signing-provider/src/components/walletconnect-utils.ts @@ -1,6 +1,5 @@ // Based on Multiversx sdk WalletConnect signing provider with modifications -import { Transaction } from './transaction'; import Client from '@walletconnect/sign-client'; import { getAppMetadata } from '@walletconnect/utils'; import { @@ -133,9 +132,9 @@ export function applyTransactionSignature({ transaction, response, }: { - transaction: Transaction; + transaction: any; response: TransactionResponse; -}): Transaction { +}): any { if (!response) { console.log( WalletConnectV2ProviderErrorMessagesEnum.invalidTransactionResponse diff --git a/packages/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/mobile-signing-provider/src/mobile-signing-provider.ts index 5cdd43a..c024c7c 100644 --- a/packages/mobile-signing-provider/src/mobile-signing-provider.ts +++ b/packages/mobile-signing-provider/src/mobile-signing-provider.ts @@ -1,8 +1,80 @@ -const nothingHereForNow = () => { - const a = 1; - const add = (b: number) => a + b; - return add(2); -}; +import { WalletConnectV2Provider } from './components/walletconnect-signing'; -// SOME comment here lorem ipsum dolor sit amet -export default nothingHereForNow; +export class MobileSigningProvider { + private walletConnectV2ProjectId: string; + private walletConnectV2RelayAddresses: string[]; + private qrCodeContainer: string | HTMLElement; + WalletConnectV2Provider = WalletConnectV2Provider; + + constructor({ + walletConnectV2ProjectId, + walletConnectV2RelayAddresses, + qrCodeContainer, + }: { + walletConnectV2ProjectId: string; + walletConnectV2RelayAddresses: string[]; + qrCodeContainer: string | HTMLElement; + }) { + this.walletConnectV2ProjectId = walletConnectV2ProjectId; + this.walletConnectV2RelayAddresses = walletConnectV2RelayAddresses; + this.qrCodeContainer = qrCodeContainer; + } + // TODO: think how to handle types + initMobileProvider = async ( + context: any, + logout: any, + networkConfig: any, + Message: any, + Transaction: any, + TransactionsConverter: any + ) => { + const { initMobileProvider } = await import( + './components/init-mobile-provider' + ); + return initMobileProvider( + context, + logout, + networkConfig, + Message, + Transaction, + TransactionsConverter, + this.walletConnectV2ProjectId, + this.walletConnectV2RelayAddresses + ); + }; + + // TODO: think how to handle types + loginWithMobile = async ( + context: any, + loginToken: string, + nativeAuthClient: any, + ls: any, + logout: any, + getNewLoginExpiresTimestamp: any, + accountSync: any, + EventsStore: any, + networkConfig: any, + Message: any, + Transaction: any, + TransactionsConverter: any + ) => { + const { loginWithMobile } = await import('./components/login-with-mobile'); + return loginWithMobile( + context, + loginToken, + nativeAuthClient, + ls, + logout, + getNewLoginExpiresTimestamp, + accountSync, + EventsStore, + networkConfig, + Message, + Transaction, + TransactionsConverter, + this.walletConnectV2ProjectId, + this.walletConnectV2RelayAddresses, + this.qrCodeContainer + ); + }; +} From 12af6db4590acb34e64b3b07cc68a957757750fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 3 Nov 2024 16:55:53 +0100 Subject: [PATCH 08/13] move mobile callbacks to the externalSigningProviders --- demo-app/index.html | 5 ++--- packages/elven.js/src/initialize-events-store.ts | 9 +++++---- packages/elven.js/src/types.ts | 5 ++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/demo-app/index.html b/demo-app/index.html index 0a116d3..a3422dd 100644 --- a/demo-app/index.html +++ b/demo-app/index.html @@ -192,6 +192,8 @@

Other demos:

walletConnectV2ProjectId: 'f502675c63610bfe4454080ac86d70e6', walletConnectV2RelayAddresses: ['wss://relay.walletconnect.com'], qrCodeContainer: 'qr-code-container', + onQrPending: () => { uiPending(true); }, + onQrLoaded: () => { uiPending(false); }, } } }, @@ -210,9 +212,6 @@

Other demos:

onTxSent: (txOnNetwork) => { const hash = txOnNetwork.txHash; hash && updateTxHashContainer(hash, true); }, onTxFinalized: (tx) => { tx?.hash && updateTxHashContainer(tx.hash); uiPending(false); }, onTxFailure: (tx, error) => { displayError(error); uiPending(false); }, - // Qr code callbacks: - onQrPending: () => { uiPending(true); }, - onQrLoaded: () => { uiPending(false); }, // Signing callbacks: onSignMsgStart: (message) => { uiPending(true); }, onSignMsgFinalized: (message, messageSignature) => { messageSignature && updateOperationResultContainer(`➡️ The signature for "${message}" message:\n${messageSignature}`); uiPending(false); }, diff --git a/packages/elven.js/src/initialize-events-store.ts b/packages/elven.js/src/initialize-events-store.ts index 3b43f76..abd4364 100644 --- a/packages/elven.js/src/initialize-events-store.ts +++ b/packages/elven.js/src/initialize-events-store.ts @@ -37,11 +37,12 @@ export const initializeEventsStore = (initOptions: InitOptions) => { } // Qr code initialization - if (initOptions.onQrPending) { - EventsStore.set(EventStoreEvents.onQrPending, initOptions.onQrPending); + const mobileConfig = initOptions?.externalSigningProviders?.mobile?.config; + if (mobileConfig?.onQrPending) { + EventsStore.set(EventStoreEvents.onQrPending, mobileConfig.onQrPending); } - if (initOptions.onQrLoaded) { - EventsStore.set(EventStoreEvents.onQrLoaded, initOptions.onQrLoaded); + if (mobileConfig?.onQrLoaded) { + EventsStore.set(EventStoreEvents.onQrLoaded, mobileConfig.onQrLoaded); } // Transactions initialization diff --git a/packages/elven.js/src/types.ts b/packages/elven.js/src/types.ts index f4fba7a..c184319 100644 --- a/packages/elven.js/src/types.ts +++ b/packages/elven.js/src/types.ts @@ -17,6 +17,8 @@ export interface MobileSigningProviderConfig { walletConnectV2ProjectId: string; walletConnectV2RelayAddresses: string[]; qrCodeContainer: string | HTMLElement; + onQrPending: () => void; + onQrLoaded: () => void; } export interface WalletConnectV2Provider @@ -74,9 +76,6 @@ export interface InitOptions { onLogoutStart?: () => void; onLogoutSuccess?: () => void; onLogoutFailure?: (error: string) => void; - // Qr - onQrPending?: () => void; - onQrLoaded?: () => void; // Transaction onTxStart?: (transaction: Transaction) => void; onTxSent?: (transaction: Transaction) => void; From f97ba269a90c8cf4cea07d92277776f548d029ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Mon, 4 Nov 2024 00:45:29 +0100 Subject: [PATCH 09/13] experiments with bundle size --- configs/esbuild/index.js | 3 +- configs/tsconfig/base.json | 3 +- demo-app/elven.js | 2 +- demo-app/mobile-signing-provider.js | 46 +- package-lock.json | 320 +----------- .../mobile-signing-provider/esbuild.config.js | 456 ++++++++++++++++++ packages/mobile-signing-provider/package.json | 4 +- .../qr-code-and-pairings-builder.ts | 12 +- 8 files changed, 495 insertions(+), 351 deletions(-) diff --git a/configs/esbuild/index.js b/configs/esbuild/index.js index 79883e5..2237d17 100644 --- a/configs/esbuild/index.js +++ b/configs/esbuild/index.js @@ -14,12 +14,13 @@ export const baseConfig = { minify: true, outdir: 'build', platform: 'browser', - target: ['es2020'], + target: ['es2022'], banner: { js: banner }, treeShaking: true, // pure: ['console.log', 'console.info', 'console.debug', 'console.warn'], sourcemap: false, define: { 'process.env.NODE_ENV': '"production"', + global: 'window', }, }; diff --git a/configs/tsconfig/base.json b/configs/tsconfig/base.json index ac64156..4965c0d 100644 --- a/configs/tsconfig/base.json +++ b/configs/tsconfig/base.json @@ -15,6 +15,7 @@ "types": [ "node" ], - "skipLibCheck": true + "skipLibCheck": true, + "importHelpers": false } } \ No newline at end of file diff --git a/demo-app/elven.js b/demo-app/elven.js index c1b025f..964b5e4 100644 --- a/demo-app/elven.js +++ b/demo-app/elven.js @@ -6,6 +6,6 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var _="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ne=new Uint8Array(256);for(let n=0;n<_.length;n++)Ne[_.charCodeAt(n)]=n;var rt=new TextEncoder,it=new TextDecoder,ke=n=>/^[0-9a-fA-F]{64}$/.test(n),R=n=>rt.encode(n),I=n=>it.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),X=n=>b(R(n)),C=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},ot=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Ee=a&63;e+=_.charAt(l),e+=_.charAt(u),e+=r+1I(C(n)),E=n=>{let e=typeof n=="string"?R(n):n;return ot(e)};function st(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function at(n,e,t){let r=n;for(let o=0;o{Te([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&Te([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function we(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=st(r);at(t,i,o)}return t}function Ue(n){let e=[];return Te([],n,e),e.join("&")}var ct=()=>typeof window<"u"&&typeof window.location<"u",z=()=>{if(ct()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},ye=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var P=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";ke(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:b(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return b(this.address)}};var Oe=1e9,Me=0,J=2,We=2,be=64,_e=1;var De="sdk-js";var Fe="hook/login",Ge="hook/logout";var He="hook/sign",$e="hook/2fa",Be="hook/sign-message",Q="walletProviderStatus",Y="transactionsSigned";var qe={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var L=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||Oe),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||J),this.options=Number(e.options?.valueOf()||Me),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var Z=class extends v{constructor(){super("Async timer already running")}},ee=class extends v{constructor(){super("Async timer aborted")}};var D=class extends v{constructor(){super("Expected transaction status not reached")}},j=class extends v{constructor(){super("Expected transaction events not found")}};var te=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var ne=class extends v{constructor(){super("Cannot sign single transaction.")}},re=class extends v{constructor(){super("Account is not connected.")}},K=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},ie=class extends Error{constructor(){super("Cannot get signed message")}};var F=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new Z;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new ee),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var ve=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},S=class S{constructor(e,t={}){this.fetcher=new ve(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||S.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||S.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||S.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new D;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new te;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new D;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new j;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new j;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new D;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==be)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${be}.`);return t}async awaitConditionally(e,t,r){let o=new F("watcher:periodic"),i=new F("watcher:patience"),s=new F("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};S.DefaultPollingInterval=6e3,S.DefaultTimeout=S.DefaultPollingInterval*15,S.DefaultPatience=0,S.NoopOnStatusReceived=()=>{};var V=S;var w=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||_e,this.signer=e.signer||De}};var p=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?E(e.senderUsername):void 0,receiverUsername:e.receiverUsername?E(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?E(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?b(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?b(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new L({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:q(e.receiverUsername||""),sender:e.sender,senderUsername:q(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?C(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var N=class N{constructor(){this.account={address:""};this.initialized=!1;if(N._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");N._instance=this}static getInstance(){return N._instance}setAddress(e){return this.account.address=e,N._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new ne;return t[0]}ensureConnected(){if(!this.account.address)throw new re}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>p.transactionToPlainObject(r))});try{return t.map(o=>p.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:I(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new w({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};N._instance=new N;var O=N;var oe="elvenjs_state",ze="https://devnet-api.multiversx.com";var k="/dapp/init",se="devnet";var f={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(oe);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(oe,JSON.stringify(t))},clear(){localStorage.removeItem(oe)}};var ae=async()=>{let n=O.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var xe=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},y=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:Fe,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:Ge,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Be,callbackUrl:t?.callbackUrl,params:{message:I(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=we(e);if((t.status?.toString()||"")!=="signed")throw new ie;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint($e,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(He,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=we(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,Q)&&e[Q]===Y}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new K;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new K;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var Se=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},G=class{constructor(e){this.config=Object.assign(new Se,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(s=>s.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(X(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var ce=(n,e)=>t=>{let r=t.data;try{r=ye()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!ye()&&t.origin!=z()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",ce(n,e)),e({type:o,payload:i}))};var U=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",ce("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>p.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>p.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:I(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new w({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),z()):t.parent&&t.parent.postMessage(e,z())),await this.waitingForResponse(qe[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",ce(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var T=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var Ae=async(n,e)=>{let t=T("signature"),r=T("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new y(`${n}${k}`);if(t&&e&&r){let l=new G({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var de=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var le=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||se,this.apiUrl=e||f[this.chainType]?.apiAddress,this.apiTimeout=r||f[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=p.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new de(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:C(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>X(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var A=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(A||{}),M=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(M||{}),lt=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(lt||{}),Pe=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(Pe||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var h=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var ue=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=h(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var H=()=>new Date().setHours(new Date().getHours()+24),ge=n=>Date.now()>n;var $=async n=>{let e=d.get("address"),t=d.get("expires");if(!(t&&ge(t))&&e&&n.networkProvider){let o=new P(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=h(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Qe=async(n,e,t,r="/")=>{let o=await ae(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=h(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",H()),await $(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var Re=async(n,e,t,r)=>{let o=new y(`${n}${k}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",f[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",H()),d.set("loginToken",e),o}catch(a){let l=h(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var pe=async(n,e)=>{c.run("onTxSent",n);let r=await new V(e).awaitCompleted(n.txHash),o=r.sender,i=new P(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var he=n=>{let e=n.sender,t=new P(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var je=async(n,e,t,r)=>{if(T(Q)===Y&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=T("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=E(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new y(`${t}${k}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=p.plainObjectToTransaction(l);u.nonce=BigInt(r),he(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await pe(m,e)}catch(m){let Le=`Getting transaction information failed! ${h(m)}`;throw c.run("onTxFailure",u,Le),new Error(Le)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var Ke=n=>{let e=d.get("activeGuardian");return e&&(n.version=J,n.options=We,n.guardian=e),n},Ve=async(n,e)=>{let t=new y(`${e}${k}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},Xe=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Je=()=>{let n=!T("walletProviderStatus"),e=T("status")==="signed",t=T("message"),r=T("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ut(n){try{let e=atob(n),t=btoa(e),r=q(n),o=E(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function B(n){return ut(n)?atob(n):n}var me=n=>Object.prototype.toString.call(n)==="[object String]";var Ye=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(B(i)),a=B(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Ze=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=B(t),s=B(r),a=Ye(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function et(n,e){let t=Ze(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new U)}var tt=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure),n.onQrPending&&c.set("onQrPending",n.onQrPending),n.onQrLoaded&&c.set("onQrLoaded",n.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var fe=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=h(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var W=class W{static async init(e){let t=d.get();if(t.expires&&ge(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:se,apiUrl:ze,apiTimeout:1e4,...e},this.networkProvider=new le(this.initOptions),this.mobileProvider=this.initOptions?.externalSigningProviders?.mobile?.provider?new this.initOptions.externalSigningProviders.mobile.provider(this.initOptions.externalSigningProviders.mobile.config):void 0,tt(this.initOptions);let r=T("accessToken");r&&await fe(async i=>{et(r,this),await $(this),i()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&T("address"))&&t?.loginMethod&&(await fe(async i=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await ae()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this,ue,f,w,L,p)),t.loginMethod==="webview"&&(this.dappProvider=new U),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await Ae(f[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await Ae(f[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await $(this),i()}),this.initOptions?.chainType&&(await je(this.dappProvider,this.networkProvider,f[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Je()))}static async login(e,t){if(!Object.values(M).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await fe(async()=>{let o=new G({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize();if(e==="browser-extension"){let s=await Qe(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o,d,ue,H,$,c,f,w,L,p);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await Re(f[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await Re(f[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await ue(this);return this.dappProvider=void 0,e}catch(e){let t=h(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=Ke(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof O&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof y&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=Xe(t);if(o||he(t),o&&this.initOptions?.chainType){await Ve(t,f[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await pe(i,this.networkProvider)}}catch(r){let o=h(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof O){let i=await this.dappProvider.signMessage(new w({data:R(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new w({data:R(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new w({data:R(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof y){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new w({data:R(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=h(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=h(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}};W.storage=d,W.destroy=()=>{W.networkProvider=void 0,W.dappProvider=void 0,W.initOptions=void 0,c.clear()};var Ie=W;var gt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},nt=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),nt({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{P as Account,lt as DappCoreWCV2CustomMethodsEnum,Ie as ElvenJS,A as EventStoreEvents,M as LoginMethodsEnum,L as Transaction,V as TransactionWatcher,Pe as WebWalletUrlParamsEnum,nt as formatAmount,gt as parseAmount}; +var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ie=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),A=n=>et.encode(n),R=n=>tt.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),j=n=>b(A(n)),k=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},nt=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Ae=a&63;e+=C.charAt(l),e+=C.charAt(u),e+=r+1R(k(n)),I=n=>{let e=typeof n=="string"?A(n):n;return nt(e)};function rt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function it(n,e,t){let r=n;for(let o=0;o{he([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&he([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function me(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=rt(r);it(t,i,o)}return t}function Le(n){let e=[];return he([],n,e),e.join("&")}var ot=()=>typeof window<"u"&&typeof window.location<"u",$=()=>{if(ot()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},fe=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var P=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Ee(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:b(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return b(this.address)}};var ke=1e9,Ue=0,K=2,Oe=2,Te=64,Ce=1;var Me="sdk-js";var We="hook/login",_e="hook/logout";var De="hook/sign",Fe="hook/2fa",Ge="hook/sign-message",B="walletProviderStatus",V="transactionsSigned";var He={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var E=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||ke),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||K),this.options=Number(e.options?.valueOf()||Ue),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var J=class extends v{constructor(){super("Async timer already running")}},X=class extends v{constructor(){super("Async timer aborted")}};var M=class extends v{constructor(){super("Expected transaction status not reached")}},q=class extends v{constructor(){super("Expected transaction events not found")}};var Y=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var Z=class extends v{constructor(){super("Cannot sign single transaction.")}},ee=class extends v{constructor(){super("Account is not connected.")}},z=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},te=class extends Error{constructor(){super("Cannot get signed message")}};var W=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new J;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new X),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var we=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Q=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new we(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new Y;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==Te)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${Te}.`);return t}async awaitConditionally(e,t,r){let o=new W("watcher:periodic"),i=new W("watcher:patience"),s=new W("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var w=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ce,this.signer=e.signer||Me}};var p=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?I(e.senderUsername):void 0,receiverUsername:e.receiverUsername?I(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?I(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?b(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?b(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new E({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:H(e.receiverUsername||""),sender:e.sender,senderUsername:H(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?k(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var U=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new Z;return t[0]}ensureConnected(){if(!this.account.address)throw new ee}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>p.transactionToPlainObject(r))});try{return t.map(o=>p.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:R(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new w({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var ne="elvenjs_state",$e="https://devnet-api.multiversx.com";var L="/dapp/init",re="devnet";var f={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(ne);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(ne,JSON.stringify(t))},clear(){localStorage.removeItem(ne)}};var ie=async()=>{let n=U.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var ye=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},y=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:We,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:_e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Ge,callbackUrl:t?.callbackUrl,params:{message:R(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=me(e);if((t.status?.toString()||"")!=="signed")throw new te;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Fe,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(De,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=me(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,B)&&e[B]===V}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new z;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new z;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var be=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},_=class{constructor(e){this.config=Object.assign(new be,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(s=>s.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(j(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var oe=(n,e)=>t=>{let r=t.data;try{r=fe()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!fe()&&t.origin!=$()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",oe(n,e)),e({type:o,payload:i}))};var N=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",oe("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>p.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>p.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:R(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new w({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),$()):t.parent&&t.parent.postMessage(e,$())),await this.waitingForResponse(He[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",oe(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var T=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var ve=async(n,e)=>{let t=T("signature"),r=T("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new y(`${n}${L}`);if(t&&e&&r){let l=new _({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var se=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var ae=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||re,this.apiUrl=e||f[this.chainType]?.apiAddress,this.apiTimeout=r||f[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=p.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new se(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:k(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>j(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var S=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(S||{}),O=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(O||{}),at=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(at||{}),xe=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(xe||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var h=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var ce=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=h(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var D=()=>new Date().setHours(new Date().getHours()+24),de=n=>Date.now()>n;var F=async n=>{let e=d.get("address"),t=d.get("expires");if(!(t&&de(t))&&e&&n.networkProvider){let o=new P(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=h(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Be=async(n,e,t,r="/")=>{let o=await ie(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=h(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",D()),await F(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var Se=async(n,e,t,r)=>{let o=new y(`${n}${L}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",f[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",D()),d.set("loginToken",e),o}catch(a){let l=h(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var le=async(n,e)=>{c.run("onTxSent",n);let r=await new Q(e).awaitCompleted(n.txHash),o=r.sender,i=new P(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var ue=n=>{let e=n.sender,t=new P(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var qe=async(n,e,t,r)=>{if(T(B)===V&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=T("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=I(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new y(`${t}${L}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=p.plainObjectToTransaction(l);u.nonce=BigInt(r),ue(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await le(m,e)}catch(m){let Re=`Getting transaction information failed! ${h(m)}`;throw c.run("onTxFailure",u,Re),new Error(Re)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var ze=n=>{let e=d.get("activeGuardian");return e&&(n.version=K,n.options=Oe,n.guardian=e),n},Qe=async(n,e)=>{let t=new y(`${e}${L}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},je=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ke=()=>{let n=!T("walletProviderStatus"),e=T("status")==="signed",t=T("message"),r=T("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ct(n){try{let e=atob(n),t=btoa(e),r=H(n),o=I(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function G(n){return ct(n)?atob(n):n}var ge=n=>Object.prototype.toString.call(n)==="[object String]";var Ve=n=>{if(!n||!ge(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(G(i)),a=G(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Je=n=>{if(!n||!ge(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=G(t),s=G(r),a=Ve(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function Xe(n,e){let t=Je(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new N)}var Ye=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&c.set("onQrPending",e.onQrPending),e?.onQrLoaded&&c.set("onQrLoaded",e.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var pe=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=h(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var Pe=class{static async init(e){let t=d.get();if(t.expires&&de(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:re,apiUrl:$e,apiTimeout:1e4,...e},this.networkProvider=new ae(this.initOptions),this.mobileProvider=this.initOptions?.externalSigningProviders?.mobile?.provider?new this.initOptions.externalSigningProviders.mobile.provider(this.initOptions.externalSigningProviders.mobile.config):void 0,Ye(this.initOptions);let r=T("accessToken");r&&await pe(async i=>{Xe(r,this),await F(this),i()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&T("address"))&&t?.loginMethod&&(await pe(async i=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await ie()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this,ce,f,w,E,p)),t.loginMethod==="webview"&&(this.dappProvider=new N),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await ve(f[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await ve(f[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await F(this),i()}),this.initOptions?.chainType&&(await qe(this.dappProvider,this.networkProvider,f[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Ke()))}static async login(e,t){if(!Object.values(O).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await pe(async()=>{let o=new _({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize();if(e==="browser-extension"){let s=await Be(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o,d,ce,D,F,c,f,w,E,p);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await Se(f[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await Se(f[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await ce(this);return this.dappProvider=void 0,e}catch(e){let t=h(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=ze(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof N&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof y&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=je(t);if(o||ue(t),o&&this.initOptions?.chainType){await Qe(t,f[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await le(i,this.networkProvider)}}catch(r){let o=h(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new w({data:A(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new w({data:A(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof N){let i=await this.dappProvider.signMessage(new w({data:A(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof y){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new w({data:A(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=h(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=h(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}static{this.storage=d}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,c.clear()}}};var dt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},Ze=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),Ze({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{P as Account,at as DappCoreWCV2CustomMethodsEnum,Pe as ElvenJS,S as EventStoreEvents,O as LoginMethodsEnum,E as Transaction,Q as TransactionWatcher,xe as WebWalletUrlParamsEnum,Ze as formatAmount,dt as parseAmount}; /** keccak.js https://github.com/adraffy/keccak.js @license MIT */ /** https://github.com/emn178/js-sha3/blob/master/src/sha3.js @license MIT */ diff --git a/demo-app/mobile-signing-provider.js b/demo-app/mobile-signing-provider.js index 1a6796a..f08eb98 100644 --- a/demo-app/mobile-signing-provider.js +++ b/demo-app/mobile-signing-provider.js @@ -6,7 +6,7 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var W6=Object.create;var Ta=Object.defineProperty;var Y6=Object.getOwnPropertyDescriptor;var X6=Object.getOwnPropertyNames;var Z6=Object.getPrototypeOf,Q6=Object.prototype.hasOwnProperty;var C0=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Z=(r,e)=>()=>(r&&(e=r(r=0)),e);var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),vt=(r,e)=>{for(var t in e)Ta(r,t,{get:e[t],enumerable:!0})},Ra=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of X6(e))!Q6.call(r,n)&&n!==t&&Ta(r,n,{get:()=>e[n],enumerable:!(i=Y6(e,n))||i.enumerable});return r},Lt=(r,e,t)=>(Ra(r,e,"default"),t&&Ra(t,e,"default")),Ue=(r,e,t)=>(t=r!=null?W6(Z6(r)):{},Ra(e||!r||!r.__esModule?Ta(t,"default",{value:r,enumerable:!0}):t,r)),so=r=>Ra(Ta({},"__esModule",{value:!0}),r);var _n=W((kR,ou)=>{"use strict";var Zn=typeof Reflect=="object"?Reflect:null,P0=Zn&&typeof Zn.apply=="function"?Zn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Da;Zn&&typeof Zn.ownKeys=="function"?Da=Zn.ownKeys:Object.getOwnPropertySymbols?Da=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Da=function(e){return Object.getOwnPropertyNames(e)};function ew(r){console&&console.warn&&console.warn(r)}var L0=Number.isNaN||function(e){return e!==e};function Ve(){Ve.init.call(this)}ou.exports=Ve;ou.exports.once=nw;Ve.EventEmitter=Ve;Ve.prototype._events=void 0;Ve.prototype._eventsCount=0;Ve.prototype._maxListeners=void 0;var O0=10;function Na(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ve,"defaultMaxListeners",{enumerable:!0,get:function(){return O0},set:function(r){if(typeof r!="number"||r<0||L0(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");O0=r}});Ve.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ve.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||L0(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function q0(r){return r._maxListeners===void 0?Ve.defaultMaxListeners:r._maxListeners}Ve.prototype.getMaxListeners=function(){return q0(this)};Ve.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")P0(c,this,t);else for(var u=c.length,b=k0(c,u),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,ew(f)}return r}Ve.prototype.addListener=function(e,t){return F0(this,e,t,!1)};Ve.prototype.on=Ve.prototype.addListener;Ve.prototype.prependListener=function(e,t){return F0(this,e,t,!0)};function tw(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function U0(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=tw.bind(i);return n.listener=t,i.wrapFn=n,n}Ve.prototype.once=function(e,t){return Na(t),this.on(e,U0(this,e,t)),this};Ve.prototype.prependOnceListener=function(e,t){return Na(t),this.prependListener(e,U0(this,e,t)),this};Ve.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Na(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():rw(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ve.prototype.off=Ve.prototype.removeListener;Ve.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function B0(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?iw(n):k0(n,n.length)}Ve.prototype.listeners=function(e){return B0(this,e,!0)};Ve.prototype.rawListeners=function(e){return B0(this,e,!1)};Ve.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):z0.call(r,e)};Ve.prototype.listenerCount=z0;function z0(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ve.prototype.eventNames=function(){return this._eventsCount>0?Da(this._events):[]};function k0(r,e){for(var t=new Array(e),i=0;ifu,__asyncDelegator:()=>mw,__asyncGenerator:()=>vw,__asyncValues:()=>yw,__await:()=>oo,__awaiter:()=>hw,__classPrivateFieldGet:()=>Ew,__classPrivateFieldSet:()=>Sw,__createBinding:()=>lw,__decorate:()=>fw,__exportStar:()=>pw,__extends:()=>ow,__generator:()=>dw,__importDefault:()=>xw,__importStar:()=>_w,__makeTemplateObject:()=>ww,__metadata:()=>uw,__param:()=>cw,__read:()=>j0,__rest:()=>aw,__spread:()=>gw,__spreadArrays:()=>bw,__values:()=>cu});function ow(r,e){au(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function aw(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function cw(r,e){return function(t,i){e(t,i,r)}}function uw(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function hw(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{u(i.next(b))}catch(y){o(y)}}function c(b){try{u(i.throw(b))}catch(y){o(y)}}function u(b){b.done?s(b.value):n(b.value).then(f,c)}u((i=i.apply(r,e||[])).next())})}function dw(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(u){return function(b){return c([u,b])}}function c(u){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function j0(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function gw(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{c(i[S](I))}catch(M){y(s[0][3],M)}}function c(S){S.value instanceof oo?Promise.resolve(S.value.v).then(u,b):y(s[0][2],S)}function u(S){f("next",S)}function b(S){f("throw",S)}function y(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function mw(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:oo(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function yw(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof cu=="function"?cu(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,c){o=r[s](o),n(f,c,o.done,o.value)})}}function n(s,o,f,c){Promise.resolve(c).then(function(u){s({value:u,done:f})},o)}}function ww(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function _w(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function xw(r){return r&&r.__esModule?r:{default:r}}function Ew(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Sw(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var au,fu,es=Z(()=>{au=function(r,e){return au=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},au(r,e)};fu=function(){return fu=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Ca,"__esModule",{value:!0});Ca.delay=void 0;function Iw(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Ca.delay=Iw});var $0=W(ts=>{"use strict";Object.defineProperty(ts,"__esModule",{value:!0});ts.ONE_THOUSAND=ts.ONE_HUNDRED=void 0;ts.ONE_HUNDRED=100;ts.ONE_THOUSAND=1e3});var H0=W(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.ONE_YEAR=ee.FOUR_WEEKS=ee.THREE_WEEKS=ee.TWO_WEEKS=ee.ONE_WEEK=ee.THIRTY_DAYS=ee.SEVEN_DAYS=ee.FIVE_DAYS=ee.THREE_DAYS=ee.ONE_DAY=ee.TWENTY_FOUR_HOURS=ee.TWELVE_HOURS=ee.SIX_HOURS=ee.THREE_HOURS=ee.ONE_HOUR=ee.SIXTY_MINUTES=ee.THIRTY_MINUTES=ee.TEN_MINUTES=ee.FIVE_MINUTES=ee.ONE_MINUTE=ee.SIXTY_SECONDS=ee.THIRTY_SECONDS=ee.TEN_SECONDS=ee.FIVE_SECONDS=ee.ONE_SECOND=void 0;ee.ONE_SECOND=1;ee.FIVE_SECONDS=5;ee.TEN_SECONDS=10;ee.THIRTY_SECONDS=30;ee.SIXTY_SECONDS=60;ee.ONE_MINUTE=ee.SIXTY_SECONDS;ee.FIVE_MINUTES=ee.ONE_MINUTE*5;ee.TEN_MINUTES=ee.ONE_MINUTE*10;ee.THIRTY_MINUTES=ee.ONE_MINUTE*30;ee.SIXTY_MINUTES=ee.ONE_MINUTE*60;ee.ONE_HOUR=ee.SIXTY_MINUTES;ee.THREE_HOURS=ee.ONE_HOUR*3;ee.SIX_HOURS=ee.ONE_HOUR*6;ee.TWELVE_HOURS=ee.ONE_HOUR*12;ee.TWENTY_FOUR_HOURS=ee.ONE_HOUR*24;ee.ONE_DAY=ee.TWENTY_FOUR_HOURS;ee.THREE_DAYS=ee.ONE_DAY*3;ee.FIVE_DAYS=ee.ONE_DAY*5;ee.SEVEN_DAYS=ee.ONE_DAY*7;ee.THIRTY_DAYS=ee.ONE_DAY*30;ee.ONE_WEEK=ee.SEVEN_DAYS;ee.TWO_WEEKS=ee.ONE_WEEK*2;ee.THREE_WEEKS=ee.ONE_WEEK*3;ee.FOUR_WEEKS=ee.ONE_WEEK*4;ee.ONE_YEAR=ee.ONE_DAY*365});var uu=W(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});var G0=(es(),so(Qn));G0.__exportStar($0(),Pa);G0.__exportStar(H0(),Pa)});var W0=W(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.fromMiliseconds=rs.toMiliseconds=void 0;var J0=uu();function Mw(r){return r*J0.ONE_THOUSAND}rs.toMiliseconds=Mw;function Aw(r){return Math.floor(r/J0.ONE_THOUSAND)}rs.fromMiliseconds=Aw});var X0=W(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var Y0=(es(),so(Qn));Y0.__exportStar(V0(),Oa);Y0.__exportStar(W0(),Oa)});var Z0=W(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.Watch=void 0;var La=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};ao.Watch=La;ao.default=La});var Q0=W(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});qa.IWatch=void 0;var hu=class{};qa.IWatch=hu});var ep=W(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var Rw=(es(),so(Qn));Rw.__exportStar(Q0(),du)});var ns=W(is=>{"use strict";Object.defineProperty(is,"__esModule",{value:!0});var Fa=(es(),so(Qn));Fa.__exportStar(X0(),is);Fa.__exportStar(Z0(),is);Fa.__exportStar(ep(),is);Fa.__exportStar(uu(),is)});var hr,tp=Z(()=>{hr=class{}});var lu=Z(()=>{tp()});var ip,Ba,pu,rp,xn,Ua,np=Z(()=>{ip=Ue(_n()),Ba=Ue(ns());lu();pu=class extends hr{constructor(e){super()}},rp=Ba.FIVE_SECONDS,xn={pulse:"heartbeat_pulse"},Ua=class r extends pu{constructor(e){super(e),this.events=new ip.EventEmitter,this.interval=rp,this.interval=e?.interval||rp}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,Ba.toMiliseconds)(this.interval))}pulse(){this.events.emit(xn.pulse)}}});function Cw(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){Pw(r);return}return e}function Pw(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function fo(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!Nw.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(Tw.test(r)||Dw.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,Cw)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}var Tw,Dw,Nw,sp=Z(()=>{Tw=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Dw=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Nw=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/});function Ow(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ut(r,...e){try{return Ow(r(...e))}catch(t){return Promise.reject(t)}}function Lw(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function qw(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function co(r){if(Lw(r))return String(r);if(qw(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return co(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function op(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}function ap(r){if(typeof r=="string")return r;op();let e=Buffer.from(r).toString("base64");return gu+e}function fp(r){return typeof r!="string"||!r.startsWith(gu)?r:(op(),Buffer.from(r.slice(gu.length),"base64"))}function qt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function cp(...r){return qt(r.join(":"))}function uo(r){return r=qt(r),r?r+":":""}var gu,up=Z(()=>{gu="base64:"});function lp(r={}){let e={mounts:{"":r.driver||Uw()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=u=>{for(let b of e.mountpoints)if(u.startsWith(b))return{base:b,relativeKey:u.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,b)=>e.mountpoints.filter(y=>y.startsWith(u)||b&&u.startsWith(y)).map(y=>({relativeBase:u.length>y.length?u.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(u,b)=>{if(e.watching){b=qt(b);for(let y of e.watchListeners)y(u,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let u in e.mounts)e.unwatch[u]=await hp(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(let u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},f=(u,b,y)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of u){let T=typeof M=="string",O=qt(T?M:M.key),N=T?void 0:M.value,B=T||!M.options?b:{...b,...M.options},z=t(O);I(z).items.push({key:O,value:N,relativeKey:z.relativeKey,options:B})}return Promise.all([...S.values()].map(M=>y(M))).then(M=>M.flat())},c={hasItem(u,b={}){u=qt(u);let{relativeKey:y,driver:S}=t(u);return ut(S.hasItem,y,b)},getItem(u,b={}){u=qt(u);let{relativeKey:y,driver:S}=t(u);return ut(S.getItem,y,b).then(I=>fo(I))},getItems(u,b){return f(u,b,y=>y.driver.getItems?ut(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:cp(y.base,I.key),value:fo(I.value)}))):Promise.all(y.items.map(S=>ut(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:fo(I)})))))},getItemRaw(u,b={}){u=qt(u);let{relativeKey:y,driver:S}=t(u);return S.getItemRaw?ut(S.getItemRaw,y,b):ut(S.getItem,y,b).then(I=>fp(I))},async setItem(u,b,y={}){if(b===void 0)return c.removeItem(u);u=qt(u);let{relativeKey:S,driver:I}=t(u);I.setItem&&(await ut(I.setItem,S,co(b),y),I.watch||n("update",u))},async setItems(u,b){await f(u,b,async y=>{if(y.driver.setItems)return ut(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:co(S.value),options:S.options})),b);y.driver.setItem&&await Promise.all(y.items.map(S=>ut(y.driver.setItem,S.relativeKey,co(S.value),S.options)))})},async setItemRaw(u,b,y={}){if(b===void 0)return c.removeItem(u,y);u=qt(u);let{relativeKey:S,driver:I}=t(u);if(I.setItemRaw)await ut(I.setItemRaw,S,b,y);else if(I.setItem)await ut(I.setItem,S,ap(b),y);else return;I.watch||n("update",u)},async removeItem(u,b={}){typeof b=="boolean"&&(b={removeMeta:b}),u=qt(u);let{relativeKey:y,driver:S}=t(u);S.removeItem&&(await ut(S.removeItem,y,b),(b.removeMeta||b.removeMata)&&await ut(S.removeItem,y+"$",b),S.watch||n("remove",u))},async getMeta(u,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),u=qt(u);let{relativeKey:y,driver:S}=t(u),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ut(S.getMeta,y,b)),!b.nativeOnly){let M=await ut(S.getItem,y+"$",b).then(T=>fo(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(u,b,y={}){return this.setItem(u+"$",b,y)},removeMeta(u,b={}){return this.removeItem(u+"$",b)},async getKeys(u,b={}){u=uo(u);let y=i(u,!0),S=[],I=[];for(let M of y){let T=await ut(M.driver.getKeys,M.relativeBase,b);for(let O of T){let N=M.mountpoint+qt(O);S.some(B=>N.startsWith(B))||I.push(N)}S=[M.mountpoint,...S.filter(O=>!O.startsWith(M.mountpoint))]}return u?I.filter(M=>M.startsWith(u)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(u,b={}){u=uo(u),await Promise.all(i(u,!1).map(async y=>{if(y.driver.clear)return ut(y.driver.clear,y.relativeBase,b);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",b);return Promise.all(S.map(I=>y.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>dp(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,b){if(u=uo(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[u]=b,e.watching&&Promise.resolve(hp(b,n,u)).then(y=>{e.unwatch[u]=y}).catch(console.error),c},async unmount(u,b=!0){u=uo(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),b&&await dp(e.mounts[u]),e.mountpoints=e.mountpoints.filter(y=>y!==u),delete e.mounts[u])},getMount(u=""){u=qt(u)+":";let b=t(u);return{driver:b.driver,base:b.base}},getMounts(u="",b={}){return u=qt(u),i(u,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(u,b={})=>c.getKeys(u,b),get:(u,b={})=>c.getItem(u,b),set:(u,b,y={})=>c.setItem(u,b,y),has:(u,b={})=>c.hasItem(u,b),del:(u,b={})=>c.removeItem(u,b),remove:(u,b={})=>c.removeItem(u,b)};return c}function hp(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function dp(r){typeof r.dispose=="function"&&await ut(r.dispose)}var Fw,Uw,pp=Z(()=>{sp();up();Fw="memory",Uw=()=>{let r=new Map;return{name:Fw,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}}});function En(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function vu(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=En(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}function ho(){return bu||(bu=vu("keyval-store","keyval")),bu}function mu(r,e=ho()){return e("readonly",t=>En(t.get(r)))}function gp(r,e,t=ho()){return t("readwrite",i=>(i.put(e,r),En(i.transaction)))}function bp(r,e=ho()){return e("readwrite",t=>(t.delete(r),En(t.transaction)))}function vp(r=ho()){return r("readwrite",e=>(e.clear(),En(e.transaction)))}function Bw(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},En(r.transaction)}function mp(r=ho()){return r("readonly",e=>{if(e.getAllKeys)return En(e.getAllKeys());let t=[];return Bw(e,i=>t.push(i.key)).then(()=>t)})}var bu,yp=Z(()=>{});function jr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return kw(r)}catch{return r}}function Zt(r){return typeof r=="string"?r:zw(r)||""}var zw,kw,ss=Z(()=>{zw=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),kw=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)}});function Hw(r){var e;return[r[0],jr((e=r[1])!=null?e:"")]}var Kw,jw,Vw,$w,wu,yu,za,_u,Gw,wp,Jw,Ww,ka,_p=Z(()=>{pp();yp();ss();Kw="idb-keyval",jw=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=vu(r.dbName,r.storeName)),{name:Kw,options:r,async hasItem(n){return!(typeof await mu(t(n),i)>"u")},async getItem(n){return await mu(t(n),i)??null},setItem(n,s){return gp(t(n),s,i)},removeItem(n){return bp(t(n),i)},getKeys(){return mp(i)},clear(){return vp(i)}}},Vw="WALLET_CONNECT_V2_INDEXED_DB",$w="keyvaluestorage",wu=class{constructor(){this.indexedDb=lp({driver:jw({dbName:Vw,storeName:$w})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Zt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},yu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},za={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof yu<"u"&&yu.localStorage?za.exports=yu.localStorage:typeof window<"u"&&window.localStorage?za.exports=window.localStorage:za.exports=new e})();_u=class{constructor(){this.localStorage=za.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Hw)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return jr(t)}async setItem(e,t){this.localStorage.setItem(e,Zt(t))}async removeItem(e){this.localStorage.removeItem(e)}},Gw="wc_storage_version",wp=1,Jw=async(r,e,t)=>{let i=Gw,n=await e.getItem(i);if(n&&n>=wp){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let c=f.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){let u=await r.getItem(f);await e.setItem(f,u),o.push(f)}}await e.setItem(i,wp),t(e),Ww(r,o)},Ww=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},ka=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new _u;this.storage=e;try{let t=new wu;Jw(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}}});var Ep=W((pT,xp)=>{"use strict";function Yw(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}xp.exports=Xw;function Xw(r,e,t){var i=t&&t.stringify||Yw,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=c||e[b]==null)break;y=c||e[b]==null)break;y=c||e[b]===void 0)break;y",y=I+2,I++;break}u+=i(e[b]),y=I+2,I++;break;case 115:if(b>=c)break;y{"use strict";var Sp=Ep();Ap.exports=Vr;var lo=a5().console||{},Zw={mapHttpRequest:Ka,mapHttpResponse:Ka,wrapRequestSerializer:xu,wrapResponseSerializer:xu,wrapErrorSerializer:xu,req:Ka,res:Ka,err:i5};function Qw(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Vr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||lo;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=Qw(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",c=Object.create(t);c.log||(c.log=po),Object.defineProperty(c,"levelVal",{get:b}),Object.defineProperty(c,"level",{get:y,set:S});let u={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:n5(r)};c.levels=Vr.levels,c.level=f,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=po,c.serializers=i,c._serialize=n,c._stdErrSerialize=s,c.child=I,e&&(c._logEvent=Eu());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,os(u,c,"error","log"),os(u,c,"fatal","error"),os(u,c,"warn","error"),os(u,c,"info","log"),os(u,c,"debug","log"),os(u,c,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let O=T.serializers;if(n&&O){var N=Object.assign({},i,O),B=r.browser.serialize===!0?Object.keys(N):n;delete M.serializers,ja([M],B,N,this._stdErrSerialize)}function z(F){this._childLevel=(F._childLevel|0)+1,this.error=as(F,M,"error"),this.fatal=as(F,M,"fatal"),this.warn=as(F,M,"warn"),this.info=as(F,M,"info"),this.debug=as(F,M,"debug"),this.trace=as(F,M,"trace"),N&&(this.serializers=N,this._serialize=B),e&&(this._logEvent=Eu([].concat(F._logEvent.bindings,M)))}return z.prototype=this,new z(this)}return c}Vr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Vr.stdSerializers=Zw;Vr.stdTimeFunctions=Object.assign({},{nullTime:Ip,epochTime:Mp,unixTime:s5,isoTime:o5});function os(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?po:n[t]?n[t]:lo[t]||lo[i]||po,e5(r,e,t)}function e5(r,e,t){!r.transmit&&e[t]===po||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===lo?lo:this;for(var c=0;c-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function as(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n"u"?t=p5(r,e):t=r.bindings().context||"",t}function b5(r,e,t=bo){let i=St(r,t);return i.trim()?`${i}/${e}`:e}function mt(r,e,t=bo){let i=b5(r,e,t),n=r.child({context:i});return g5(n,i,t)}function v5(r){var e,t;let i=new Mu((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,li.default)(Ga(Ha({},r.opts),{level:"trace",browser:Ga(Ha({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function m5(r){var e;let t=new Au((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,li.default)(Ga(Ha({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Dp(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?v5(r):m5(r)}var li,go,f5,bo,Ru,Iu,Va,$a,Mu,Au,c5,u5,h5,Rp,d5,l5,Tp,Ha,Ga,Tu=Z(()=>{li=Ue(Su()),go=Ue(Su());ss();f5={level:"info"},bo="custom_context",Ru=1e3*1024,Iu=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Va=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Iu(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},$a=class{constructor(e,t=Ru){this.level=e??"error",this.levelValue=li.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Va(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===li.levels.values.error?console.error(e):t===li.levels.values.warn?console.warn(e):t===li.levels.values.debug?console.debug(e):t===li.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Zt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Va(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Zt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Mu=class{constructor(e,t=Ru){this.baseChunkLogger=new $a(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Au=class{constructor(e,t=Ru){this.baseChunkLogger=new $a(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},c5=Object.defineProperty,u5=Object.defineProperties,h5=Object.getOwnPropertyDescriptors,Rp=Object.getOwnPropertySymbols,d5=Object.prototype.hasOwnProperty,l5=Object.prototype.propertyIsEnumerable,Tp=(r,e,t)=>e in r?c5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ha=(r,e)=>{for(var t in e||(e={}))d5.call(e,t)&&Tp(r,t,e[t]);if(Rp)for(var t of Rp(e))l5.call(e,t)&&Tp(r,t,e[t]);return r},Ga=(r,e)=>u5(r,h5(e))});var Np,Ja,Wa,Ya,Xa,Za,Qa,ef,tf,rf,nf,sf,of,af,Du=Z(()=>{lu();Np=Ue(_n()),Ja=class extends hr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},Wa=class extends hr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},Ya=class{constructor(e,t){this.logger=e,this.core=t}},Xa=class extends hr{constructor(e,t){super(),this.relayer=e,this.logger=t}},Za=class extends hr{constructor(e){super()}},Qa=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}},ef=class extends hr{constructor(e,t){super(),this.relayer=e,this.logger=t}},tf=class extends hr{constructor(e,t){super(),this.core=e,this.logger=t}},rf=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},nf=class{constructor(e,t){this.projectId=e,this.logger=t}},sf=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}},of=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},af=class{constructor(e){this.client=e}}});var Pp=W(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0});ff.BrowserRandomSource=void 0;var Cp=65536,Nu=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});function y5(r){for(var e=0;e{});var Op=W(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});cf.NodeRandomSource=void 0;var w5=Qt(),Ou=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof C0<"u"){let e=Pu();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});uf.SystemRandomSource=void 0;var _5=Pp(),x5=Op(),Lu=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new _5.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new x5.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};uf.SystemRandomSource=Lu});var qp=W(kt=>{"use strict";Object.defineProperty(kt,"__esModule",{value:!0});function E5(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}kt.mul=Math.imul||E5;function S5(r,e){return r+e|0}kt.add=S5;function I5(r,e){return r-e|0}kt.sub=I5;function M5(r,e){return r<>>32-e}kt.rotl=M5;function A5(r,e){return r<<32-e|r>>>e}kt.rotr=A5;function R5(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}kt.isInteger=Number.isInteger||R5;kt.MAX_SAFE_INTEGER=9007199254740991;kt.isSafeInteger=function(r){return kt.isInteger(r)&&r>=-kt.MAX_SAFE_INTEGER&&r<=kt.MAX_SAFE_INTEGER}});var fs=W(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});var Fp=qp();function T5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}qe.readInt16BE=T5;function D5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}qe.readUint16BE=D5;function N5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}qe.readInt16LE=N5;function C5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}qe.readUint16LE=C5;function Up(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}qe.writeUint16BE=Up;qe.writeInt16BE=Up;function Bp(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}qe.writeUint16LE=Bp;qe.writeInt16LE=Bp;function qu(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}qe.readInt32BE=qu;function Fu(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}qe.readUint32BE=Fu;function Uu(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}qe.readInt32LE=Uu;function Bu(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}qe.readUint32LE=Bu;function hf(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}qe.writeUint32BE=hf;qe.writeInt32BE=hf;function df(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}qe.writeUint32LE=df;qe.writeInt32LE=df;function P5(r,e){e===void 0&&(e=0);var t=qu(r,e),i=qu(r,e+4);return t*4294967296+i-(i>>31)*4294967296}qe.readInt64BE=P5;function O5(r,e){e===void 0&&(e=0);var t=Fu(r,e),i=Fu(r,e+4);return t*4294967296+i}qe.readUint64BE=O5;function L5(r,e){e===void 0&&(e=0);var t=Uu(r,e),i=Uu(r,e+4);return i*4294967296+t-(t>>31)*4294967296}qe.readInt64LE=L5;function q5(r,e){e===void 0&&(e=0);var t=Bu(r,e),i=Bu(r,e+4);return i*4294967296+t}qe.readUint64LE=q5;function zp(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),hf(r/4294967296>>>0,e,t),hf(r>>>0,e,t+4),e}qe.writeUint64BE=zp;qe.writeInt64BE=zp;function kp(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),df(r>>>0,e,t),df(r/4294967296>>>0,e,t+4),e}qe.writeUint64LE=kp;qe.writeInt64LE=kp;function F5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}qe.readUintBE=F5;function U5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}qe.writeUintBE=B5;function z5(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Fp.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.randomStringForEntropy=It.randomString=It.randomUint32=It.randomBytes=It.defaultRandomSource=void 0;var W5=Lp(),Y5=fs(),Kp=Qt();It.defaultRandomSource=new W5.SystemRandomSource;function zu(r,e=It.defaultRandomSource){return e.randomBytes(r)}It.randomBytes=zu;function X5(r=It.defaultRandomSource){let e=zu(4,r),t=(0,Y5.readUint32LE)(e);return(0,Kp.wipe)(e),t}It.randomUint32=X5;var jp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Vp(r,e=jp,t=It.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=zu(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let c=o[f];c{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var us=fs(),cs=Qt();pi.DIGEST_LENGTH=64;pi.BLOCK_SIZE=128;var Hp=function(){function r(){this.digestLength=pi.DIGEST_LENGTH,this.blockSize=pi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){cs.wipe(this._buffer),cs.wipe(this._tempHi),cs.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ku(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ku(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){cs.wipe(e.stateHi),cs.wipe(e.stateLo),e.buffer&&cs.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();pi.SHA512=Hp;var $p=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function ku(r,e,t,i,n,s,o){for(var f=t[0],c=t[1],u=t[2],b=t[3],y=t[4],S=t[5],I=t[6],M=t[7],T=i[0],O=i[1],N=i[2],B=i[3],z=i[4],F=i[5],k=i[6],V=i[7],L,P,J,D,l,w,p,a;o>=128;){for(var d=0;d<16;d++){var v=8*d+s;r[d]=us.readUint32BE(n,v),e[d]=us.readUint32BE(n,v+4)}for(var d=0;d<80;d++){var _=f,m=c,h=u,x=b,A=y,g=S,R=I,K=M,E=T,C=O,q=N,U=B,j=z,Y=F,H=k,$=V;if(L=M,P=V,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=(y>>>14|z<<18)^(y>>>18|z<<14)^(z>>>9|y<<23),P=(z>>>14|y<<18)^(z>>>18|y<<14)^(y>>>9|z<<23),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=y&S^~y&I,P=z&F^~z&k,l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=$p[d*2],P=$p[d*2+1],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=r[d%16],P=e[d%16],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,J=p&65535|a<<16,D=l&65535|w<<16,L=J,P=D,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),P=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,L=f&c^f&u^c&u,P=T&O^T&N^O&N,l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,K=p&65535|a<<16,$=l&65535|w<<16,L=x,P=U,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=J,P=D,l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,U=l&65535|w<<16,c=_,u=m,b=h,y=x,S=A,I=g,M=R,f=K,O=E,N=C,B=q,z=U,F=j,k=Y,V=H,T=$,d%16===15)for(var v=0;v<16;v++)L=r[v],P=e[v],l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=r[(v+9)%16],P=e[(v+9)%16],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,J=r[(v+1)%16],D=e[(v+1)%16],L=(J>>>1|D<<31)^(J>>>8|D<<24)^J>>>7,P=(D>>>1|J<<31)^(D>>>8|J<<24)^(D>>>7|J<<25),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,J=r[(v+14)%16],D=e[(v+14)%16],L=(J>>>19|D<<13)^(D>>>29|J<<3)^J>>>6,P=(D>>>19|J<<13)^(J>>>29|D<<3)^(D>>>6|J<<26),l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[v]=p&65535|a<<16,e[v]=l&65535|w<<16}L=f,P=T,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[0],P=i[0],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=c,P=O,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[1],P=i[1],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=c=p&65535|a<<16,i[1]=O=l&65535|w<<16,L=u,P=N,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[2],P=i[2],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=u=p&65535|a<<16,i[2]=N=l&65535|w<<16,L=b,P=B,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[3],P=i[3],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=B=l&65535|w<<16,L=y,P=z,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[4],P=i[4],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=y=p&65535|a<<16,i[4]=z=l&65535|w<<16,L=S,P=F,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[5],P=i[5],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=F=l&65535|w<<16,L=I,P=k,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[6],P=i[6],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=k=l&65535|w<<16,L=M,P=V,l=P&65535,w=P>>>16,p=L&65535,a=L>>>16,L=t[7],P=i[7],l+=P&65535,w+=P>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=V=l&65535|w<<16,s+=128,o-=128}return s}function Q5(r){var e=new Hp;e.update(r);var t=e.digest();return e.clean(),t}pi.hash=Q5});var a1=W(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var e4=mo(),yo=Gp(),Zp=Qt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function re(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,Qp(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function e1(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function Yp(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return wo(t,r),wo(i,e),e1(t,i)}function t1(r){let e=new Uint8Array(32);return wo(e,r),e[0]&1}function s4(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Sn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function Mn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function $e(r,e,t){let i,n,s=0,o=0,f=0,c=0,u=0,b=0,y=0,S=0,I=0,M=0,T=0,O=0,N=0,B=0,z=0,F=0,k=0,V=0,L=0,P=0,J=0,D=0,l=0,w=0,p=0,a=0,d=0,v=0,_=0,m=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],K=t[4],E=t[5],C=t[6],q=t[7],U=t[8],j=t[9],Y=t[10],H=t[11],$=t[12],te=t[13],G=t[14],X=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,c+=i*R,u+=i*K,b+=i*E,y+=i*C,S+=i*q,I+=i*U,M+=i*j,T+=i*Y,O+=i*H,N+=i*$,B+=i*te,z+=i*G,F+=i*X,i=e[1],o+=i*x,f+=i*A,c+=i*g,u+=i*R,b+=i*K,y+=i*E,S+=i*C,I+=i*q,M+=i*U,T+=i*j,O+=i*Y,N+=i*H,B+=i*$,z+=i*te,F+=i*G,k+=i*X,i=e[2],f+=i*x,c+=i*A,u+=i*g,b+=i*R,y+=i*K,S+=i*E,I+=i*C,M+=i*q,T+=i*U,O+=i*j,N+=i*Y,B+=i*H,z+=i*$,F+=i*te,k+=i*G,V+=i*X,i=e[3],c+=i*x,u+=i*A,b+=i*g,y+=i*R,S+=i*K,I+=i*E,M+=i*C,T+=i*q,O+=i*U,N+=i*j,B+=i*Y,z+=i*H,F+=i*$,k+=i*te,V+=i*G,L+=i*X,i=e[4],u+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*K,M+=i*E,T+=i*C,O+=i*q,N+=i*U,B+=i*j,z+=i*Y,F+=i*H,k+=i*$,V+=i*te,L+=i*G,P+=i*X,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*K,T+=i*E,O+=i*C,N+=i*q,B+=i*U,z+=i*j,F+=i*Y,k+=i*H,V+=i*$,L+=i*te,P+=i*G,J+=i*X,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*K,O+=i*E,N+=i*C,B+=i*q,z+=i*U,F+=i*j,k+=i*Y,V+=i*H,L+=i*$,P+=i*te,J+=i*G,D+=i*X,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*K,N+=i*E,B+=i*C,z+=i*q,F+=i*U,k+=i*j,V+=i*Y,L+=i*H,P+=i*$,J+=i*te,D+=i*G,l+=i*X,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,N+=i*K,B+=i*E,z+=i*C,F+=i*q,k+=i*U,V+=i*j,L+=i*Y,P+=i*H,J+=i*$,D+=i*te,l+=i*G,w+=i*X,i=e[9],M+=i*x,T+=i*A,O+=i*g,N+=i*R,B+=i*K,z+=i*E,F+=i*C,k+=i*q,V+=i*U,L+=i*j,P+=i*Y,J+=i*H,D+=i*$,l+=i*te,w+=i*G,p+=i*X,i=e[10],T+=i*x,O+=i*A,N+=i*g,B+=i*R,z+=i*K,F+=i*E,k+=i*C,V+=i*q,L+=i*U,P+=i*j,J+=i*Y,D+=i*H,l+=i*$,w+=i*te,p+=i*G,a+=i*X,i=e[11],O+=i*x,N+=i*A,B+=i*g,z+=i*R,F+=i*K,k+=i*E,V+=i*C,L+=i*q,P+=i*U,J+=i*j,D+=i*Y,l+=i*H,w+=i*$,p+=i*te,a+=i*G,d+=i*X,i=e[12],N+=i*x,B+=i*A,z+=i*g,F+=i*R,k+=i*K,V+=i*E,L+=i*C,P+=i*q,J+=i*U,D+=i*j,l+=i*Y,w+=i*H,p+=i*$,a+=i*te,d+=i*G,v+=i*X,i=e[13],B+=i*x,z+=i*A,F+=i*g,k+=i*R,V+=i*K,L+=i*E,P+=i*C,J+=i*q,D+=i*U,l+=i*j,w+=i*Y,p+=i*H,a+=i*$,d+=i*te,v+=i*G,_+=i*X,i=e[14],z+=i*x,F+=i*A,k+=i*g,V+=i*R,L+=i*K,P+=i*E,J+=i*C,D+=i*q,l+=i*U,w+=i*j,p+=i*Y,a+=i*H,d+=i*$,v+=i*te,_+=i*G,m+=i*X,i=e[15],F+=i*x,k+=i*A,V+=i*g,L+=i*R,P+=i*K,J+=i*E,D+=i*C,l+=i*q,w+=i*U,p+=i*j,a+=i*Y,d+=i*H,v+=i*$,_+=i*te,m+=i*G,h+=i*X,s+=38*k,o+=38*V,f+=38*L,c+=38*P,u+=38*J,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*v,N+=38*_,B+=38*m,z+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=c,r[4]=u,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=N,r[13]=B,r[14]=z,r[15]=F}function In(r,e){$e(r,e,e)}function r1(r,e){let t=re(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)In(t,t),i!==2&&i!==4&&$e(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function o4(r,e){let t=re(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)In(t,t),i!==1&&$e(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function $u(r,e){let t=re(),i=re(),n=re(),s=re(),o=re(),f=re(),c=re(),u=re(),b=re();Mn(t,r[1],r[0]),Mn(b,e[1],e[0]),$e(t,t,b),Sn(i,r[0],r[1]),Sn(b,e[0],e[1]),$e(i,i,b),$e(n,r[3],e[3]),$e(n,n,i4),$e(s,r[2],e[2]),Sn(s,s,s),Mn(o,i,t),Mn(f,s,n),Sn(c,s,n),Sn(u,i,t),$e(r[0],o,f),$e(r[1],u,c),$e(r[2],c,f),$e(r[3],o,u)}function Xp(r,e,t){for(let i=0;i<4;i++)Qp(r[i],e[i],t)}function Gu(r,e){let t=re(),i=re(),n=re();r1(n,e[2]),$e(t,e[0],n),$e(i,e[1],n),wo(r,i),r[31]^=t1(t)<<7}function i1(r,e,t){Ci(r[0],Vu),Ci(r[1],hs),Ci(r[2],hs),Ci(r[3],Vu);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;Xp(r,e,n),$u(e,r),$u(r,r),Xp(r,e,n)}}function Ju(r,e){let t=[re(),re(),re(),re()];Ci(t[0],Jp),Ci(t[1],Wp),Ci(t[2],hs),$e(t[3],Jp,Wp),i1(r,t,e)}function n1(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,yo.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[re(),re(),re(),re()];Ju(i,e),Gu(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=n1;function a4(r){let e=(0,e4.randomBytes)(32,r),t=n1(e);return(0,Zp.wipe)(e),t}ze.generateKeyPair=a4;function f4(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=f4;var ju=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function s1(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*ju[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*ju[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Hu(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;s1(r,e)}function c4(r,e){let t=new Float64Array(64),i=[re(),re(),re(),re()],n=(0,yo.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new yo.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Hu(f),Ju(i,f),Gu(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let c=o.digest();Hu(c);for(let u=0;u<32;u++)t[u]=f[u];for(let u=0;u<32;u++)for(let b=0;b<32;b++)t[u+b]+=c[u]*n[b];return s1(s.subarray(32),t),s}ze.sign=c4;function o1(r,e){let t=re(),i=re(),n=re(),s=re(),o=re(),f=re(),c=re();return Ci(r[2],hs),s4(r[1],e),In(n,r[1]),$e(s,n,r4),Mn(n,n,r[2]),Sn(s,r[2],s),In(o,s),In(f,o),$e(c,f,o),$e(t,c,n),$e(t,t,s),o4(t,t),$e(t,t,n),$e(t,t,s),$e(t,t,s),$e(r[0],t,s),In(i,r[0]),$e(i,i,s),Yp(i,n)&&$e(r[0],r[0],n4),In(i,r[0]),$e(i,i,s),Yp(i,n)?-1:(t1(r[0])===e[31]>>7&&Mn(r[0],Vu,r[0]),$e(r[3],r[0],r[1]),0)}function u4(r,e,t){let i=new Uint8Array(32),n=[re(),re(),re(),re()],s=[re(),re(),re(),re()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(o1(s,r))return!1;let o=new yo.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Hu(f),i1(n,s,f),Ju(s,t.subarray(32)),$u(n,s),Gu(i,n),!e1(t,i)}ze.verify=u4;function h4(r){let e=[re(),re(),re(),re()];if(o1(e,r))throw new Error("Ed25519: invalid public key");let t=re(),i=re(),n=e[1];Sn(t,hs,n),Mn(i,hs,n),r1(i,i),$e(t,t,i);let s=new Uint8Array(32);return wo(s,t),s}ze.convertPublicKeyToX25519=h4;function d4(r){let e=(0,yo.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,Zp.wipe)(e),t}ze.convertSecretKeyToX25519=d4});var f1,c1,_o,xo,Wu,Yu,u1,h1,d1,Xu,l1,p1,lf=Z(()=>{f1="EdDSA",c1="JWT",_o=".",xo="base64url",Wu="utf8",Yu="utf8",u1=":",h1="did",d1="key",Xu="base58btc",l1="z",p1="K36"});function Eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}var pf=Z(()=>{});function An(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=Eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var Zu=Z(()=>{pf()});function l4(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,F=new Uint8Array(z);N!==B;){for(var k=M[N],V=0,L=z-1;(k!==0||V>>0,F[L]=k%f>>>0,k=k/f>>>0;if(k!==0)throw new Error("Non-zero carry");O=V,N++}for(var P=z-O;P!==z&&F[P]===0;)P++;for(var J=c.repeat(T);P>>0,z=new Uint8Array(B);M[T];){var F=t[M.charCodeAt(T)];if(F===255)return;for(var k=0,V=B-1;(F!==0||k>>0,z[V]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");N=k,T++}if(M[T]!==" "){for(var L=B-N;L!==B&&z[L]===0;)L++;for(var P=new Uint8Array(O+(B-L)),J=O;L!==B;)P[J++]=z[L++];return P}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var p4,g4,g1,b1=Z(()=>{p4=l4,g4=p4,g1=g4});var FT,v1,gi,m1,y1,Pi=Z(()=>{FT=new Uint8Array(0),v1=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},m1=r=>new TextEncoder().encode(r),y1=r=>new TextDecoder().decode(r)});var Qu,eh,th,_1,rh,ds,Oi,b4,v4,et,dr=Z(()=>{b1();Pi();Qu=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},eh=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return _1(this,e)}},th=class{constructor(e){this.decoders=e}or(e){return _1(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},_1=(r,e)=>new th({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),rh=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Qu(e,t,i),this.decoder=new eh(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ds=({name:r,prefix:e,encode:t,decode:i})=>new rh(r,e,t,i),Oi=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=g1(t,e);return ds({prefix:r,name:e,encode:i,decode:s=>gi(n(s))})},b4=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[u++]=255&c>>f)}if(f>=t||255&c<<8-f)throw new SyntaxError("Unexpected end of data");return o},v4=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<ds({prefix:e,name:r,encode(n){return v4(n,i,t)},decode(n){return b4(n,i,t,r)}})});var ih={};vt(ih,{identity:()=>m4});var m4,x1=Z(()=>{dr();Pi();m4=ds({prefix:"\0",name:"identity",encode:r=>y1(r),decode:r=>m1(r)})});var nh={};vt(nh,{base2:()=>y4});var y4,E1=Z(()=>{dr();y4=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})});var sh={};vt(sh,{base8:()=>w4});var w4,S1=Z(()=>{dr();w4=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})});var oh={};vt(oh,{base10:()=>_4});var _4,I1=Z(()=>{dr();_4=Oi({prefix:"9",name:"base10",alphabet:"0123456789"})});var ah={};vt(ah,{base16:()=>x4,base16upper:()=>E4});var x4,E4,M1=Z(()=>{dr();x4=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),E4=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});var fh={};vt(fh,{base32:()=>ls,base32hex:()=>A4,base32hexpad:()=>T4,base32hexpadupper:()=>D4,base32hexupper:()=>R4,base32pad:()=>I4,base32padupper:()=>M4,base32upper:()=>S4,base32z:()=>N4});var ls,S4,I4,M4,A4,R4,T4,D4,N4,ch=Z(()=>{dr();ls=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),S4=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),I4=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),M4=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),A4=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),R4=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),T4=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),D4=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),N4=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})});var uh={};vt(uh,{base36:()=>C4,base36upper:()=>P4});var C4,P4,A1=Z(()=>{dr();C4=Oi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),P4=Oi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})});var hh={};vt(hh,{base58btc:()=>$r,base58flickr:()=>O4});var $r,O4,dh=Z(()=>{dr();$r=Oi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),O4=Oi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});var lh={};vt(lh,{base64:()=>L4,base64pad:()=>q4,base64url:()=>F4,base64urlpad:()=>U4});var L4,q4,F4,U4,R1=Z(()=>{dr();L4=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),q4=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),F4=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),U4=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});var ph={};vt(ph,{base256emoji:()=>j4});function k4(r){return r.reduce((e,t)=>(e+=B4[t],e),"")}function K4(r){let e=[];for(let t of r){let i=z4[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var T1,B4,z4,j4,D1=Z(()=>{dr();T1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),B4=T1.reduce((r,e,t)=>(r[t]=e,r),[]),z4=T1.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);j4=ds({prefix:"\u{1F680}",name:"base256emoji",encode:k4,decode:K4})});function P1(r,e,t){e=e||[],t=t||0;for(var i=t;r>=G4;)e[t++]=r&255|N1,r/=128;for(;r&H4;)e[t++]=r&255|N1,r>>>=7;return e[t]=r|0,P1.bytes=t-i+1,e}function gh(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw gh.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&C1)<=W4);return gh.bytes=s-i,t}var V4,N1,$4,H4,G4,J4,W4,C1,Y4,X4,Z4,Q4,e8,t8,r8,i8,n8,s8,o8,a8,So,O1=Z(()=>{V4=P1,N1=128,$4=127,H4=~$4,G4=Math.pow(2,31);J4=gh,W4=128,C1=127;Y4=Math.pow(2,7),X4=Math.pow(2,14),Z4=Math.pow(2,21),Q4=Math.pow(2,28),e8=Math.pow(2,35),t8=Math.pow(2,42),r8=Math.pow(2,49),i8=Math.pow(2,56),n8=Math.pow(2,63),s8=function(r){return r{O1();Io=(r,e=0)=>[So.decode(r,e),So.decode.bytes],ps=(r,e,t=0)=>(So.encode(r,e,t),e),gs=r=>So.encodingLength(r)});var Rn,L1,q1,bs,Ao=Z(()=>{Pi();bf();Rn=(r,e)=>{let t=e.byteLength,i=gs(r),n=i+gs(t),s=new Uint8Array(n+t);return ps(r,s,0),ps(t,s,i),s.set(e,n),new bs(r,t,e,s)},L1=r=>{let e=gi(r),[t,i]=Io(e),[n,s]=Io(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new bs(t,n,o,e)},q1=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&v1(r.bytes,e.bytes),bs=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}}});var vh,bh,mh=Z(()=>{Ao();vh=({name:r,code:e,encode:t})=>new bh(r,e,t),bh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Rn(this.code,t):t.then(i=>Rn(this.code,i))}else throw Error("Unknown type, must be binary type")}}});var yh={};vt(yh,{sha256:()=>f8,sha512:()=>c8});var U1,f8,c8,B1=Z(()=>{mh();U1=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),f8=vh({name:"sha2-256",code:18,encode:U1("SHA-256")}),c8=vh({name:"sha2-512",code:19,encode:U1("SHA-512")})});var wh={};vt(wh,{identity:()=>d8});var z1,u8,k1,h8,d8,K1=Z(()=>{Pi();Ao();z1=0,u8="identity",k1=gi,h8=r=>Rn(z1,k1(r)),d8={code:z1,name:u8,encode:k1,digest:h8}});var j1=Z(()=>{Pi()});var nD,sD,V1=Z(()=>{nD=new TextEncoder,sD=new TextDecoder});var yf,g8,b8,v8,Ro,m8,$1,H1,vf,mf,y8,w8,_8,G1=Z(()=>{bf();Ao();dh();ch();Pi();yf=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:mf,byteLength:mf,code:vf,version:vf,multihash:vf,bytes:vf,_baseCache:mf,asCID:mf})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==Ro)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==m8)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=Rn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&q1(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return b8(t,n,e||$r.encoder);default:return v8(t,n,e||ls.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return w8(/^0\.0/,_8),!!(e&&(e[H1]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||$1(t,i,n.bytes))}else if(e!=null&&e[H1]===!0){let{version:t,multihash:i,code:n}=e,s=L1(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==Ro)throw new Error(`Version 0 CID must use dag-pb (code: ${Ro}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=$1(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Ro,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=gi(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new bs(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=Io(e.subarray(t));return t+=S,y},n=i(),s=Ro;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),c=i(),u=t+c,b=u-o;return{version:n,codec:s,multihashCode:f,digestSize:c,multihashSize:b,size:u}}static parse(e,t){let[i,n]=g8(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},g8=(r,e)=>{switch(r[0]){case"Q":{let t=e||$r;return[$r.prefix,t.decode(`${$r.prefix}${r}`)]}case $r.prefix:{let t=e||$r;return[$r.prefix,t.decode(r)]}case ls.prefix:{let t=e||ls;return[ls.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},b8=(r,e,t)=>{let{prefix:i}=t;if(i!==$r.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},v8=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},Ro=112,m8=18,$1=(r,e,t)=>{let i=gs(r),n=i+gs(e),s=new Uint8Array(n+t.byteLength);return ps(r,s,0),ps(e,s,i),s.set(t,n),s},H1=Symbol.for("@ipld/js-cid/CID"),vf={writable:!1,configurable:!1,enumerable:!0},mf={writable:!1,enumerable:!1,configurable:!1},y8="0.0.0-dev",w8=(r,e)=>{if(r.test(y8))console.warn(e);else throw new Error(e)},_8=`CID.isCID(v) is deprecated and will be removed in the next major release. +var hm=Object.create;var on=Object.defineProperty;var lm=Object.getOwnPropertyDescriptor;var dm=Object.getOwnPropertyNames;var fm=Object.getPrototypeOf,pm=Object.prototype.hasOwnProperty;var ph=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var P=(i,e)=>()=>(i&&(e=i(i=0)),e);var oe=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Se=(i,e)=>{for(var r in e)on(i,r,{get:e[r],enumerable:!0})},nn=(i,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of dm(e))!pm.call(i,s)&&s!==r&&on(i,s,{get:()=>e[s],enumerable:!(t=lm(e,s))||t.enumerable});return i},Me=(i,e,r)=>(nn(i,e,"default"),r&&nn(r,e,"default")),pe=(i,e,r)=>(r=i!=null?hm(fm(i)):{},nn(e||!i||!i.__esModule?on(r,"default",{value:i,enumerable:!0}):r,i)),ei=i=>nn(on({},"__esModule",{value:!0}),i);var Yt=oe((l2,Zo)=>{"use strict";var yr=typeof Reflect=="object"?Reflect:null,gh=yr&&typeof yr.apply=="function"?yr.apply:function(e,r,t){return Function.prototype.apply.call(e,r,t)},an;yr&&typeof yr.ownKeys=="function"?an=yr.ownKeys:Object.getOwnPropertySymbols?an=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:an=function(e){return Object.getOwnPropertyNames(e)};function gm(i){console&&console.warn&&console.warn(i)}var yh=Number.isNaN||function(e){return e!==e};function he(){he.init.call(this)}Zo.exports=he;Zo.exports.once=bm;he.EventEmitter=he;he.prototype._events=void 0;he.prototype._eventsCount=0;he.prototype._maxListeners=void 0;var mh=10;function cn(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(he,"defaultMaxListeners",{enumerable:!0,get:function(){return mh},set:function(i){if(typeof i!="number"||i<0||yh(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");mh=i}});he.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};he.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||yh(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function wh(i){return i._maxListeners===void 0?he.defaultMaxListeners:i._maxListeners}he.prototype.getMaxListeners=function(){return wh(this)};he.prototype.emit=function(e){for(var r=[],t=1;t0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(c===void 0)return!1;if(typeof c=="function")gh(c,this,r);else for(var h=c.length,d=xh(c,h),t=0;t0&&o.length>s&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=i,a.type=e,a.count=o.length,gm(a)}return i}he.prototype.addListener=function(e,r){return bh(this,e,r,!1)};he.prototype.on=he.prototype.addListener;he.prototype.prependListener=function(e,r){return bh(this,e,r,!0)};function mm(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Eh(i,e,r){var t={fired:!1,wrapFn:void 0,target:i,type:e,listener:r},s=mm.bind(t);return s.listener=r,t.wrapFn=s,s}he.prototype.once=function(e,r){return cn(r),this.on(e,Eh(this,e,r)),this};he.prototype.prependOnceListener=function(e,r){return cn(r),this.prependListener(e,Eh(this,e,r)),this};he.prototype.removeListener=function(e,r){var t,s,n,o,a;if(cn(r),s=this._events,s===void 0)return this;if(t=s[e],t===void 0)return this;if(t===r||t.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,t.listener||r));else if(typeof t!="function"){for(n=-1,o=t.length-1;o>=0;o--)if(t[o]===r||t[o].listener===r){a=t[o].listener,n=o;break}if(n<0)return this;n===0?t.shift():ym(t,n),t.length===1&&(s[e]=t[0]),s.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};he.prototype.off=he.prototype.removeListener;he.prototype.removeAllListeners=function(e){var r,t,s;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){var n=Object.keys(t),o;for(s=0;s=0;s--)this.removeListener(e,r[s]);return this};function _h(i,e,r){var t=i._events;if(t===void 0)return[];var s=t[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?wm(s):xh(s,s.length)}he.prototype.listeners=function(e){return _h(this,e,!0)};he.prototype.rawListeners=function(e){return _h(this,e,!1)};he.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):vh.call(i,e)};he.prototype.listenerCount=vh;function vh(i){var e=this._events;if(e!==void 0){var r=e[i];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}he.prototype.eventNames=function(){return this._eventsCount>0?an(this._events):[]};function xh(i,e){for(var r=new Array(e),t=0;t_m,__createBinding:()=>Ih,__exportStar:()=>vm,__read:()=>Sm,__values:()=>xm});function _m(i,e,r,t){return new(r||(r=Promise))(function(s,n){function o(h){try{c(t.next(h))}catch(d){n(d)}}function a(h){try{c(t.throw(h))}catch(d){n(d)}}function c(h){h.done?s(h.value):new r(function(d){d(h.value)}).then(o,a)}c((t=t.apply(i,e||[])).next())})}function vm(i,e){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ih(e,i,r)}function Ih(i,e,r,t){t===void 0&&(t=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(i,t,s)}function xm(i){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&i[e],t=0;if(r)return r.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&t>=i.length&&(i=void 0),{value:i&&i[t++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Sm(i,e){var r=typeof Symbol=="function"&&i[Symbol.iterator];if(!r)return i;var t=r.call(i),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=t.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=t.return)&&r.call(t)}finally{if(o)throw o.error}}return n}var br=P(()=>{});var Dh=oe(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.delay=void 0;function Im(i){return new Promise(e=>{setTimeout(()=>{e(!0)},i)})}un.delay=Im});var Th=oe(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.ONE_THOUSAND=Er.ONE_HUNDRED=void 0;Er.ONE_HUNDRED=100;Er.ONE_THOUSAND=1e3});var Rh=oe(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.ONE_YEAR=K.FOUR_WEEKS=K.THREE_WEEKS=K.TWO_WEEKS=K.ONE_WEEK=K.THIRTY_DAYS=K.SEVEN_DAYS=K.FIVE_DAYS=K.THREE_DAYS=K.ONE_DAY=K.TWENTY_FOUR_HOURS=K.TWELVE_HOURS=K.SIX_HOURS=K.THREE_HOURS=K.ONE_HOUR=K.SIXTY_MINUTES=K.THIRTY_MINUTES=K.TEN_MINUTES=K.FIVE_MINUTES=K.ONE_MINUTE=K.SIXTY_SECONDS=K.THIRTY_SECONDS=K.TEN_SECONDS=K.FIVE_SECONDS=K.ONE_SECOND=void 0;K.ONE_SECOND=1;K.FIVE_SECONDS=5;K.TEN_SECONDS=10;K.THIRTY_SECONDS=30;K.SIXTY_SECONDS=60;K.ONE_MINUTE=K.SIXTY_SECONDS;K.FIVE_MINUTES=K.ONE_MINUTE*5;K.TEN_MINUTES=K.ONE_MINUTE*10;K.THIRTY_MINUTES=K.ONE_MINUTE*30;K.SIXTY_MINUTES=K.ONE_MINUTE*60;K.ONE_HOUR=K.SIXTY_MINUTES;K.THREE_HOURS=K.ONE_HOUR*3;K.SIX_HOURS=K.ONE_HOUR*6;K.TWELVE_HOURS=K.ONE_HOUR*12;K.TWENTY_FOUR_HOURS=K.ONE_HOUR*24;K.ONE_DAY=K.TWENTY_FOUR_HOURS;K.THREE_DAYS=K.ONE_DAY*3;K.FIVE_DAYS=K.ONE_DAY*5;K.SEVEN_DAYS=K.ONE_DAY*7;K.THIRTY_DAYS=K.ONE_DAY*30;K.ONE_WEEK=K.SEVEN_DAYS;K.TWO_WEEKS=K.ONE_WEEK*2;K.THREE_WEEKS=K.ONE_WEEK*3;K.FOUR_WEEKS=K.ONE_WEEK*4;K.ONE_YEAR=K.ONE_DAY*365});var ea=oe(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});var Ch=(br(),ei(wr));Ch.__exportStar(Th(),hn);Ch.__exportStar(Rh(),hn)});var Ah=oe(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.fromMiliseconds=_r.toMiliseconds=void 0;var Nh=ea();function Dm(i){return i*Nh.ONE_THOUSAND}_r.toMiliseconds=Dm;function Tm(i){return Math.floor(i/Nh.ONE_THOUSAND)}_r.fromMiliseconds=Tm});var Ph=oe(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});var Oh=(br(),ei(wr));Oh.__exportStar(Dh(),ln);Oh.__exportStar(Ah(),ln)});var Lh=oe(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});ti.Watch=void 0;var dn=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let r=this.get(e);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let t=Date.now()-r.started;this.timestamps.set(e,{started:r.started,elapsed:t})}get(e){let r=this.timestamps.get(e);if(typeof r>"u")throw new Error(`No timestamp found for label: ${e}`);return r}elapsed(e){let r=this.get(e);return r.elapsed||Date.now()-r.started}};ti.Watch=dn;ti.default=dn});var Uh=oe(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.IWatch=void 0;var ta=class{};fn.IWatch=ta});var Mh=oe(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});var Rm=(br(),ei(wr));Rm.__exportStar(Uh(),ra)});var xr=oe(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});var pn=(br(),ei(wr));pn.__exportStar(Ph(),vr);pn.__exportStar(Lh(),vr);pn.__exportStar(Mh(),vr);pn.__exportStar(ea(),vr)});var Qe,Fh=P(()=>{Qe=class{}});var ia=P(()=>{Fh()});var Bh,mn,sa,kh,Xt,gn,qh=P(()=>{Bh=pe(Yt()),mn=pe(xr());ia();sa=class extends Qe{constructor(e){super()}},kh=mn.FIVE_SECONDS,Xt={pulse:"heartbeat_pulse"},gn=class i extends sa{constructor(e){super(e),this.events=new Bh.EventEmitter,this.interval=kh,this.interval=e?.interval||kh}static async init(e){let r=new i(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,mn.toMiliseconds)(this.interval))}pulse(){this.events.emit(Xt.pulse)}}});function zh(i={}){return{async getItem(e){try{return localStorage.getItem(e)}catch(r){return console.warn("Storage getItem error:",r),null}},async setItem(e,r){try{localStorage.setItem(e,r)}catch(t){console.warn("Storage setItem error:",t)}},async removeItem(e){try{localStorage.removeItem(e)}catch(r){console.warn("Storage removeItem error:",r)}},async clear(){try{localStorage.clear()}catch(e){console.warn("Storage clear error:",e)}},async mount(){},async unmount(){}}}var Vh=P(()=>{});function Qt(i){return new Promise((e,r)=>{i.oncomplete=i.onsuccess=()=>e(i.result),i.onabort=i.onerror=()=>r(i.error)})}function oa(i,e){let r=indexedDB.open(i);r.onupgradeneeded=()=>r.result.createObjectStore(e);let t=Qt(r);return(s,n)=>t.then(o=>n(o.transaction(e,s).objectStore(e)))}function ri(){return na||(na=oa("keyval-store","keyval")),na}function aa(i,e=ri()){return e("readonly",r=>Qt(r.get(i)))}function Kh(i,e,r=ri()){return r("readwrite",t=>(t.put(e,i),Qt(t.transaction)))}function jh(i,e=ri()){return e("readwrite",r=>(r.delete(i),Qt(r.transaction)))}function $h(i=ri()){return i("readwrite",e=>(e.clear(),Qt(e.transaction)))}function Cm(i,e){return i.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Qt(i.transaction)}function Hh(i=ri()){return i("readonly",e=>{if(e.getAllKeys)return Qt(e.getAllKeys());let r=[];return Cm(e,t=>r.push(t.key)).then(()=>r)})}var na,Gh=P(()=>{});function ut(i){if(typeof i!="string")throw new Error(`Cannot safe json parse value of type ${typeof i}`);try{return Am(i)}catch{return i}}function $e(i){return typeof i=="string"?i:Nm(i)||""}var Nm,Am,Sr=P(()=>{Nm=i=>JSON.stringify(i,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),Am=i=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=i.replace(e,'$1"$2n"$3');return JSON.parse(r,(t,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)}});function Mm(i){var e;return[i[0],ut((e=i[1])!=null?e:"")]}var Om,Pm,Lm,Um,ua,ca,yn,ha,Fm,Wh,km,Bm,wn,Jh=P(()=>{Vh();Gh();Sr();Om="idb-keyval",Pm=(i={})=>{let e=i.base&&i.base.length>0?`${i.base}:`:"",r=s=>e+s,t;return i.dbName&&i.storeName&&(t=oa(i.dbName,i.storeName)),{name:Om,options:i,async hasItem(s){return!(typeof await aa(r(s),t)>"u")},async getItem(s){return await aa(r(s),t)??null},setItem(s,n){return Kh(r(s),n,t)},removeItem(s){return jh(r(s),t)},getKeys(){return Hh(t)},clear(){return $h(t)}}},Lm="WALLET_CONNECT_V2_INDEXED_DB",Um="keyvaluestorage",ua=class{constructor(){this.indexedDb=zh({driver:Pm({dbName:Lm,storeName:Um})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,$e(r))}async removeItem(e){await this.indexedDb.removeItem(e)}},ca=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},yn={exports:{}};(function(){let i;function e(){}i=e,i.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},i.prototype.setItem=function(r,t){this[r]=String(t)},i.prototype.removeItem=function(r){delete this[r]},i.prototype.clear=function(){let r=this;Object.keys(r).forEach(function(t){r[t]=void 0,delete r[t]})},i.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},i.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof ca<"u"&&ca.localStorage?yn.exports=ca.localStorage:typeof window<"u"&&window.localStorage?yn.exports=window.localStorage:yn.exports=new e})();ha=class{constructor(){this.localStorage=yn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Mm)}async getItem(e){let r=this.localStorage.getItem(e);if(r!==null)return ut(r)}async setItem(e,r){this.localStorage.setItem(e,$e(r))}async removeItem(e){this.localStorage.removeItem(e)}},Fm="wc_storage_version",Wh=1,km=async(i,e,r)=>{let t=Fm,s=await e.getItem(t);if(s&&s>=Wh){r(e);return}let n=await i.getKeys();if(!n.length){r(e);return}let o=[];for(;n.length;){let a=n.shift();if(!a)continue;let c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){let h=await i.getItem(a);await e.setItem(a,h),o.push(a)}}await e.setItem(t,Wh),r(e),Bm(i,o)},Bm=async(i,e)=>{e.length&&e.forEach(async r=>{await i.removeItem(r)})},wn=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};let e=new ha;this.storage=e;try{let r=new ua;km(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}}});function Yh(){return{trace:la,debug:la,info:console.log.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),fatal:console.error.bind(console),child:function(){return this}}}function bn(){return Yh()}var la,Zt,Pt,da=P(()=>{la=()=>{},Zt={values:{trace:10,debug:20,info:30,warn:40,error:50,fatal:60}};bn.destination=()=>({write:la});bn.transport=()=>Yh();bn.levels=Zt;Pt=bn});function si(i){return xn(vn({},i),{level:i?.level||qm.level})}function Hm(i,e=ii){return i[e]||""}function Gm(i,e,r=ii){return i[r]=e,i}function Re(i,e=ii){let r="";return typeof i.bindings>"u"?r=Hm(i,e):r=i.bindings().context||"",r}function Wm(i,e,r=ii){let t=Re(i,r);return t.trim()?`${t}/${e}`:e}function Ie(i,e,r=ii){let t=Wm(i,e,r),s=i.child({context:t});return Gm(s,t,r)}function Jm(i){var e,r;let t=new pa((e=i.opts)==null?void 0:e.level,i.maxSizeInBytes);return{logger:Pt(xn(vn({},i.opts),{level:"trace",browser:xn(vn({},(r=i.opts)==null?void 0:r.browser),{write:s=>t.write(s)})})),chunkLoggerController:t}}function Ym(i){var e;let r=new ga((e=i.opts)==null?void 0:e.level,i.maxSizeInBytes);return{logger:Pt(xn(vn({},i.opts),{level:"trace"}),r),chunkLoggerController:r}}function Zh(i){return typeof i.loggerOverride<"u"&&typeof i.loggerOverride!="string"?{logger:i.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Jm(i):Ym(i)}var qm,ii,ma,fa,En,_n,pa,ga,zm,Vm,Km,Xh,jm,$m,Qh,vn,xn,ya=P(()=>{da();da();Sr();qm={level:"info"},ii="custom_context",ma=1e3*1024,fa=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},En=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let r=new fa(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let r=e.value;return e=e.next,{done:!1,value:r}}}}},_n=class{constructor(e,r=ma){this.level=e??"error",this.levelValue=Zt.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new En(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Zt.values.error?console.error(e):r===Zt.values.warn?console.warn(e):r===Zt.values.debug?console.debug(e):r===Zt.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append($e({timestamp:new Date().toISOString(),log:e}));let r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new En(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let r=this.getLogArray();return r.push($e({extraMetadata:e})),new Blob(r,{type:"application/json"})}},pa=class{constructor(e,r=ma){this.baseChunkLogger=new _n(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let r=URL.createObjectURL(this.logsToBlob(e)),t=document.createElement("a");t.href=r,t.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(r)}},ga=class{constructor(e,r=ma){this.baseChunkLogger=new _n(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},zm=Object.defineProperty,Vm=Object.defineProperties,Km=Object.getOwnPropertyDescriptors,Xh=Object.getOwnPropertySymbols,jm=Object.prototype.hasOwnProperty,$m=Object.prototype.propertyIsEnumerable,Qh=(i,e,r)=>e in i?zm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,vn=(i,e)=>{for(var r in e||(e={}))jm.call(e,r)&&Qh(i,r,e[r]);if(Xh)for(var r of Xh(e))$m.call(e,r)&&Qh(i,r,e[r]);return i},xn=(i,e)=>Vm(i,Km(e))});var el,Sn,In,Dn,Tn,Rn,Cn,Nn,An,On,Pn,Ln,Un,Mn,wa=P(()=>{ia();el=pe(Yt()),Sn=class extends Qe{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},In=class extends Qe{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}},Dn=class{constructor(e,r){this.logger=e,this.core=r}},Tn=class extends Qe{constructor(e,r){super(),this.relayer=e,this.logger=r}},Rn=class extends Qe{constructor(e){super()}},Cn=class{constructor(e,r,t,s){this.core=e,this.logger=r,this.name=t}},Nn=class extends Qe{constructor(e,r){super(),this.relayer=e,this.logger=r}},An=class extends Qe{constructor(e,r){super(),this.core=e,this.logger=r}},On=class{constructor(e,r,t){this.core=e,this.logger=r,this.store=t}},Pn=class{constructor(e,r){this.projectId=e,this.logger=r}},Ln=class{constructor(e,r,t){this.core=e,this.logger=r,this.telemetryEnabled=t}},Un=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},Mn=class{constructor(e){this.client=e}}});var rl=oe(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.BrowserRandomSource=void 0;var tl=65536,ba=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let r=new Uint8Array(e);for(let t=0;t{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});function Xm(i){for(var e=0;e{});var sl=oe(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.NodeRandomSource=void 0;var Qm=He(),_a=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof ph<"u"){let e=il();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let t=new Uint8Array(e);for(let s=0;s{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.SystemRandomSource=void 0;var Zm=rl(),ey=sl(),va=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Zm.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new ey.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Bn.SystemRandomSource=va});var ol=oe(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});function ty(i,e){var r=i>>>16&65535,t=i&65535,s=e>>>16&65535,n=e&65535;return t*n+(r*n+t*s<<16>>>0)|0}ze.mul=Math.imul||ty;function ry(i,e){return i+e|0}ze.add=ry;function iy(i,e){return i-e|0}ze.sub=iy;function sy(i,e){return i<>>32-e}ze.rotl=sy;function ny(i,e){return i<<32-e|i>>>e}ze.rotr=ny;function oy(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i}ze.isInteger=Number.isInteger||oy;ze.MAX_SAFE_INTEGER=9007199254740991;ze.isSafeInteger=function(i){return ze.isInteger(i)&&i>=-ze.MAX_SAFE_INTEGER&&i<=ze.MAX_SAFE_INTEGER}});var Ir=oe(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});var al=ol();function ay(i,e){return e===void 0&&(e=0),(i[e+0]<<8|i[e+1])<<16>>16}ne.readInt16BE=ay;function cy(i,e){return e===void 0&&(e=0),(i[e+0]<<8|i[e+1])>>>0}ne.readUint16BE=cy;function uy(i,e){return e===void 0&&(e=0),(i[e+1]<<8|i[e])<<16>>16}ne.readInt16LE=uy;function hy(i,e){return e===void 0&&(e=0),(i[e+1]<<8|i[e])>>>0}ne.readUint16LE=hy;function cl(i,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=i>>>8,e[r+1]=i>>>0,e}ne.writeUint16BE=cl;ne.writeInt16BE=cl;function ul(i,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=i>>>0,e[r+1]=i>>>8,e}ne.writeUint16LE=ul;ne.writeInt16LE=ul;function xa(i,e){return e===void 0&&(e=0),i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}ne.readInt32BE=xa;function Sa(i,e){return e===void 0&&(e=0),(i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0}ne.readUint32BE=Sa;function Ia(i,e){return e===void 0&&(e=0),i[e+3]<<24|i[e+2]<<16|i[e+1]<<8|i[e]}ne.readInt32LE=Ia;function Da(i,e){return e===void 0&&(e=0),(i[e+3]<<24|i[e+2]<<16|i[e+1]<<8|i[e])>>>0}ne.readUint32LE=Da;function qn(i,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=i>>>24,e[r+1]=i>>>16,e[r+2]=i>>>8,e[r+3]=i>>>0,e}ne.writeUint32BE=qn;ne.writeInt32BE=qn;function zn(i,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=i>>>0,e[r+1]=i>>>8,e[r+2]=i>>>16,e[r+3]=i>>>24,e}ne.writeUint32LE=zn;ne.writeInt32LE=zn;function ly(i,e){e===void 0&&(e=0);var r=xa(i,e),t=xa(i,e+4);return r*4294967296+t-(t>>31)*4294967296}ne.readInt64BE=ly;function dy(i,e){e===void 0&&(e=0);var r=Sa(i,e),t=Sa(i,e+4);return r*4294967296+t}ne.readUint64BE=dy;function fy(i,e){e===void 0&&(e=0);var r=Ia(i,e),t=Ia(i,e+4);return t*4294967296+r-(r>>31)*4294967296}ne.readInt64LE=fy;function py(i,e){e===void 0&&(e=0);var r=Da(i,e),t=Da(i,e+4);return t*4294967296+r}ne.readUint64LE=py;function hl(i,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),qn(i/4294967296>>>0,e,r),qn(i>>>0,e,r+4),e}ne.writeUint64BE=hl;ne.writeInt64BE=hl;function ll(i,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),zn(i>>>0,e,r),zn(i/4294967296>>>0,e,r+4),e}ne.writeUint64LE=ll;ne.writeInt64LE=ll;function gy(i,e,r){if(r===void 0&&(r=0),i%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(i/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var t=0,s=1,n=i/8+r-1;n>=r;n--)t+=e[n]*s,s*=256;return t}ne.readUintBE=gy;function my(i,e,r){if(r===void 0&&(r=0),i%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(i/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var t=0,s=1,n=r;n=t;n--)r[n]=e/s&255,s*=256;return r}ne.writeUintBE=yy;function wy(i,e,r,t){if(r===void 0&&(r=new Uint8Array(i/8)),t===void 0&&(t=0),i%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!al.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var s=1,n=t;n{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.randomStringForEntropy=Ce.randomString=Ce.randomUint32=Ce.randomBytes=Ce.defaultRandomSource=void 0;var Ty=nl(),Ry=Ir(),dl=He();Ce.defaultRandomSource=new Ty.SystemRandomSource;function Ta(i,e=Ce.defaultRandomSource){return e.randomBytes(i)}Ce.randomBytes=Ta;function Cy(i=Ce.defaultRandomSource){let e=Ta(4,i),r=(0,Ry.readUint32LE)(e);return(0,dl.wipe)(e),r}Ce.randomUint32=Cy;var fl="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function pl(i,e=fl,r=Ce.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let t="",s=e.length,n=256-256%s;for(;i>0;){let o=Ta(Math.ceil(i*256/n),r);for(let a=0;a0;a++){let c=o[a];c{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});var Tr=Ir(),Dr=He();_t.DIGEST_LENGTH=64;_t.BLOCK_SIZE=128;var ml=function(){function i(){this.digestLength=_t.DIGEST_LENGTH,this.blockSize=_t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return i.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},i.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},i.prototype.clean=function(){Dr.wipe(this._buffer),Dr.wipe(this._tempHi),Dr.wipe(this._tempLo),this.reset()},i.prototype.update=function(e,r){if(r===void 0&&(r=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var t=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength<_t.BLOCK_SIZE&&r>0;)this._buffer[this._bufferLength++]=e[t++],r--;this._bufferLength===this.blockSize&&(Ra(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(t=Ra(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,t,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=e[t++],r--;return this},i.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,t=this._bufferLength,s=r/536870912|0,n=r<<3,o=r%128<112?128:256;this._buffer[t]=128;for(var a=t+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},i.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},i.prototype.cleanSavedState=function(e){Dr.wipe(e.stateHi),Dr.wipe(e.stateLo),e.buffer&&Dr.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},i}();_t.SHA512=ml;var gl=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Ra(i,e,r,t,s,n,o){for(var a=r[0],c=r[1],h=r[2],d=r[3],l=r[4],p=r[5],f=r[6],g=r[7],w=t[0],b=t[1],v=t[2],x=t[3],I=t[4],S=t[5],T=t[6],L=t[7],y,m,k,$,O,C,R,N;o>=128;){for(var G=0;G<16;G++){var H=8*G+n;i[G]=Tr.readUint32BE(s,H),e[G]=Tr.readUint32BE(s,H+4)}for(var G=0;G<80;G++){var q=a,j=c,re=h,Y=d,Z=l,V=p,J=f,X=g,u=w,E=b,_=v,D=x,A=I,U=S,F=T,M=L;if(y=g,m=L,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=(l>>>14|I<<18)^(l>>>18|I<<14)^(I>>>9|l<<23),m=(I>>>14|l<<18)^(I>>>18|l<<14)^(l>>>9|I<<23),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=l&p^~l&f,m=I&S^~I&T,O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=gl[G*2],m=gl[G*2+1],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=i[G%16],m=e[G%16],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,k=R&65535|N<<16,$=O&65535|C<<16,y=k,m=$,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=(a>>>28|w<<4)^(w>>>2|a<<30)^(w>>>7|a<<25),m=(w>>>28|a<<4)^(a>>>2|w<<30)^(a>>>7|w<<25),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=a&c^a&h^c&h,m=w&b^w&v^b&v,O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,X=R&65535|N<<16,M=O&65535|C<<16,y=Y,m=D,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=k,m=$,O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,Y=R&65535|N<<16,D=O&65535|C<<16,c=q,h=j,d=re,l=Y,p=Z,f=V,g=J,a=X,b=u,v=E,x=_,I=D,S=A,T=U,L=F,w=M,G%16===15)for(var H=0;H<16;H++)y=i[H],m=e[H],O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=i[(H+9)%16],m=e[(H+9)%16],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,k=i[(H+1)%16],$=e[(H+1)%16],y=(k>>>1|$<<31)^(k>>>8|$<<24)^k>>>7,m=($>>>1|k<<31)^($>>>8|k<<24)^($>>>7|k<<25),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,k=i[(H+14)%16],$=e[(H+14)%16],y=(k>>>19|$<<13)^($>>>29|k<<3)^k>>>6,m=($>>>19|k<<13)^(k>>>29|$<<3)^($>>>6|k<<26),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,i[H]=R&65535|N<<16,e[H]=O&65535|C<<16}y=a,m=w,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[0],m=t[0],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[0]=a=R&65535|N<<16,t[0]=w=O&65535|C<<16,y=c,m=b,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[1],m=t[1],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[1]=c=R&65535|N<<16,t[1]=b=O&65535|C<<16,y=h,m=v,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[2],m=t[2],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[2]=h=R&65535|N<<16,t[2]=v=O&65535|C<<16,y=d,m=x,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[3],m=t[3],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[3]=d=R&65535|N<<16,t[3]=x=O&65535|C<<16,y=l,m=I,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[4],m=t[4],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[4]=l=R&65535|N<<16,t[4]=I=O&65535|C<<16,y=p,m=S,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[5],m=t[5],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[5]=p=R&65535|N<<16,t[5]=S=O&65535|C<<16,y=f,m=T,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[6],m=t[6],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[6]=f=R&65535|N<<16,t[6]=T=O&65535|C<<16,y=g,m=L,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[7],m=t[7],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[7]=g=R&65535|N<<16,t[7]=L=O&65535|C<<16,n+=128,o-=128}return n}function Ay(i){var e=new ml;e.update(i);var r=e.digest();return e.clean(),r}_t.hash=Ay});var Al=oe(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.convertSecretKeyToX25519=ue.convertPublicKeyToX25519=ue.verify=ue.sign=ue.extractPublicKeyFromSecretKey=ue.generateKeyPair=ue.generateKeyPairFromSeed=ue.SEED_LENGTH=ue.SECRET_KEY_LENGTH=ue.PUBLIC_KEY_LENGTH=ue.SIGNATURE_LENGTH=void 0;var Oy=ni(),oi=yl(),vl=He();ue.SIGNATURE_LENGTH=64;ue.PUBLIC_KEY_LENGTH=32;ue.SECRET_KEY_LENGTH=64;ue.SEED_LENGTH=32;function te(i){let e=new Float64Array(16);if(i)for(let r=0;r>16&1),r[o-1]&=65535;r[15]=t[15]-32767-(r[14]>>16&1);let n=r[15]>>16&1;r[14]&=65535,xl(t,r,1-n)}for(let s=0;s<16;s++)i[2*s]=t[s]&255,i[2*s+1]=t[s]>>8}function Sl(i,e){let r=0;for(let t=0;t<32;t++)r|=i[t]^e[t];return(1&r-1>>>8)-1}function El(i,e){let r=new Uint8Array(32),t=new Uint8Array(32);return ai(r,i),ai(t,e),Sl(r,t)}function Il(i){let e=new Uint8Array(32);return ai(e,i),e[0]&1}function Fy(i,e){for(let r=0;r<16;r++)i[r]=e[2*r]+(e[2*r+1]<<8);i[15]&=32767}function er(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]+r[t]}function rr(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]-r[t]}function le(i,e,r){let t,s,n=0,o=0,a=0,c=0,h=0,d=0,l=0,p=0,f=0,g=0,w=0,b=0,v=0,x=0,I=0,S=0,T=0,L=0,y=0,m=0,k=0,$=0,O=0,C=0,R=0,N=0,G=0,H=0,q=0,j=0,re=0,Y=r[0],Z=r[1],V=r[2],J=r[3],X=r[4],u=r[5],E=r[6],_=r[7],D=r[8],A=r[9],U=r[10],F=r[11],M=r[12],Q=r[13],z=r[14],ee=r[15];t=e[0],n+=t*Y,o+=t*Z,a+=t*V,c+=t*J,h+=t*X,d+=t*u,l+=t*E,p+=t*_,f+=t*D,g+=t*A,w+=t*U,b+=t*F,v+=t*M,x+=t*Q,I+=t*z,S+=t*ee,t=e[1],o+=t*Y,a+=t*Z,c+=t*V,h+=t*J,d+=t*X,l+=t*u,p+=t*E,f+=t*_,g+=t*D,w+=t*A,b+=t*U,v+=t*F,x+=t*M,I+=t*Q,S+=t*z,T+=t*ee,t=e[2],a+=t*Y,c+=t*Z,h+=t*V,d+=t*J,l+=t*X,p+=t*u,f+=t*E,g+=t*_,w+=t*D,b+=t*A,v+=t*U,x+=t*F,I+=t*M,S+=t*Q,T+=t*z,L+=t*ee,t=e[3],c+=t*Y,h+=t*Z,d+=t*V,l+=t*J,p+=t*X,f+=t*u,g+=t*E,w+=t*_,b+=t*D,v+=t*A,x+=t*U,I+=t*F,S+=t*M,T+=t*Q,L+=t*z,y+=t*ee,t=e[4],h+=t*Y,d+=t*Z,l+=t*V,p+=t*J,f+=t*X,g+=t*u,w+=t*E,b+=t*_,v+=t*D,x+=t*A,I+=t*U,S+=t*F,T+=t*M,L+=t*Q,y+=t*z,m+=t*ee,t=e[5],d+=t*Y,l+=t*Z,p+=t*V,f+=t*J,g+=t*X,w+=t*u,b+=t*E,v+=t*_,x+=t*D,I+=t*A,S+=t*U,T+=t*F,L+=t*M,y+=t*Q,m+=t*z,k+=t*ee,t=e[6],l+=t*Y,p+=t*Z,f+=t*V,g+=t*J,w+=t*X,b+=t*u,v+=t*E,x+=t*_,I+=t*D,S+=t*A,T+=t*U,L+=t*F,y+=t*M,m+=t*Q,k+=t*z,$+=t*ee,t=e[7],p+=t*Y,f+=t*Z,g+=t*V,w+=t*J,b+=t*X,v+=t*u,x+=t*E,I+=t*_,S+=t*D,T+=t*A,L+=t*U,y+=t*F,m+=t*M,k+=t*Q,$+=t*z,O+=t*ee,t=e[8],f+=t*Y,g+=t*Z,w+=t*V,b+=t*J,v+=t*X,x+=t*u,I+=t*E,S+=t*_,T+=t*D,L+=t*A,y+=t*U,m+=t*F,k+=t*M,$+=t*Q,O+=t*z,C+=t*ee,t=e[9],g+=t*Y,w+=t*Z,b+=t*V,v+=t*J,x+=t*X,I+=t*u,S+=t*E,T+=t*_,L+=t*D,y+=t*A,m+=t*U,k+=t*F,$+=t*M,O+=t*Q,C+=t*z,R+=t*ee,t=e[10],w+=t*Y,b+=t*Z,v+=t*V,x+=t*J,I+=t*X,S+=t*u,T+=t*E,L+=t*_,y+=t*D,m+=t*A,k+=t*U,$+=t*F,O+=t*M,C+=t*Q,R+=t*z,N+=t*ee,t=e[11],b+=t*Y,v+=t*Z,x+=t*V,I+=t*J,S+=t*X,T+=t*u,L+=t*E,y+=t*_,m+=t*D,k+=t*A,$+=t*U,O+=t*F,C+=t*M,R+=t*Q,N+=t*z,G+=t*ee,t=e[12],v+=t*Y,x+=t*Z,I+=t*V,S+=t*J,T+=t*X,L+=t*u,y+=t*E,m+=t*_,k+=t*D,$+=t*A,O+=t*U,C+=t*F,R+=t*M,N+=t*Q,G+=t*z,H+=t*ee,t=e[13],x+=t*Y,I+=t*Z,S+=t*V,T+=t*J,L+=t*X,y+=t*u,m+=t*E,k+=t*_,$+=t*D,O+=t*A,C+=t*U,R+=t*F,N+=t*M,G+=t*Q,H+=t*z,q+=t*ee,t=e[14],I+=t*Y,S+=t*Z,T+=t*V,L+=t*J,y+=t*X,m+=t*u,k+=t*E,$+=t*_,O+=t*D,C+=t*A,R+=t*U,N+=t*F,G+=t*M,H+=t*Q,q+=t*z,j+=t*ee,t=e[15],S+=t*Y,T+=t*Z,L+=t*V,y+=t*J,m+=t*X,k+=t*u,$+=t*E,O+=t*_,C+=t*D,R+=t*A,N+=t*U,G+=t*F,H+=t*M,q+=t*Q,j+=t*z,re+=t*ee,n+=38*T,o+=38*L,a+=38*y,c+=38*m,h+=38*k,d+=38*$,l+=38*O,p+=38*C,f+=38*R,g+=38*N,w+=38*G,b+=38*H,v+=38*q,x+=38*j,I+=38*re,s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),i[0]=n,i[1]=o,i[2]=a,i[3]=c,i[4]=h,i[5]=d,i[6]=l,i[7]=p,i[8]=f,i[9]=g,i[10]=w,i[11]=b,i[12]=v,i[13]=x,i[14]=I,i[15]=S}function tr(i,e){le(i,e,e)}function Dl(i,e){let r=te(),t;for(t=0;t<16;t++)r[t]=e[t];for(t=253;t>=0;t--)tr(r,r),t!==2&&t!==4&&le(r,r,e);for(t=0;t<16;t++)i[t]=r[t]}function ky(i,e){let r=te(),t;for(t=0;t<16;t++)r[t]=e[t];for(t=250;t>=0;t--)tr(r,r),t!==1&&le(r,r,e);for(t=0;t<16;t++)i[t]=r[t]}function Oa(i,e){let r=te(),t=te(),s=te(),n=te(),o=te(),a=te(),c=te(),h=te(),d=te();rr(r,i[1],i[0]),rr(d,e[1],e[0]),le(r,r,d),er(t,i[0],i[1]),er(d,e[0],e[1]),le(t,t,d),le(s,i[3],e[3]),le(s,s,Uy),le(n,i[2],e[2]),er(n,n,n),rr(o,t,r),rr(a,n,s),er(c,n,s),er(h,t,r),le(i[0],o,a),le(i[1],h,c),le(i[2],c,a),le(i[3],o,h)}function _l(i,e,r){for(let t=0;t<4;t++)xl(i[t],e[t],r)}function La(i,e){let r=te(),t=te(),s=te();Dl(s,e[2]),le(r,e[0],s),le(t,e[1],s),ai(i,t),i[31]^=Il(r)<<7}function Tl(i,e,r){Lt(i[0],Aa),Lt(i[1],Rr),Lt(i[2],Rr),Lt(i[3],Aa);for(let t=255;t>=0;--t){let s=r[t/8|0]>>(t&7)&1;_l(i,e,s),Oa(e,i),Oa(i,i),_l(i,e,s)}}function Ua(i,e){let r=[te(),te(),te(),te()];Lt(r[0],wl),Lt(r[1],bl),Lt(r[2],Rr),le(r[3],wl,bl),Tl(i,r,e)}function Rl(i){if(i.length!==ue.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ue.SEED_LENGTH} bytes`);let e=(0,oi.hash)(i);e[0]&=248,e[31]&=127,e[31]|=64;let r=new Uint8Array(32),t=[te(),te(),te(),te()];Ua(t,e),La(r,t);let s=new Uint8Array(64);return s.set(i),s.set(r,32),{publicKey:r,secretKey:s}}ue.generateKeyPairFromSeed=Rl;function By(i){let e=(0,Oy.randomBytes)(32,i),r=Rl(e);return(0,vl.wipe)(e),r}ue.generateKeyPair=By;function qy(i){if(i.length!==ue.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ue.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(i.subarray(32))}ue.extractPublicKeyFromSecretKey=qy;var Na=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Cl(i,e){let r,t,s,n;for(t=63;t>=32;--t){for(r=0,s=t-32,n=t-12;s>4)*Na[s],r=e[s]>>8,e[s]&=255;for(s=0;s<32;s++)e[s]-=r*Na[s];for(t=0;t<32;t++)e[t+1]+=e[t]>>8,i[t]=e[t]&255}function Pa(i){let e=new Float64Array(64);for(let r=0;r<64;r++)e[r]=i[r];for(let r=0;r<64;r++)i[r]=0;Cl(i,e)}function zy(i,e){let r=new Float64Array(64),t=[te(),te(),te(),te()],s=(0,oi.hash)(i.subarray(0,32));s[0]&=248,s[31]&=127,s[31]|=64;let n=new Uint8Array(64);n.set(s.subarray(32),32);let o=new oi.SHA512;o.update(n.subarray(32)),o.update(e);let a=o.digest();o.clean(),Pa(a),Ua(t,a),La(n,t),o.reset(),o.update(n.subarray(0,32)),o.update(i.subarray(32)),o.update(e);let c=o.digest();Pa(c);for(let h=0;h<32;h++)r[h]=a[h];for(let h=0;h<32;h++)for(let d=0;d<32;d++)r[h+d]+=c[h]*s[d];return Cl(n.subarray(32),r),n}ue.sign=zy;function Nl(i,e){let r=te(),t=te(),s=te(),n=te(),o=te(),a=te(),c=te();return Lt(i[2],Rr),Fy(i[1],e),tr(s,i[1]),le(n,s,Ly),rr(s,s,i[2]),er(n,i[2],n),tr(o,n),tr(a,o),le(c,a,o),le(r,c,s),le(r,r,n),ky(r,r),le(r,r,s),le(r,r,n),le(r,r,n),le(i[0],r,n),tr(t,i[0]),le(t,t,n),El(t,s)&&le(i[0],i[0],My),tr(t,i[0]),le(t,t,n),El(t,s)?-1:(Il(i[0])===e[31]>>7&&rr(i[0],Aa,i[0]),le(i[3],i[0],i[1]),0)}function Vy(i,e,r){let t=new Uint8Array(32),s=[te(),te(),te(),te()],n=[te(),te(),te(),te()];if(r.length!==ue.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ue.SIGNATURE_LENGTH} bytes`);if(Nl(n,i))return!1;let o=new oi.SHA512;o.update(r.subarray(0,32)),o.update(i),o.update(e);let a=o.digest();return Pa(a),Tl(s,n,a),Ua(n,r.subarray(32)),Oa(s,n),La(t,s),!Sl(r,t)}ue.verify=Vy;function Ky(i){let e=[te(),te(),te(),te()];if(Nl(e,i))throw new Error("Ed25519: invalid public key");let r=te(),t=te(),s=e[1];er(r,Rr,s),rr(t,Rr,s),Dl(t,t),le(r,r,t);let n=new Uint8Array(32);return ai(n,r),n}ue.convertPublicKeyToX25519=Ky;function jy(i){let e=(0,oi.hash)(i.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let r=new Uint8Array(e.subarray(0,32));return(0,vl.wipe)(e),r}ue.convertSecretKeyToX25519=jy});var Ol,Pl,ci,ui,Ma,Fa,Ll,Ul,Ml,ka,Fl,kl,Vn=P(()=>{Ol="EdDSA",Pl="JWT",ci=".",ui="base64url",Ma="utf8",Fa="utf8",Ll=":",Ul="did",Ml="key",ka="base58btc",Fl="z",kl="K36"});function hi(i=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(i):new Uint8Array(i)}var Kn=P(()=>{});function ir(i,e){e||(e=i.reduce((s,n)=>s+n.length,0));let r=hi(e),t=0;for(let s of i)r.set(s,t),t+=s.length;return r}var Ba=P(()=>{Kn()});function $y(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),t=0;t>>0,S=new Uint8Array(I);v!==x;){for(var T=g[v],L=0,y=I-1;(T!==0||L>>0,S[y]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");b=L,v++}for(var m=I-b;m!==I&&S[m]===0;)m++;for(var k=c.repeat(w);m>>0,I=new Uint8Array(x);g[w];){var S=r[g.charCodeAt(w)];if(S===255)return;for(var T=0,L=x-1;(S!==0||T>>0,I[L]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");v=T,w++}if(g[w]!==" "){for(var y=x-v;y!==x&&I[y]===0;)y++;for(var m=new Uint8Array(b+(x-y)),k=b;y!==x;)m[k++]=I[y++];return m}}}function f(g){var w=p(g);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:f}}var Hy,Gy,Bl,ql=P(()=>{Hy=$y,Gy=Hy,Bl=Gy});var s3,zl,vt,Vl,Kl,Ut=P(()=>{s3=new Uint8Array(0),zl=(i,e)=>{if(i===e)return!0;if(i.byteLength!==e.byteLength)return!1;for(let r=0;r{if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")},Vl=i=>new TextEncoder().encode(i),Kl=i=>new TextDecoder().decode(i)});var qa,za,Va,$l,Ka,Cr,Mt,Wy,Jy,ye,Ze=P(()=>{ql();Ut();qa=class{constructor(e,r,t){this.name=e,this.prefix=r,this.baseEncode=t}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},za=class{constructor(e,r,t){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=t}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return $l(this,e)}},Va=class{constructor(e){this.decoders=e}or(e){return $l(this,e)}decode(e){let r=e[0],t=this.decoders[r];if(t)return t.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},$l=(i,e)=>new Va({...i.decoders||{[i.prefix]:i},...e.decoders||{[e.prefix]:e}}),Ka=class{constructor(e,r,t,s){this.name=e,this.prefix=r,this.baseEncode=t,this.baseDecode=s,this.encoder=new qa(e,r,t),this.decoder=new za(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Cr=({name:i,prefix:e,encode:r,decode:t})=>new Ka(i,e,r,t),Mt=({prefix:i,name:e,alphabet:r})=>{let{encode:t,decode:s}=Bl(r,e);return Cr({prefix:i,name:e,encode:t,decode:n=>vt(s(n))})},Wy=(i,e,r,t)=>{let s={};for(let d=0;d=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Jy=(i,e,r)=>{let t=e[e.length-1]==="=",s=(1<r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<Cr({prefix:e,name:i,encode(s){return Jy(s,t,r)},decode(s){return Wy(s,t,r,i)}})});var ja={};Se(ja,{identity:()=>Yy});var Yy,Hl=P(()=>{Ze();Ut();Yy=Cr({prefix:"\0",name:"identity",encode:i=>Kl(i),decode:i=>Vl(i)})});var $a={};Se($a,{base2:()=>Xy});var Xy,Gl=P(()=>{Ze();Xy=ye({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})});var Ha={};Se(Ha,{base8:()=>Qy});var Qy,Wl=P(()=>{Ze();Qy=ye({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})});var Ga={};Se(Ga,{base10:()=>Zy});var Zy,Jl=P(()=>{Ze();Zy=Mt({prefix:"9",name:"base10",alphabet:"0123456789"})});var Wa={};Se(Wa,{base16:()=>ew,base16upper:()=>tw});var ew,tw,Yl=P(()=>{Ze();ew=ye({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tw=ye({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});var Ja={};Se(Ja,{base32:()=>Nr,base32hex:()=>nw,base32hexpad:()=>aw,base32hexpadupper:()=>cw,base32hexupper:()=>ow,base32pad:()=>iw,base32padupper:()=>sw,base32upper:()=>rw,base32z:()=>uw});var Nr,rw,iw,sw,nw,ow,aw,cw,uw,Ya=P(()=>{Ze();Nr=ye({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rw=ye({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),iw=ye({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),sw=ye({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nw=ye({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ow=ye({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),aw=ye({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),cw=ye({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),uw=ye({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})});var Xa={};Se(Xa,{base36:()=>hw,base36upper:()=>lw});var hw,lw,Xl=P(()=>{Ze();hw=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lw=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})});var Qa={};Se(Qa,{base58btc:()=>ht,base58flickr:()=>dw});var ht,dw,Za=P(()=>{Ze();ht=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),dw=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});var ec={};Se(ec,{base64:()=>fw,base64pad:()=>pw,base64url:()=>gw,base64urlpad:()=>mw});var fw,pw,gw,mw,Ql=P(()=>{Ze();fw=ye({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pw=ye({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gw=ye({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mw=ye({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});var tc={};Se(tc,{base256emoji:()=>_w});function bw(i){return i.reduce((e,r)=>(e+=yw[r],e),"")}function Ew(i){let e=[];for(let r of i){let t=ww[r.codePointAt(0)];if(t===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}var Zl,yw,ww,_w,ed=P(()=>{Ze();Zl=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),yw=Zl.reduce((i,e,r)=>(i[r]=e,i),[]),ww=Zl.reduce((i,e,r)=>(i[e.codePointAt(0)]=r,i),[]);_w=Cr({prefix:"\u{1F680}",name:"base256emoji",encode:bw,decode:Ew})});function id(i,e,r){e=e||[],r=r||0;for(var t=r;i>=Iw;)e[r++]=i&255|td,i/=128;for(;i&Sw;)e[r++]=i&255|td,i>>>=7;return e[r]=i|0,id.bytes=r-t+1,e}function rc(i,t){var r=0,t=t||0,s=0,n=t,o,a=i.length;do{if(n>=a)throw rc.bytes=0,new RangeError("Could not decode varint");o=i[n++],r+=s<28?(o&rd)<=Tw);return rc.bytes=n-t,r}var vw,td,xw,Sw,Iw,Dw,Tw,rd,Rw,Cw,Nw,Aw,Ow,Pw,Lw,Uw,Mw,Fw,kw,Bw,li,sd=P(()=>{vw=id,td=128,xw=127,Sw=~xw,Iw=Math.pow(2,31);Dw=rc,Tw=128,rd=127;Rw=Math.pow(2,7),Cw=Math.pow(2,14),Nw=Math.pow(2,21),Aw=Math.pow(2,28),Ow=Math.pow(2,35),Pw=Math.pow(2,42),Lw=Math.pow(2,49),Uw=Math.pow(2,56),Mw=Math.pow(2,63),Fw=function(i){return i{sd();di=(i,e=0)=>[li.decode(i,e),li.decode.bytes],Ar=(i,e,r=0)=>(li.encode(i,e,r),e),Or=i=>li.encodingLength(i)});var sr,nd,od,Pr,pi=P(()=>{Ut();$n();sr=(i,e)=>{let r=e.byteLength,t=Or(i),s=t+Or(r),n=new Uint8Array(s+r);return Ar(i,n,0),Ar(r,n,t),n.set(e,s),new Pr(i,r,e,n)},nd=i=>{let e=vt(i),[r,t]=di(e),[s,n]=di(e.subarray(t)),o=e.subarray(t+n);if(o.byteLength!==s)throw new Error("Incorrect length");return new Pr(r,s,o,e)},od=(i,e)=>i===e?!0:i.code===e.code&&i.size===e.size&&zl(i.bytes,e.bytes),Pr=class{constructor(e,r,t,s){this.code=e,this.size=r,this.digest=t,this.bytes=s}}});var sc,ic,nc=P(()=>{pi();sc=({name:i,code:e,encode:r})=>new ic(i,e,r),ic=class{constructor(e,r,t){this.name=e,this.code=r,this.encode=t}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?sr(this.code,r):r.then(t=>sr(this.code,t))}else throw Error("Unknown type, must be binary type")}}});var oc={};Se(oc,{sha256:()=>qw,sha512:()=>zw});var cd,qw,zw,ud=P(()=>{nc();cd=i=>async e=>new Uint8Array(await crypto.subtle.digest(i,e)),qw=sc({name:"sha2-256",code:18,encode:cd("SHA-256")}),zw=sc({name:"sha2-512",code:19,encode:cd("SHA-512")})});var ac={};Se(ac,{identity:()=>jw});var hd,Vw,ld,Kw,jw,dd=P(()=>{Ut();pi();hd=0,Vw="identity",ld=vt,Kw=i=>sr(hd,ld(i)),jw={code:hd,name:Vw,encode:ld,digest:Kw}});var fd=P(()=>{Ut()});var I3,D3,pd=P(()=>{I3=new TextEncoder,D3=new TextDecoder});var Wn,Gw,Ww,Jw,gi,Yw,gd,md,Hn,Gn,Xw,Qw,Zw,yd=P(()=>{$n();pi();Za();Ya();Ut();Wn=class i{constructor(e,r,t,s){this.code=r,this.version=e,this.multihash=t,this.bytes=s,this.byteOffset=s.byteOffset,this.byteLength=s.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Gn,byteLength:Gn,code:Hn,version:Hn,multihash:Hn,bytes:Hn,_baseCache:Gn,asCID:Gn})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:r}=this;if(e!==gi)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Yw)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return i.createV0(r)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,t=sr(e,r);return i.createV1(this.code,t)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&od(this.multihash,e.multihash)}toString(e){let{bytes:r,version:t,_baseCache:s}=this;switch(t){case 0:return Ww(r,s,e||ht.encoder);default:return Jw(r,s,e||Nr.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Qw(/^0\.0/,Zw),!!(e&&(e[md]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof i)return e;if(e!=null&&e.asCID===e){let{version:r,code:t,multihash:s,bytes:n}=e;return new i(r,t,s,n||gd(r,t,s.bytes))}else if(e!=null&&e[md]===!0){let{version:r,multihash:t,code:s}=e,n=nd(t);return i.create(r,s,n)}else return null}static create(e,r,t){if(typeof r!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(r!==gi)throw new Error(`Version 0 CID must use dag-pb (code: ${gi}) block encoding`);return new i(e,r,t,t.bytes)}case 1:{let s=gd(e,r,t.bytes);return new i(e,r,t,s)}default:throw new Error("Invalid version")}}static createV0(e){return i.create(0,gi,e)}static createV1(e,r){return i.create(1,e,r)}static decode(e){let[r,t]=i.decodeFirst(e);if(t.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=i.inspectBytes(e),t=r.size-r.multihashSize,s=vt(e.subarray(t,t+r.multihashSize));if(s.byteLength!==r.multihashSize)throw new Error("Incorrect length");let n=s.subarray(r.multihashSize-r.digestSize),o=new Pr(r.multihashCode,r.digestSize,n,s);return[r.version===0?i.createV0(o):i.createV1(r.codec,o),e.subarray(r.size)]}static inspectBytes(e){let r=0,t=()=>{let[l,p]=di(e.subarray(r));return r+=p,l},s=t(),n=gi;if(s===18?(s=0,r=0):s===1&&(n=t()),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let o=r,a=t(),c=t(),h=r+c,d=h-o;return{version:s,codec:n,multihashCode:a,digestSize:c,multihashSize:d,size:h}}static parse(e,r){let[t,s]=Gw(e,r),n=i.decode(s);return n._baseCache.set(t,e),n}},Gw=(i,e)=>{switch(i[0]){case"Q":{let r=e||ht;return[ht.prefix,r.decode(`${ht.prefix}${i}`)]}case ht.prefix:{let r=e||ht;return[ht.prefix,r.decode(i)]}case Nr.prefix:{let r=e||Nr;return[Nr.prefix,r.decode(i)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[i[0],e.decode(i)]}}},Ww=(i,e,r)=>{let{prefix:t}=r;if(t!==ht.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let s=e.get(t);if(s==null){let n=r.encode(i).slice(1);return e.set(t,n),n}else return s},Jw=(i,e,r)=>{let{prefix:t}=r,s=e.get(t);if(s==null){let n=r.encode(i);return e.set(t,n),n}else return s},gi=112,Yw=18,gd=(i,e,r)=>{let t=Or(i),s=t+Or(e),n=new Uint8Array(s+r.byteLength);return Ar(i,n,0),Ar(e,n,t),n.set(r,s),n},md=Symbol.for("@ipld/js-cid/CID"),Hn={writable:!1,configurable:!1,enumerable:!0},Gn={writable:!1,enumerable:!1,configurable:!1},Xw="0.0.0-dev",Qw=(i,e)=>{if(i.test(Xw))console.warn(e);else throw new Error(e)},Zw=`CID.isCID(v) is deprecated and will be removed in the next major release. Following code pattern: if (CID.isCID(value)) { @@ -20,41 +20,18 @@ if (cid) { // Make sure to use cid instead of value doSomethingWithCID(cid) } -`});var J1=Z(()=>{G1();bf();Pi();mh();Ao()});var _h,lD,W1=Z(()=>{x1();E1();S1();I1();M1();ch();A1();dh();R1();D1();B1();K1();j1();V1();J1();_h={...ih,...nh,...sh,...oh,...ah,...fh,...uh,...hh,...lh,...ph},lD={...yh,...wh}});function X1(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var Y1,xh,x8,wf,Eh=Z(()=>{W1();pf();Y1=X1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),xh=X1("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Eo(r.length);for(let t=0;t{Eh()});function st(r,e="utf8"){let t=wf[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}var Ih=Z(()=>{Eh()});function Z1(r){return jr(tt(st(r,xo),Wu))}function _f(r){return tt(st(Zt(r),Wu),xo)}function xf(r){let e=st(p1,Xu),t=l1+tt(An([e,r]),Xu);return[h1,d1,t].join(u1)}function E8(r){return tt(r,xo)}function S8(r){return st(r,xo)}function Q1(r){return st([_f(r.header),_f(r.payload)].join(_o),Yu)}function eg(r){return[_f(r.header),_f(r.payload),E8(r.signature)].join(_o)}function vs(r){let e=r.split(_o),t=Z1(e[0]),i=Z1(e[1]),n=S8(e[2]),s=st(e.slice(0,2).join(_o),Yu);return{header:t,payload:i,signature:n,data:s}}var Mh=Z(()=>{Zu();Sh();Ih();ss();lf()});function Ah(r=(0,tg.randomBytes)(32)){return To.generateKeyPairFromSeed(r)}async function ig(r,e,t,i,n=(0,rg.fromMiliseconds)(Date.now())){let s={alg:f1,typ:c1},o=xf(i.publicKey),f=n+t,c={iss:o,sub:r,aud:e,iat:n,exp:f},u=Q1({header:s,payload:c}),b=To.sign(i.secretKey,u);return eg({header:s,payload:c,signature:b})}var To,tg,rg,ng=Z(()=>{To=Ue(a1()),tg=Ue(mo()),rg=Ue(ns());lf();Mh()});var sg=Z(()=>{});var Ef=Z(()=>{ng();lf();sg();Mh()});function ug(r){return r?cg(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new N8:typeof navigator<"u"?cg(navigator.userAgent):F8()}function L8(r){return r!==""&&O8.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function cg(r){var e=L8(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new D8;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{og=function(r,e,t){if(t||arguments.length===2)for(var i=0,n=e.length,s;i{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.getLocalStorage=Je.getLocalStorageOrThrow=Je.getCrypto=Je.getCryptoOrThrow=Je.getLocation=Je.getLocationOrThrow=Je.getNavigator=Je.getNavigatorOrThrow=Je.getDocument=Je.getDocumentOrThrow=Je.getFromWindowOrThrow=Je.getFromWindow=void 0;function Tn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Je.getFromWindow=Tn;function ms(r){let e=Tn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Je.getFromWindowOrThrow=ms;function B8(){return ms("document")}Je.getDocumentOrThrow=B8;function z8(){return Tn("document")}Je.getDocument=z8;function k8(){return ms("navigator")}Je.getNavigatorOrThrow=k8;function K8(){return Tn("navigator")}Je.getNavigator=K8;function j8(){return ms("location")}Je.getLocationOrThrow=j8;function V8(){return Tn("location")}Je.getLocation=V8;function $8(){return ms("crypto")}Je.getCryptoOrThrow=$8;function H8(){return Tn("crypto")}Je.getCrypto=H8;function G8(){return ms("localStorage")}Je.getLocalStorageOrThrow=G8;function J8(){return Tn("localStorage")}Je.getLocalStorage=J8});var lg=W(If=>{"use strict";Object.defineProperty(If,"__esModule",{value:!0});If.getWindowMetadata=void 0;var dg=Sf();function W8(){let r,e;try{r=dg.getDocumentOrThrow(),e=dg.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=M.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let N=e.protocol+"//"+e.host;if(O.indexOf("/")===0)N+=O;else{let B=e.pathname.split("/");B.pop();let z=B.join("/");N+=z+"/"+O}S.push(N)}else if(O.indexOf("//")===0){let N=e.protocol+O;S.push(N)}else S.push(O)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(O)).filter(O=>O?y.includes(O):!1);if(T.length&&T){let O=M.getAttribute("content");if(O)return O}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),c=e.origin,u=t();return{description:f,url:c,icons:u,name:o}}If.getWindowMetadata=W8});var gg=W((zD,pg)=>{"use strict";pg.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var wg=W((kD,yg)=>{"use strict";var mg="%[a-f0-9]{2}",bg=new RegExp("("+mg+")|([^%]+?)","gi"),vg=new RegExp("("+mg+")+","gi");function Rh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],Rh(t),Rh(i))}function Y8(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(bg)||[],t=1;t{"use strict";_g.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Sg=W((jD,Eg)=>{"use strict";Eg.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Z8=gg(),Q8=wg(),Mg=xg(),e_=Sg(),t_=r=>r==null,Th=Symbol("encodeFragmentIdentifier");function r_(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ot(e,r),"[",n,"]"].join("")]:[...t,[ot(e,r),"[",ot(n,r),"]=",ot(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ot(e,r),"[]"].join("")]:[...t,[ot(e,r),"[]=",ot(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ot(e,r),":list="].join("")]:[...t,[ot(e,r),":list=",ot(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[ot(t,r),e,ot(n,r)].join("")]:[[i,ot(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,ot(e,r)]:[...t,[ot(e,r),"=",ot(i,r)].join("")]}}function i_(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&bi(i,r).includes(r.arrayFormatSeparator);i=o?bi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(c=>bi(c,r)):i===null?i:bi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&bi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>bi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Ag(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function ot(r,e){return e.encode?e.strict?Z8(r):encodeURIComponent(r):r}function bi(r,e){return e.decode?Q8(r):r}function Rg(r){return Array.isArray(r)?r.sort():typeof r=="object"?Rg(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Tg(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function n_(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Dg(r){r=Tg(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ig(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Ng(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Ag(e.arrayFormatSeparator);let t=i_(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Mg(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:bi(o,e),t(bi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ig(s[o],e);else i[n]=Ig(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Rg(o):n[s]=o,n},Object.create(null))}Ft.extract=Dg;Ft.parse=Ng;Ft.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Ag(e.arrayFormatSeparator);let t=o=>e.skipNull&&t_(r[o])||e.skipEmptyString&&r[o]==="",i=r_(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?ot(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?ot(o,e)+"[]":f.reduce(i(o),[]).join("&"):ot(o,e)+"="+ot(f,e)}).filter(o=>o.length>0).join("&")};Ft.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Mg(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Ng(Dg(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:bi(i,e)}:{})};Ft.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Th]:!0},e);let t=Tg(r.url).split("?")[0]||"",i=Ft.extract(r.url),n=Ft.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ft.stringify(s,e);o&&(o=`?${o}`);let f=n_(r.url);return r.fragmentIdentifier&&(f=`#${e[Th]?ot(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ft.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Th]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ft.parseUrl(r,t);return Ft.stringifyUrl({url:i,query:e_(n,e),fragmentIdentifier:s},t)};Ft.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ft.pick(r,i,t)}});var Pg=W(($D,Mf)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=global:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof Mf=="object"&&Mf.exports,f=typeof define=="function"&&define.amd,c=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],N=[128,256],B=["hex","buffer","arrayBuffer","array","digest"],z={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),c&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var F=function(E,C,q){return function(U){return new g(E,C,E).update(U)[q]()}},k=function(E,C,q){return function(U,j){return new g(E,C,j).update(U)[q]()}},V=function(E,C,q){return function(U,j,Y,H){return a["cshake"+E].update(U,j,Y,H)[q]()}},L=function(E,C,q){return function(U,j,Y,H){return a["kmac"+E].update(U,j,Y,H)[q]()}},P=function(E,C,q,U){for(var j=0;j>5,this.byteCount=this.blockCount<<2,this.outputBlocks=q>>5,this.extraBytes=(q&31)>>3;for(var U=0;U<50;++U)this.s[U]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var C,q=typeof E;if(q!=="string"){if(q==="object"){if(E===null)throw new Error(r);if(c&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!c||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}for(var U=this.blocks,j=this.byteCount,Y=E.length,H=this.blockCount,$=0,te=this.s,G,X;$>2]|=E[$]<>2]|=X<>2]|=(192|X>>6)<>2]|=(128|X&63)<=57344?(U[G>>2]|=(224|X>>12)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<>2]|=(240|X>>18)<>2]|=(128|X>>12&63)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<=j){for(this.start=G-j,this.block=U[H],G=0;G>8,q=E&255;q>0;)j.unshift(q),E=E>>8,q=E&255,++U;return C?j.push(U):j.unshift(U),this.update(j),j.length},g.prototype.encodeString=function(E){var C,q=typeof E;if(q!=="string"){if(q==="object"){if(E===null)throw new Error(r);if(c&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!c||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);C=!0}var U=0,j=E.length;if(C)U=j;else for(var Y=0;Y=57344?U+=3:(H=65536+((H&1023)<<10|E.charCodeAt(++Y)&1023),U+=4)}return U+=this.encode(U*8),this.update(E),U},g.prototype.bytepad=function(E,C){for(var q=this.encode(C),U=0;U>2]|=this.padding[C&3],this.lastByteIndex===this.byteCount)for(E[0]=E[q],C=1;C>4&15]+u[$&15]+u[$>>12&15]+u[$>>8&15]+u[$>>20&15]+u[$>>16&15]+u[$>>28&15]+u[$>>24&15];Y%E===0&&(K(C),j=0)}return U&&($=C[j],H+=u[$>>4&15]+u[$&15],U>1&&(H+=u[$>>12&15]+u[$>>8&15]),U>2&&(H+=u[$>>20&15]+u[$>>16&15])),H},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,C=this.s,q=this.outputBlocks,U=this.extraBytes,j=0,Y=0,H=this.outputBits>>3,$;U?$=new ArrayBuffer(q+1<<2):$=new ArrayBuffer(H);for(var te=new Uint32Array($);Y>8&255,H[$+2]=te>>16&255,H[$+3]=te>>24&255;Y%E===0&&K(C)}return U&&($=Y<<2,te=C[j],H[$]=te&255,U>1&&(H[$+1]=te>>8&255),U>2&&(H[$+2]=te>>16&255)),H};function R(E,C,q){g.call(this,E,C,q)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var K=function(E){var C,q,U,j,Y,H,$,te,G,X,Rr,ne,se,Tr,oe,ae,Dr,fe,ce,Nr,ue,he,Cr,de,le,Pr,pe,ge,Or,be,ve,Lr,me,ye,qr,we,_e,Fr,xe,Ee,Ur,Se,Ie,Br,Me,Ae,zr,Re,Te,kr,De,Ne,Kr,Ce,Pe,ur,Ke,je,Gt,Jt,Wt,Yt,Xt;for(U=0;U<48;U+=2)j=E[0]^E[10]^E[20]^E[30]^E[40],Y=E[1]^E[11]^E[21]^E[31]^E[41],H=E[2]^E[12]^E[22]^E[32]^E[42],$=E[3]^E[13]^E[23]^E[33]^E[43],te=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],X=E[6]^E[16]^E[26]^E[36]^E[46],Rr=E[7]^E[17]^E[27]^E[37]^E[47],ne=E[8]^E[18]^E[28]^E[38]^E[48],se=E[9]^E[19]^E[29]^E[39]^E[49],C=ne^(H<<1|$>>>31),q=se^($<<1|H>>>31),E[0]^=C,E[1]^=q,E[10]^=C,E[11]^=q,E[20]^=C,E[21]^=q,E[30]^=C,E[31]^=q,E[40]^=C,E[41]^=q,C=j^(te<<1|G>>>31),q=Y^(G<<1|te>>>31),E[2]^=C,E[3]^=q,E[12]^=C,E[13]^=q,E[22]^=C,E[23]^=q,E[32]^=C,E[33]^=q,E[42]^=C,E[43]^=q,C=H^(X<<1|Rr>>>31),q=$^(Rr<<1|X>>>31),E[4]^=C,E[5]^=q,E[14]^=C,E[15]^=q,E[24]^=C,E[25]^=q,E[34]^=C,E[35]^=q,E[44]^=C,E[45]^=q,C=te^(ne<<1|se>>>31),q=G^(se<<1|ne>>>31),E[6]^=C,E[7]^=q,E[16]^=C,E[17]^=q,E[26]^=C,E[27]^=q,E[36]^=C,E[37]^=q,E[46]^=C,E[47]^=q,C=X^(j<<1|Y>>>31),q=Rr^(Y<<1|j>>>31),E[8]^=C,E[9]^=q,E[18]^=C,E[19]^=q,E[28]^=C,E[29]^=q,E[38]^=C,E[39]^=q,E[48]^=C,E[49]^=q,Tr=E[0],oe=E[1],Ae=E[11]<<4|E[10]>>>28,zr=E[10]<<4|E[11]>>>28,ge=E[20]<<3|E[21]>>>29,Or=E[21]<<3|E[20]>>>29,Jt=E[31]<<9|E[30]>>>23,Wt=E[30]<<9|E[31]>>>23,Se=E[40]<<18|E[41]>>>14,Ie=E[41]<<18|E[40]>>>14,ye=E[2]<<1|E[3]>>>31,qr=E[3]<<1|E[2]>>>31,ae=E[13]<<12|E[12]>>>20,Dr=E[12]<<12|E[13]>>>20,Re=E[22]<<10|E[23]>>>22,Te=E[23]<<10|E[22]>>>22,be=E[33]<<13|E[32]>>>19,ve=E[32]<<13|E[33]>>>19,Yt=E[42]<<2|E[43]>>>30,Xt=E[43]<<2|E[42]>>>30,Ce=E[5]<<30|E[4]>>>2,Pe=E[4]<<30|E[5]>>>2,we=E[14]<<6|E[15]>>>26,_e=E[15]<<6|E[14]>>>26,fe=E[25]<<11|E[24]>>>21,ce=E[24]<<11|E[25]>>>21,kr=E[34]<<15|E[35]>>>17,De=E[35]<<15|E[34]>>>17,Lr=E[45]<<29|E[44]>>>3,me=E[44]<<29|E[45]>>>3,de=E[6]<<28|E[7]>>>4,le=E[7]<<28|E[6]>>>4,ur=E[17]<<23|E[16]>>>9,Ke=E[16]<<23|E[17]>>>9,Fr=E[26]<<25|E[27]>>>7,xe=E[27]<<25|E[26]>>>7,Nr=E[36]<<21|E[37]>>>11,ue=E[37]<<21|E[36]>>>11,Ne=E[47]<<24|E[46]>>>8,Kr=E[46]<<24|E[47]>>>8,Br=E[8]<<27|E[9]>>>5,Me=E[9]<<27|E[8]>>>5,Pr=E[18]<<20|E[19]>>>12,pe=E[19]<<20|E[18]>>>12,je=E[29]<<7|E[28]>>>25,Gt=E[28]<<7|E[29]>>>25,Ee=E[38]<<8|E[39]>>>24,Ur=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Cr=E[49]<<14|E[48]>>>18,E[0]=Tr^~ae&fe,E[1]=oe^~Dr&ce,E[10]=de^~Pr&ge,E[11]=le^~pe&Or,E[20]=ye^~we&Fr,E[21]=qr^~_e&xe,E[30]=Br^~Ae&Re,E[31]=Me^~zr&Te,E[40]=Ce^~ur&je,E[41]=Pe^~Ke&Gt,E[2]=ae^~fe&Nr,E[3]=Dr^~ce&ue,E[12]=Pr^~ge&be,E[13]=pe^~Or&ve,E[22]=we^~Fr&Ee,E[23]=_e^~xe&Ur,E[32]=Ae^~Re&kr,E[33]=zr^~Te&De,E[42]=ur^~je&Jt,E[43]=Ke^~Gt&Wt,E[4]=fe^~Nr&he,E[5]=ce^~ue&Cr,E[14]=ge^~be&Lr,E[15]=Or^~ve&me,E[24]=Fr^~Ee&Se,E[25]=xe^~Ur&Ie,E[34]=Re^~kr&Ne,E[35]=Te^~De&Kr,E[44]=je^~Jt&Yt,E[45]=Gt^~Wt&Xt,E[6]=Nr^~he&Tr,E[7]=ue^~Cr&oe,E[16]=be^~Lr&de,E[17]=ve^~me&le,E[26]=Ee^~Se&ye,E[27]=Ur^~Ie&qr,E[36]=kr^~Ne&Br,E[37]=De^~Kr&Me,E[46]=Jt^~Yt&Ce,E[47]=Wt^~Xt&Pe,E[8]=he^~Tr&ae,E[9]=Cr^~oe&Dr,E[18]=Lr^~de&Pr,E[19]=me^~le&pe,E[28]=Se^~ye&we,E[29]=Ie^~qr&_e,E[38]=Ne^~Br&Ae,E[39]=Kr^~Me&zr,E[48]=Yt^~Ce&ur,E[49]=Xt^~Pe&Ke,E[0]^=T[U],E[1]^=T[U+1]};if(o)Mf.exports=a;else{for(v=0;v{Og="logger/5.7.0"});function s_(){try{let r=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var qg,Fg,Af,Ug,Dh,Bg,Nh,lr,zg,ht,Li=Z(()=>{"use strict";Lg();qg=!1,Fg=!1,Af={debug:1,default:2,info:2,warning:3,error:4,off:5},Ug=Af.default,Dh=null;Bg=s_();(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(Nh||(Nh={}));(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(lr||(lr={}));zg="0123456789abcdef",ht=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();Af[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Ug>Af[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(Fg)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(c=>{let u=i[c];try{if(u instanceof Uint8Array){let b="";for(let y=0;y>4],b+=zg[u[y]&15];n.push(c+"=Uint8Array(0x"+b+")")}else n.push(c+"="+JSON.stringify(u))}catch{n.push(c+"="+JSON.stringify(i[c].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case lr.NUMERIC_FAULT:{o="NUMERIC_FAULT";let c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case lr.CALL_EXCEPTION:case lr.INSUFFICIENT_FUNDS:case lr.MISSING_NEW:case lr.NONCE_EXPIRED:case lr.REPLACEMENT_UNDERPRICED:case lr.TRANSACTION_REPLACED:case lr.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(c){f[c]=i[c]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),Bg&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bg})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Dh||(Dh=new r(Og)),Dh}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qg){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Fg=!!e,qg=!!t}static setLogLevel(e){let t=Af[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}Ug=t}static from(e){return new r(e)}};ht.errors=lr;ht.levels=Nh});var kg,Kg=Z(()=>{kg="bytes/5.7.0"});function Vg(r){return!!r.toHexString}function ys(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return ys(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function $g(r){return pr(r)&&!(r.length%2)||Ph(r)}function jg(r){return typeof r=="number"&&r==r&&r%1===0}function Ph(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!jg(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Xe(r,e){if(e||(e={}),typeof r=="number"){at.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),ys(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vg(r)&&(r=r.toHexString()),pr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":at.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nXe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),ys(i)}function o_(r,e){r=Xe(r),r.length>e&&at.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),ys(t)}function pr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}function Mt(r,e){if(e||(e={}),typeof r=="number"){at.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Ch[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vg(r))return r.toHexString();if(pr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":at.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Ph(r)){let t="0x";for(let i=0;i>4]+Ch[n&15]}return t}return at.throwArgumentError("invalid hexlify value","value",r)}function Rf(r){if(typeof r!="string")r=Mt(r);else if(!pr(r)||r.length%2)return null;return(r.length-2)/2}function Tf(r,e,t){return typeof r!="string"?r=Mt(r):(!pr(r)||r.length%2)&&at.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function qi(r,e){for(typeof r!="string"?r=Mt(r):pr(r)||at.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&at.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function Df(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if($g(r)){let t=Xe(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Mt(t.slice(0,32)),e.s=Mt(t.slice(32,64))):t.length===65?(e.r=Mt(t.slice(0,32)),e.s=Mt(t.slice(32,64)),e.v=t[64]):at.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:at.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Mt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=o_(Xe(e._vs),32);e._vs=Mt(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&at.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=Mt(n);e.s==null?e.s=o:e.s!==o&&at.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?at.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&at.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!pr(e.r)?at.throwArgumentError("signature missing or invalid r","signature",r):e.r=qi(e.r,32),e.s==null||!pr(e.s)?at.throwArgumentError("signature missing or invalid s","signature",r):e.s=qi(e.s,32);let t=Xe(e.s);t[0]>=128&&at.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=Mt(t);e._vs&&(pr(e._vs)||at.throwArgumentError("signature invalid _vs","signature",r),e._vs=qi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&at.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}var at,Ch,Dn=Z(()=>{"use strict";Li();Kg();at=new ht(kg);Ch="0123456789abcdef"});function ws(r){return"0x"+Hg.default.keccak_256(Xe(r))}var Hg,Nf=Z(()=>{"use strict";Hg=Ue(Pg());Dn()});var Lh=W(()=>{});var Fh=W((Gg,qh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var d=function(){};d.prototype=a.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,a,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(d=a,a=10),this._init(p||0,a||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Lh().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,d){return a.cmp(d)>0?a:d},n.min=function(a,d){return a.cmp(d)<0?a:d},n.prototype._init=function(a,d,v){if(typeof a=="number")return this._initNumber(a,d,v);if(typeof a=="object")return this._initArray(a,d,v);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)h=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[m]|=h<>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);else if(v==="le")for(_=0,m=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);return this._strip()};function o(p,a){var d=p.charCodeAt(a);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function f(p,a,d){var v=o(p,d);return d-1>=a&&(v|=o(p,d-1)<<4),v}n.prototype._parseHex=function(a,d,v){this.length=Math.ceil((a.length-d)/6),this.words=new Array(this.length);for(var _=0;_=d;_-=2)x=f(a,d,_)<=18?(m-=18,h+=1,this.words[h]|=x>>>26):m+=8;else{var A=a.length-d;for(_=A%2===0?d+1:d;_=18?(m-=18,h+=1,this.words[h]|=x>>>26):m+=8}this._strip()};function c(p,a,d,v){for(var _=0,m=0,h=Math.min(p.length,d),x=a;x=49?m=A-49+10:A>=17?m=A-17+10:m=A,t(A>=0&&m1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,d){a=a||10,d=d|0||1;var v;if(a===16||a==="hex"){v="";for(var _=0,m=0,h=0;h>>24-_&16777215,_+=2,_>=26&&(_-=26,h--),m!==0||h!==this.length-1?v=y[6-A.length]+A+v:v=A+v}for(m!==0&&(v=m.toString(16)+v);v.length%d!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];v="";var K=this.clone();for(K.negative=0;!K.isZero();){var E=K.modrn(R).toString(a);K=K.idivn(R),K.isZero()?v=E+v:v=y[g-E.length]+E+v}for(this.isZero()&&(v="0"+v);v.length%d!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,d){return this.toArrayLike(s,a,d)}),n.prototype.toArray=function(a,d){return this.toArrayLike(Array,a,d)};var M=function(a,d){return a.allocUnsafe?a.allocUnsafe(d):new a(d)};n.prototype.toArrayLike=function(a,d,v){this._strip();var _=this.byteLength(),m=v||Math.max(1,_);t(_<=m,"byte array longer than desired length"),t(m>0,"Requested array length <= 0");var h=M(a,m),x=d==="le"?"LE":"BE";return this["_toArrayLike"+x](h,_),h},n.prototype._toArrayLikeLE=function(a,d){for(var v=0,_=0,m=0,h=0;m>8&255),v>16&255),h===6?(v>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(v=0&&(a[v--]=x>>8&255),v>=0&&(a[v--]=x>>16&255),h===6?(v>=0&&(a[v--]=x>>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(v>=0)for(a[v--]=_;v>=0;)a[v--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var d=a,v=0;return d>=4096&&(v+=13,d>>>=13),d>=64&&(v+=7,d>>>=7),d>=8&&(v+=4,d>>>=4),d>=2&&(v+=2,d>>>=2),v+d},n.prototype._zeroBits=function(a){if(a===0)return 26;var d=a,v=0;return d&8191||(v+=13,d>>>=13),d&127||(v+=7,d>>>=7),d&15||(v+=4,d>>>=4),d&3||(v+=2,d>>>=2),d&1||v++,v},n.prototype.bitLength=function(){var a=this.words[this.length-1],d=this._countBits(a);return(this.length-1)*26+d};function T(p){for(var a=new Array(p.bitLength()),d=0;d>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,d=0;da.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var d;this.length>a.length?d=a:d=this;for(var v=0;va.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var d,v;this.length>a.length?(d=this,v=a):(d=a,v=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var d=Math.ceil(a/26)|0,v=a%26;this._expand(d),v>0&&d--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-v),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,d){t(typeof a=="number"&&a>=0);var v=a/26|0,_=a%26;return this._expand(v+1),d?this.words[v]=this.words[v]|1<<_:this.words[v]=this.words[v]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var d;if(this.negative!==0&&a.negative===0)return this.negative=0,d=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,d=this.isub(a),a.negative=1,d._normSign();var v,_;this.length>a.length?(v=this,_=a):(v=a,_=this);for(var m=0,h=0;h<_.length;h++)d=(v.words[h]|0)+(_.words[h]|0)+m,this.words[h]=d&67108863,m=d>>>26;for(;m!==0&&h>>26;if(this.length=v.length,m!==0)this.words[this.length]=m,this.length++;else if(v!==this)for(;ha.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var d=this.iadd(a);return a.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var v=this.cmp(a);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,m;v>0?(_=this,m=a):(_=a,m=this);for(var h=0,x=0;x>26,this.words[x]=d&67108863;for(;h!==0&&x<_.length;x++)d=(_.words[x]|0)+h,h=d>>26,this.words[x]=d&67108863;if(h===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function O(p,a,d){d.negative=a.negative^p.negative;var v=p.length+a.length|0;d.length=v,v=v-1|0;var _=p.words[0]|0,m=a.words[0]|0,h=_*m,x=h&67108863,A=h/67108864|0;d.words[0]=x;for(var g=1;g>>26,K=A&67108863,E=Math.min(g,a.length-1),C=Math.max(0,g-p.length+1);C<=E;C++){var q=g-C|0;_=p.words[q]|0,m=a.words[C]|0,h=_*m+K,R+=h/67108864|0,K=h&67108863}d.words[g]=K|0,A=R|0}return A!==0?d.words[g]=A|0:d.length--,d._strip()}var N=function(a,d,v){var _=a.words,m=d.words,h=v.words,x=0,A,g,R,K=_[0]|0,E=K&8191,C=K>>>13,q=_[1]|0,U=q&8191,j=q>>>13,Y=_[2]|0,H=Y&8191,$=Y>>>13,te=_[3]|0,G=te&8191,X=te>>>13,Rr=_[4]|0,ne=Rr&8191,se=Rr>>>13,Tr=_[5]|0,oe=Tr&8191,ae=Tr>>>13,Dr=_[6]|0,fe=Dr&8191,ce=Dr>>>13,Nr=_[7]|0,ue=Nr&8191,he=Nr>>>13,Cr=_[8]|0,de=Cr&8191,le=Cr>>>13,Pr=_[9]|0,pe=Pr&8191,ge=Pr>>>13,Or=m[0]|0,be=Or&8191,ve=Or>>>13,Lr=m[1]|0,me=Lr&8191,ye=Lr>>>13,qr=m[2]|0,we=qr&8191,_e=qr>>>13,Fr=m[3]|0,xe=Fr&8191,Ee=Fr>>>13,Ur=m[4]|0,Se=Ur&8191,Ie=Ur>>>13,Br=m[5]|0,Me=Br&8191,Ae=Br>>>13,zr=m[6]|0,Re=zr&8191,Te=zr>>>13,kr=m[7]|0,De=kr&8191,Ne=kr>>>13,Kr=m[8]|0,Ce=Kr&8191,Pe=Kr>>>13,ur=m[9]|0,Ke=ur&8191,je=ur>>>13;v.negative=a.negative^d.negative,v.length=19,A=Math.imul(E,be),g=Math.imul(E,ve),g=g+Math.imul(C,be)|0,R=Math.imul(C,ve);var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(U,be),g=Math.imul(U,ve),g=g+Math.imul(j,be)|0,R=Math.imul(j,ve),A=A+Math.imul(E,me)|0,g=g+Math.imul(E,ye)|0,g=g+Math.imul(C,me)|0,R=R+Math.imul(C,ye)|0;var Jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,A=Math.imul(H,be),g=Math.imul(H,ve),g=g+Math.imul($,be)|0,R=Math.imul($,ve),A=A+Math.imul(U,me)|0,g=g+Math.imul(U,ye)|0,g=g+Math.imul(j,me)|0,R=R+Math.imul(j,ye)|0,A=A+Math.imul(E,we)|0,g=g+Math.imul(E,_e)|0,g=g+Math.imul(C,we)|0,R=R+Math.imul(C,_e)|0;var Wt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,A=Math.imul(G,be),g=Math.imul(G,ve),g=g+Math.imul(X,be)|0,R=Math.imul(X,ve),A=A+Math.imul(H,me)|0,g=g+Math.imul(H,ye)|0,g=g+Math.imul($,me)|0,R=R+Math.imul($,ye)|0,A=A+Math.imul(U,we)|0,g=g+Math.imul(U,_e)|0,g=g+Math.imul(j,we)|0,R=R+Math.imul(j,_e)|0,A=A+Math.imul(E,xe)|0,g=g+Math.imul(E,Ee)|0,g=g+Math.imul(C,xe)|0,R=R+Math.imul(C,Ee)|0;var Yt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,A=Math.imul(ne,be),g=Math.imul(ne,ve),g=g+Math.imul(se,be)|0,R=Math.imul(se,ve),A=A+Math.imul(G,me)|0,g=g+Math.imul(G,ye)|0,g=g+Math.imul(X,me)|0,R=R+Math.imul(X,ye)|0,A=A+Math.imul(H,we)|0,g=g+Math.imul(H,_e)|0,g=g+Math.imul($,we)|0,R=R+Math.imul($,_e)|0,A=A+Math.imul(U,xe)|0,g=g+Math.imul(U,Ee)|0,g=g+Math.imul(j,xe)|0,R=R+Math.imul(j,Ee)|0,A=A+Math.imul(E,Se)|0,g=g+Math.imul(E,Ie)|0,g=g+Math.imul(C,Se)|0,R=R+Math.imul(C,Ie)|0;var Xt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,A=Math.imul(oe,be),g=Math.imul(oe,ve),g=g+Math.imul(ae,be)|0,R=Math.imul(ae,ve),A=A+Math.imul(ne,me)|0,g=g+Math.imul(ne,ye)|0,g=g+Math.imul(se,me)|0,R=R+Math.imul(se,ye)|0,A=A+Math.imul(G,we)|0,g=g+Math.imul(G,_e)|0,g=g+Math.imul(X,we)|0,R=R+Math.imul(X,_e)|0,A=A+Math.imul(H,xe)|0,g=g+Math.imul(H,Ee)|0,g=g+Math.imul($,xe)|0,R=R+Math.imul($,Ee)|0,A=A+Math.imul(U,Se)|0,g=g+Math.imul(U,Ie)|0,g=g+Math.imul(j,Se)|0,R=R+Math.imul(j,Ie)|0,A=A+Math.imul(E,Me)|0,g=g+Math.imul(E,Ae)|0,g=g+Math.imul(C,Me)|0,R=R+Math.imul(C,Ae)|0;var un=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(un>>>26)|0,un&=67108863,A=Math.imul(fe,be),g=Math.imul(fe,ve),g=g+Math.imul(ce,be)|0,R=Math.imul(ce,ve),A=A+Math.imul(oe,me)|0,g=g+Math.imul(oe,ye)|0,g=g+Math.imul(ae,me)|0,R=R+Math.imul(ae,ye)|0,A=A+Math.imul(ne,we)|0,g=g+Math.imul(ne,_e)|0,g=g+Math.imul(se,we)|0,R=R+Math.imul(se,_e)|0,A=A+Math.imul(G,xe)|0,g=g+Math.imul(G,Ee)|0,g=g+Math.imul(X,xe)|0,R=R+Math.imul(X,Ee)|0,A=A+Math.imul(H,Se)|0,g=g+Math.imul(H,Ie)|0,g=g+Math.imul($,Se)|0,R=R+Math.imul($,Ie)|0,A=A+Math.imul(U,Me)|0,g=g+Math.imul(U,Ae)|0,g=g+Math.imul(j,Me)|0,R=R+Math.imul(j,Ae)|0,A=A+Math.imul(E,Re)|0,g=g+Math.imul(E,Te)|0,g=g+Math.imul(C,Re)|0,R=R+Math.imul(C,Te)|0;var hn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(hn>>>26)|0,hn&=67108863,A=Math.imul(ue,be),g=Math.imul(ue,ve),g=g+Math.imul(he,be)|0,R=Math.imul(he,ve),A=A+Math.imul(fe,me)|0,g=g+Math.imul(fe,ye)|0,g=g+Math.imul(ce,me)|0,R=R+Math.imul(ce,ye)|0,A=A+Math.imul(oe,we)|0,g=g+Math.imul(oe,_e)|0,g=g+Math.imul(ae,we)|0,R=R+Math.imul(ae,_e)|0,A=A+Math.imul(ne,xe)|0,g=g+Math.imul(ne,Ee)|0,g=g+Math.imul(se,xe)|0,R=R+Math.imul(se,Ee)|0,A=A+Math.imul(G,Se)|0,g=g+Math.imul(G,Ie)|0,g=g+Math.imul(X,Se)|0,R=R+Math.imul(X,Ie)|0,A=A+Math.imul(H,Me)|0,g=g+Math.imul(H,Ae)|0,g=g+Math.imul($,Me)|0,R=R+Math.imul($,Ae)|0,A=A+Math.imul(U,Re)|0,g=g+Math.imul(U,Te)|0,g=g+Math.imul(j,Re)|0,R=R+Math.imul(j,Te)|0,A=A+Math.imul(E,De)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(C,De)|0,R=R+Math.imul(C,Ne)|0;var dn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(dn>>>26)|0,dn&=67108863,A=Math.imul(de,be),g=Math.imul(de,ve),g=g+Math.imul(le,be)|0,R=Math.imul(le,ve),A=A+Math.imul(ue,me)|0,g=g+Math.imul(ue,ye)|0,g=g+Math.imul(he,me)|0,R=R+Math.imul(he,ye)|0,A=A+Math.imul(fe,we)|0,g=g+Math.imul(fe,_e)|0,g=g+Math.imul(ce,we)|0,R=R+Math.imul(ce,_e)|0,A=A+Math.imul(oe,xe)|0,g=g+Math.imul(oe,Ee)|0,g=g+Math.imul(ae,xe)|0,R=R+Math.imul(ae,Ee)|0,A=A+Math.imul(ne,Se)|0,g=g+Math.imul(ne,Ie)|0,g=g+Math.imul(se,Se)|0,R=R+Math.imul(se,Ie)|0,A=A+Math.imul(G,Me)|0,g=g+Math.imul(G,Ae)|0,g=g+Math.imul(X,Me)|0,R=R+Math.imul(X,Ae)|0,A=A+Math.imul(H,Re)|0,g=g+Math.imul(H,Te)|0,g=g+Math.imul($,Re)|0,R=R+Math.imul($,Te)|0,A=A+Math.imul(U,De)|0,g=g+Math.imul(U,Ne)|0,g=g+Math.imul(j,De)|0,R=R+Math.imul(j,Ne)|0,A=A+Math.imul(E,Ce)|0,g=g+Math.imul(E,Pe)|0,g=g+Math.imul(C,Ce)|0,R=R+Math.imul(C,Pe)|0;var ln=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(ln>>>26)|0,ln&=67108863,A=Math.imul(pe,be),g=Math.imul(pe,ve),g=g+Math.imul(ge,be)|0,R=Math.imul(ge,ve),A=A+Math.imul(de,me)|0,g=g+Math.imul(de,ye)|0,g=g+Math.imul(le,me)|0,R=R+Math.imul(le,ye)|0,A=A+Math.imul(ue,we)|0,g=g+Math.imul(ue,_e)|0,g=g+Math.imul(he,we)|0,R=R+Math.imul(he,_e)|0,A=A+Math.imul(fe,xe)|0,g=g+Math.imul(fe,Ee)|0,g=g+Math.imul(ce,xe)|0,R=R+Math.imul(ce,Ee)|0,A=A+Math.imul(oe,Se)|0,g=g+Math.imul(oe,Ie)|0,g=g+Math.imul(ae,Se)|0,R=R+Math.imul(ae,Ie)|0,A=A+Math.imul(ne,Me)|0,g=g+Math.imul(ne,Ae)|0,g=g+Math.imul(se,Me)|0,R=R+Math.imul(se,Ae)|0,A=A+Math.imul(G,Re)|0,g=g+Math.imul(G,Te)|0,g=g+Math.imul(X,Re)|0,R=R+Math.imul(X,Te)|0,A=A+Math.imul(H,De)|0,g=g+Math.imul(H,Ne)|0,g=g+Math.imul($,De)|0,R=R+Math.imul($,Ne)|0,A=A+Math.imul(U,Ce)|0,g=g+Math.imul(U,Pe)|0,g=g+Math.imul(j,Ce)|0,R=R+Math.imul(j,Pe)|0,A=A+Math.imul(E,Ke)|0,g=g+Math.imul(E,je)|0,g=g+Math.imul(C,Ke)|0,R=R+Math.imul(C,je)|0;var pn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(pn>>>26)|0,pn&=67108863,A=Math.imul(pe,me),g=Math.imul(pe,ye),g=g+Math.imul(ge,me)|0,R=Math.imul(ge,ye),A=A+Math.imul(de,we)|0,g=g+Math.imul(de,_e)|0,g=g+Math.imul(le,we)|0,R=R+Math.imul(le,_e)|0,A=A+Math.imul(ue,xe)|0,g=g+Math.imul(ue,Ee)|0,g=g+Math.imul(he,xe)|0,R=R+Math.imul(he,Ee)|0,A=A+Math.imul(fe,Se)|0,g=g+Math.imul(fe,Ie)|0,g=g+Math.imul(ce,Se)|0,R=R+Math.imul(ce,Ie)|0,A=A+Math.imul(oe,Me)|0,g=g+Math.imul(oe,Ae)|0,g=g+Math.imul(ae,Me)|0,R=R+Math.imul(ae,Ae)|0,A=A+Math.imul(ne,Re)|0,g=g+Math.imul(ne,Te)|0,g=g+Math.imul(se,Re)|0,R=R+Math.imul(se,Te)|0,A=A+Math.imul(G,De)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(X,De)|0,R=R+Math.imul(X,Ne)|0,A=A+Math.imul(H,Ce)|0,g=g+Math.imul(H,Pe)|0,g=g+Math.imul($,Ce)|0,R=R+Math.imul($,Pe)|0,A=A+Math.imul(U,Ke)|0,g=g+Math.imul(U,je)|0,g=g+Math.imul(j,Ke)|0,R=R+Math.imul(j,je)|0;var gn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(gn>>>26)|0,gn&=67108863,A=Math.imul(pe,we),g=Math.imul(pe,_e),g=g+Math.imul(ge,we)|0,R=Math.imul(ge,_e),A=A+Math.imul(de,xe)|0,g=g+Math.imul(de,Ee)|0,g=g+Math.imul(le,xe)|0,R=R+Math.imul(le,Ee)|0,A=A+Math.imul(ue,Se)|0,g=g+Math.imul(ue,Ie)|0,g=g+Math.imul(he,Se)|0,R=R+Math.imul(he,Ie)|0,A=A+Math.imul(fe,Me)|0,g=g+Math.imul(fe,Ae)|0,g=g+Math.imul(ce,Me)|0,R=R+Math.imul(ce,Ae)|0,A=A+Math.imul(oe,Re)|0,g=g+Math.imul(oe,Te)|0,g=g+Math.imul(ae,Re)|0,R=R+Math.imul(ae,Te)|0,A=A+Math.imul(ne,De)|0,g=g+Math.imul(ne,Ne)|0,g=g+Math.imul(se,De)|0,R=R+Math.imul(se,Ne)|0,A=A+Math.imul(G,Ce)|0,g=g+Math.imul(G,Pe)|0,g=g+Math.imul(X,Ce)|0,R=R+Math.imul(X,Pe)|0,A=A+Math.imul(H,Ke)|0,g=g+Math.imul(H,je)|0,g=g+Math.imul($,Ke)|0,R=R+Math.imul($,je)|0;var bn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(bn>>>26)|0,bn&=67108863,A=Math.imul(pe,xe),g=Math.imul(pe,Ee),g=g+Math.imul(ge,xe)|0,R=Math.imul(ge,Ee),A=A+Math.imul(de,Se)|0,g=g+Math.imul(de,Ie)|0,g=g+Math.imul(le,Se)|0,R=R+Math.imul(le,Ie)|0,A=A+Math.imul(ue,Me)|0,g=g+Math.imul(ue,Ae)|0,g=g+Math.imul(he,Me)|0,R=R+Math.imul(he,Ae)|0,A=A+Math.imul(fe,Re)|0,g=g+Math.imul(fe,Te)|0,g=g+Math.imul(ce,Re)|0,R=R+Math.imul(ce,Te)|0,A=A+Math.imul(oe,De)|0,g=g+Math.imul(oe,Ne)|0,g=g+Math.imul(ae,De)|0,R=R+Math.imul(ae,Ne)|0,A=A+Math.imul(ne,Ce)|0,g=g+Math.imul(ne,Pe)|0,g=g+Math.imul(se,Ce)|0,R=R+Math.imul(se,Pe)|0,A=A+Math.imul(G,Ke)|0,g=g+Math.imul(G,je)|0,g=g+Math.imul(X,Ke)|0,R=R+Math.imul(X,je)|0;var vn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(vn>>>26)|0,vn&=67108863,A=Math.imul(pe,Se),g=Math.imul(pe,Ie),g=g+Math.imul(ge,Se)|0,R=Math.imul(ge,Ie),A=A+Math.imul(de,Me)|0,g=g+Math.imul(de,Ae)|0,g=g+Math.imul(le,Me)|0,R=R+Math.imul(le,Ae)|0,A=A+Math.imul(ue,Re)|0,g=g+Math.imul(ue,Te)|0,g=g+Math.imul(he,Re)|0,R=R+Math.imul(he,Te)|0,A=A+Math.imul(fe,De)|0,g=g+Math.imul(fe,Ne)|0,g=g+Math.imul(ce,De)|0,R=R+Math.imul(ce,Ne)|0,A=A+Math.imul(oe,Ce)|0,g=g+Math.imul(oe,Pe)|0,g=g+Math.imul(ae,Ce)|0,R=R+Math.imul(ae,Pe)|0,A=A+Math.imul(ne,Ke)|0,g=g+Math.imul(ne,je)|0,g=g+Math.imul(se,Ke)|0,R=R+Math.imul(se,je)|0;var mn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(mn>>>26)|0,mn&=67108863,A=Math.imul(pe,Me),g=Math.imul(pe,Ae),g=g+Math.imul(ge,Me)|0,R=Math.imul(ge,Ae),A=A+Math.imul(de,Re)|0,g=g+Math.imul(de,Te)|0,g=g+Math.imul(le,Re)|0,R=R+Math.imul(le,Te)|0,A=A+Math.imul(ue,De)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(he,De)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(fe,Ce)|0,g=g+Math.imul(fe,Pe)|0,g=g+Math.imul(ce,Ce)|0,R=R+Math.imul(ce,Pe)|0,A=A+Math.imul(oe,Ke)|0,g=g+Math.imul(oe,je)|0,g=g+Math.imul(ae,Ke)|0,R=R+Math.imul(ae,je)|0;var yn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(yn>>>26)|0,yn&=67108863,A=Math.imul(pe,Re),g=Math.imul(pe,Te),g=g+Math.imul(ge,Re)|0,R=Math.imul(ge,Te),A=A+Math.imul(de,De)|0,g=g+Math.imul(de,Ne)|0,g=g+Math.imul(le,De)|0,R=R+Math.imul(le,Ne)|0,A=A+Math.imul(ue,Ce)|0,g=g+Math.imul(ue,Pe)|0,g=g+Math.imul(he,Ce)|0,R=R+Math.imul(he,Pe)|0,A=A+Math.imul(fe,Ke)|0,g=g+Math.imul(fe,je)|0,g=g+Math.imul(ce,Ke)|0,R=R+Math.imul(ce,je)|0;var wn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(wn>>>26)|0,wn&=67108863,A=Math.imul(pe,De),g=Math.imul(pe,Ne),g=g+Math.imul(ge,De)|0,R=Math.imul(ge,Ne),A=A+Math.imul(de,Ce)|0,g=g+Math.imul(de,Pe)|0,g=g+Math.imul(le,Ce)|0,R=R+Math.imul(le,Pe)|0,A=A+Math.imul(ue,Ke)|0,g=g+Math.imul(ue,je)|0,g=g+Math.imul(he,Ke)|0,R=R+Math.imul(he,je)|0;var iu=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(iu>>>26)|0,iu&=67108863,A=Math.imul(pe,Ce),g=Math.imul(pe,Pe),g=g+Math.imul(ge,Ce)|0,R=Math.imul(ge,Pe),A=A+Math.imul(de,Ke)|0,g=g+Math.imul(de,je)|0,g=g+Math.imul(le,Ke)|0,R=R+Math.imul(le,je)|0;var nu=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nu>>>26)|0,nu&=67108863,A=Math.imul(pe,Ke),g=Math.imul(pe,je),g=g+Math.imul(ge,Ke)|0,R=Math.imul(ge,je);var su=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(su>>>26)|0,su&=67108863,h[0]=Gt,h[1]=Jt,h[2]=Wt,h[3]=Yt,h[4]=Xt,h[5]=un,h[6]=hn,h[7]=dn,h[8]=ln,h[9]=pn,h[10]=gn,h[11]=bn,h[12]=vn,h[13]=mn,h[14]=yn,h[15]=wn,h[16]=iu,h[17]=nu,h[18]=su,x!==0&&(h[19]=x,v.length++),v};Math.imul||(N=O);function B(p,a,d){d.negative=a.negative^p.negative,d.length=p.length+a.length;for(var v=0,_=0,m=0;m>>26)|0,_+=h>>>26,h&=67108863}d.words[m]=x,v=h,h=_}return v!==0?d.words[m]=v:d.length--,d._strip()}function z(p,a,d){return B(p,a,d)}n.prototype.mulTo=function(a,d){var v,_=this.length+a.length;return this.length===10&&a.length===10?v=N(this,a,d):_<63?v=O(this,a,d):_<1024?v=B(this,a,d):v=z(this,a,d),v};function F(p,a){this.x=p,this.y=a}F.prototype.makeRBT=function(a){for(var d=new Array(a),v=n.prototype._countBits(a)-1,_=0;_>=1;return _},F.prototype.permute=function(a,d,v,_,m,h){for(var x=0;x>>1)m++;return 1<>>13,v[2*h+1]=m&8191,m=m>>>13;for(h=2*d;h<_;++h)v[h]=0;t(m===0),t((m&-8192)===0)},F.prototype.stub=function(a){for(var d=new Array(a),v=0;v>=26,v+=m/67108864|0,v+=h>>>26,this.words[_]=h&67108863}return v!==0&&(this.words[_]=v,this.length++),d?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var d=T(a);if(d.length===0)return new n(1);for(var v=this,_=0;_=0);var d=a%26,v=(a-d)/26,_=67108863>>>26-d<<26-d,m;if(d!==0){var h=0;for(m=0;m>>26-d}h&&(this.words[m]=h,this.length++)}if(v!==0){for(m=this.length-1;m>=0;m--)this.words[m+v]=this.words[m];for(m=0;m=0);var _;d?_=(d-d%26)/26:_=0;var m=a%26,h=Math.min((a-m)/26,this.length),x=67108863^67108863>>>m<h)for(this.length-=h,g=0;g=0&&(R!==0||g>=_);g--){var K=this.words[g]|0;this.words[g]=R<<26-m|K>>>m,R=K&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,d,v){return t(this.negative===0),this.iushrn(a,d,v)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var d=a%26,v=(a-d)/26,_=1<=0);var d=a%26,v=(a-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(d!==0&&v++,this.length=Math.min(v,this.length),d!==0){var _=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(A/67108864|0),this.words[m+v]=h&67108863}for(;m>26,this.words[m+v]=h&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,m=0;m>26,this.words[m]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,d){var v=this.length-a.length,_=this.clone(),m=a,h=m.words[m.length-1]|0,x=this._countBits(h);v=26-x,v!==0&&(m=m.ushln(v),_.iushln(v),h=m.words[m.length-1]|0);var A=_.length-m.length,g;if(d!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var C=(_.words[m.length+E]|0)*67108864+(_.words[m.length+E-1]|0);for(C=Math.min(C/h|0,67108863),_._ishlnsubmul(m,C,E);_.negative!==0;)C--,_.negative=0,_._ishlnsubmul(m,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=C)}return g&&g._strip(),_._strip(),d!=="div"&&v!==0&&_.iushrn(v),{div:g||null,mod:_}},n.prototype.divmod=function(a,d,v){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,m,h;return this.negative!==0&&a.negative===0?(h=this.neg().divmod(a,d),d!=="mod"&&(_=h.div.neg()),d!=="div"&&(m=h.mod.neg(),v&&m.negative!==0&&m.iadd(a)),{div:_,mod:m}):this.negative===0&&a.negative!==0?(h=this.divmod(a.neg(),d),d!=="mod"&&(_=h.div.neg()),{div:_,mod:h.mod}):this.negative&a.negative?(h=this.neg().divmod(a.neg(),d),d!=="div"&&(m=h.mod.neg(),v&&m.negative!==0&&m.isub(a)),{div:h.div,mod:m}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?d==="div"?{div:this.divn(a.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,d)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var d=this.divmod(a);if(d.mod.isZero())return d.div;var v=d.div.negative!==0?d.mod.isub(a):d.mod,_=a.ushrn(1),m=a.andln(1),h=v.cmp(_);return h<0||m===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var v=(1<<26)%a,_=0,m=this.length-1;m>=0;m--)_=(v*_+(this.words[m]|0))%a;return d?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var v=0,_=this.length-1;_>=0;_--){var m=(this.words[_]|0)+v*67108864;this.words[_]=m/a|0,v=m%a}return this._strip(),d?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var d=this,v=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),m=new n(0),h=new n(0),x=new n(1),A=0;d.isEven()&&v.isEven();)d.iushrn(1),v.iushrn(1),++A;for(var g=v.clone(),R=d.clone();!d.isZero();){for(var K=0,E=1;!(d.words[0]&E)&&K<26;++K,E<<=1);if(K>0)for(d.iushrn(K);K-- >0;)(_.isOdd()||m.isOdd())&&(_.iadd(g),m.isub(R)),_.iushrn(1),m.iushrn(1);for(var C=0,q=1;!(v.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(v.iushrn(C);C-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(g),x.isub(R)),h.iushrn(1),x.iushrn(1);d.cmp(v)>=0?(d.isub(v),_.isub(h),m.isub(x)):(v.isub(d),h.isub(_),x.isub(m))}return{a:h,b:x,gcd:v.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var d=this,v=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),m=new n(0),h=v.clone();d.cmpn(1)>0&&v.cmpn(1)>0;){for(var x=0,A=1;!(d.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(d.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(h),_.iushrn(1);for(var g=0,R=1;!(v.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(v.iushrn(g);g-- >0;)m.isOdd()&&m.iadd(h),m.iushrn(1);d.cmp(v)>=0?(d.isub(v),_.isub(m)):(v.isub(d),m.isub(_))}var K;return d.cmpn(1)===0?K=_:K=m,K.cmpn(0)<0&&K.iadd(a),K},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var d=this.clone(),v=a.clone();d.negative=0,v.negative=0;for(var _=0;d.isEven()&&v.isEven();_++)d.iushrn(1),v.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;v.isEven();)v.iushrn(1);var m=d.cmp(v);if(m<0){var h=d;d=v,v=h}else if(m===0||v.cmpn(1)===0)break;d.isub(v)}while(!0);return v.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var d=a%26,v=(a-d)/26,_=1<>>26,x&=67108863,this.words[h]=x}return m!==0&&(this.words[h]=m,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var d=a<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var v;if(this.length>1)v=1;else{d&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;v=_===a?0:_a.length)return 1;if(this.length=0;v--){var _=this.words[v]|0,m=a.words[v]|0;if(_!==m){_m&&(d=1);break}}return d},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var k={k256:null,p224:null,p192:null,p25519:null};function V(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},V.prototype.ireduce=function(a){var d=a,v;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),v=d.bitLength();while(v>this.n);var _=v0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},V.prototype.split=function(a,d){a.iushrn(this.n,0,d)},V.prototype.imulK=function(a){return a.imul(this.k)};function L(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,V),L.prototype.split=function(a,d){for(var v=4194303,_=Math.min(a.length,9),m=0;m<_;m++)d.words[m]=a.words[m];if(d.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var h=a.words[9];for(d.words[d.length++]=h&v,m=10;m>>22,h=x}h>>>=22,a.words[m-10]=h,h===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var d=0,v=0;v>>=26,a.words[v]=m,d=_}return d!==0&&(a.words[a.length++]=d),a},n._prime=function(a){if(k[a])return k[a];var d;if(a==="k256")d=new L;else if(a==="p224")d=new P;else if(a==="p192")d=new J;else if(a==="p25519")d=new D;else throw new Error("Unknown prime "+a);return k[a]=d,d};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,d){t((a.negative|d.negative)===0,"red works only with positives"),t(a.red&&a.red===d.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(u(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,d){this._verify2(a,d);var v=a.add(d);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},l.prototype.iadd=function(a,d){this._verify2(a,d);var v=a.iadd(d);return v.cmp(this.m)>=0&&v.isub(this.m),v},l.prototype.sub=function(a,d){this._verify2(a,d);var v=a.sub(d);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},l.prototype.isub=function(a,d){this._verify2(a,d);var v=a.isub(d);return v.cmpn(0)<0&&v.iadd(this.m),v},l.prototype.shl=function(a,d){return this._verify1(a),this.imod(a.ushln(d))},l.prototype.imul=function(a,d){return this._verify2(a,d),this.imod(a.imul(d))},l.prototype.mul=function(a,d){return this._verify2(a,d),this.imod(a.mul(d))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var v=this.m.add(new n(1)).iushrn(2);return this.pow(a,v)}for(var _=this.m.subn(1),m=0;!_.isZero()&&_.andln(1)===0;)m++,_.iushrn(1);t(!_.isZero());var h=new n(1).toRed(this),x=h.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),K=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),C=m;E.cmp(h)!==0;){for(var q=E,U=0;q.cmp(h)!==0;U++)q=q.redSqr();t(U=0;m--){for(var R=d.words[m],K=g-1;K>=0;K--){var E=R>>K&1;if(h!==_[0]&&(h=this.sqr(h)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==v&&(m!==0||K!==0))&&(h=this.mul(h,_[x]),A=0,x=0)}g=26}return h},l.prototype.convertTo=function(a){var d=a.umod(this.m);return d===a?d.clone():d},l.prototype.convertFrom=function(a){var d=a.clone();return d.red=null,d},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var d=this.imod(a.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(a,d){if(a.isZero()||d.isZero())return a.words[0]=0,a.length=1,a;var v=a.imul(d),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),h=m;return m.cmp(this.m)>=0?h=m.isub(this.m):m.cmpn(0)<0&&(h=m.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(a,d){if(a.isZero()||d.isZero())return new n(0)._forceRed(this);var v=a.mul(d),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),h=m;return m.cmp(this.m)>=0?h=m.isub(this.m):m.cmpn(0)<0&&(h=m.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(a){var d=this.imod(a._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof qh>"u"||qh,Gg)});var Jg,Wg=Z(()=>{Jg="bignumber/5.7.0"});function Uh(r){return new a_(r,36).toString(16)}var Yg,a_,oN,Xg=Z(()=>{"use strict";Yg=Ue(Fh());Li();Wg();a_=Yg.default.BN,oN=new ht(Jg)});var Zg=Z(()=>{Xg()});var Qg,eb=Z(()=>{Qg="strings/5.7.0"});function c_(r,e,t,i,n){return tb.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function rb(r,e,t,i,n){if(r===Nn.BAD_PREFIX||r===Nn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===Nn.OVERRUN?t.length-e-1:0}function u_(r,e,t,i,n){return r===Nn.OVERLONG?(i.push(n),0):(i.push(65533),rb(r,e,t,i,n))}function No(r,e=Do.current){e!=Do.current&&(tb.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return Xe(t)}var tb,Do,Nn,h_,ib=Z(()=>{"use strict";Dn();Li();eb();tb=new ht(Qg);(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(Do||(Do={}));(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(Nn||(Nn={}));h_=Object.freeze({error:c_,ignore:rb,replace:u_})});var nb=Z(()=>{"use strict";ib()});function Cf(r){return typeof r=="string"&&(r=No(r)),ws(Oh([No(sb),No(String(r.length)),r]))}var sb,ob=Z(()=>{Dn();Nf();nb();sb=`Ethereum Signed Message: -`});var ab,fb=Z(()=>{ab="address/5.7.0"});function cb(r){pr(r,20)||Co.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=Xe(ws(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}function p_(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}function g_(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Bh[i]).join("");for(;e.length>=ub;){let i=e.substring(0,ub);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function hb(r){let e=null;if(typeof r!="string"&&Co.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=cb(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&Co.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==g_(r)&&Co.throwArgumentError("bad icap checksum","address",r),e=Uh(r.substring(4));e.length<40;)e="0"+e;e=cb("0x"+e)}else Co.throwArgumentError("invalid address","address",r);return e}var Co,l_,Bh,ub,db=Z(()=>{"use strict";Dn();Zg();Nf();Li();fb();Co=new ht(ab);l_=9007199254740991;Bh={};for(let r=0;r<10;r++)Bh[String(r)]=String(r);for(let r=0;r<26;r++)Bh[String.fromCharCode(65+r)]=String(10+r);ub=Math.floor(p_(l_))});var lb,pb=Z(()=>{lb="properties/5.7.0"});function _s(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var LN,gb=Z(()=>{"use strict";Li();pb();LN=new ht(lb)});var bb=Z(()=>{"use strict";ob()});var Fi=W((BN,mb)=>{mb.exports=vb;function vb(r,e){if(!r)throw new Error(e||"Assertion failed")}vb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var Po=W((zN,zh)=>{typeof Object.create=="function"?zh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:zh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var gr=W(He=>{"use strict";var b_=Fi(),v_=Po();He.inherits=v_;function m_(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function y_(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):m_(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}He.htonl=yb;function __(r,e){for(var t="",i=0;i>>0}return s}He.join32=x_;function E_(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}He.split32=E_;function S_(r,e){return r>>>e|r<<32-e}He.rotr32=S_;function I_(r,e){return r<>>32-e}He.rotl32=I_;function M_(r,e){return r+e>>>0}He.sum32=M_;function A_(r,e,t){return r+e+t>>>0}He.sum32_3=A_;function R_(r,e,t,i){return r+e+t+i>>>0}He.sum32_4=R_;function T_(r,e,t,i,n){return r+e+t+i+n>>>0}He.sum32_5=T_;function D_(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}He.sum64=D_;function N_(r,e,t,i){var n=e+i>>>0,s=(n>>0}He.sum64_hi=N_;function C_(r,e,t,i){var n=e+i;return n>>>0}He.sum64_lo=C_;function P_(r,e,t,i,n,s,o,f){var c=0,u=e;u=u+i>>>0,c+=u>>0,c+=u>>0,c+=u>>0}He.sum64_4_hi=P_;function O_(r,e,t,i,n,s,o,f){var c=e+i+s+f;return c>>>0}He.sum64_4_lo=O_;function L_(r,e,t,i,n,s,o,f,c,u){var b=0,y=e;y=y+i>>>0,b+=y>>0,b+=y>>0,b+=y>>0,b+=y>>0}He.sum64_5_hi=L_;function q_(r,e,t,i,n,s,o,f,c,u){var b=e+i+s+f+u;return b>>>0}He.sum64_5_lo=q_;function F_(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}He.rotr64_hi=F_;function U_(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}He.rotr64_lo=U_;function B_(r,e,t){return r>>>t}He.shr64_hi=B_;function z_(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}He.shr64_lo=z_});var xs=W(Eb=>{"use strict";var xb=gr(),k_=Fi();function Pf(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}Eb.BlockHash=Pf;Pf.prototype.update=function(e,t){if(e=xb.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=xb.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var K_=gr(),Hr=K_.rotr32;function j_(r,e,t,i){if(r===0)return Sb(e,t,i);if(r===1||r===3)return Mb(e,t,i);if(r===2)return Ib(e,t,i)}vi.ft_1=j_;function Sb(r,e,t){return r&e^~r&t}vi.ch32=Sb;function Ib(r,e,t){return r&e^r&t^e&t}vi.maj32=Ib;function Mb(r,e,t){return r^e^t}vi.p32=Mb;function V_(r){return Hr(r,2)^Hr(r,13)^Hr(r,22)}vi.s0_256=V_;function $_(r){return Hr(r,6)^Hr(r,11)^Hr(r,25)}vi.s1_256=$_;function H_(r){return Hr(r,7)^Hr(r,18)^r>>>3}vi.g0_256=H_;function G_(r){return Hr(r,17)^Hr(r,19)^r>>>10}vi.g1_256=G_});var Tb=W((VN,Rb)=>{"use strict";var Es=gr(),J_=xs(),W_=kh(),Kh=Es.rotl32,Oo=Es.sum32,Y_=Es.sum32_5,X_=W_.ft_1,Ab=J_.BlockHash,Z_=[1518500249,1859775393,2400959708,3395469782];function Gr(){if(!(this instanceof Gr))return new Gr;Ab.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Es.inherits(Gr,Ab);Rb.exports=Gr;Gr.blockSize=512;Gr.outSize=160;Gr.hmacStrength=80;Gr.padLength=64;Gr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Ss=gr(),Q_=xs(),Is=kh(),ex=Fi(),br=Ss.sum32,tx=Ss.sum32_4,rx=Ss.sum32_5,ix=Is.ch32,nx=Is.maj32,sx=Is.s0_256,ox=Is.s1_256,ax=Is.g0_256,fx=Is.g1_256,Db=Q_.BlockHash,cx=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Jr(){if(!(this instanceof Jr))return new Jr;Db.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=cx,this.W=new Array(64)}Ss.inherits(Jr,Db);Nb.exports=Jr;Jr.blockSize=512;Jr.outSize=256;Jr.hmacStrength=192;Jr.padLength=64;Jr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Vh=gr(),Cb=jh();function mi(){if(!(this instanceof mi))return new mi;Cb.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Vh.inherits(mi,Cb);Pb.exports=mi;mi.blockSize=512;mi.outSize=224;mi.hmacStrength=192;mi.padLength=64;mi.prototype._digest=function(e){return e==="hex"?Vh.toHex32(this.h.slice(0,7),"big"):Vh.split32(this.h.slice(0,7),"big")}});var Gh=W((GN,Ub)=>{"use strict";var Ut=gr(),ux=xs(),hx=Fi(),Wr=Ut.rotr64_hi,Yr=Ut.rotr64_lo,Lb=Ut.shr64_hi,qb=Ut.shr64_lo,Ui=Ut.sum64,$h=Ut.sum64_hi,Hh=Ut.sum64_lo,dx=Ut.sum64_4_hi,lx=Ut.sum64_4_lo,px=Ut.sum64_5_hi,gx=Ut.sum64_5_lo,Fb=ux.BlockHash,bx=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function vr(){if(!(this instanceof vr))return new vr;Fb.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=bx,this.W=new Array(160)}Ut.inherits(vr,Fb);Ub.exports=vr;vr.blockSize=1024;vr.outSize=512;vr.hmacStrength=192;vr.padLength=128;vr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Jh=gr(),Bb=Gh();function yi(){if(!(this instanceof yi))return new yi;Bb.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Jh.inherits(yi,Bb);zb.exports=yi;yi.blockSize=1024;yi.outSize=384;yi.hmacStrength=192;yi.padLength=128;yi.prototype._digest=function(e){return e==="hex"?Jh.toHex32(this.h.slice(0,12),"big"):Jh.split32(this.h.slice(0,12),"big")}});var Kb=W(Ms=>{"use strict";Ms.sha1=Tb();Ms.sha224=Ob();Ms.sha256=jh();Ms.sha384=kb();Ms.sha512=Gh()});var Jb=W(Gb=>{"use strict";var Cn=gr(),Tx=xs(),Of=Cn.rotl32,jb=Cn.sum32,Lo=Cn.sum32_3,Vb=Cn.sum32_4,Hb=Tx.BlockHash;function Xr(){if(!(this instanceof Xr))return new Xr;Hb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Cn.inherits(Xr,Hb);Gb.ripemd160=Xr;Xr.blockSize=512;Xr.outSize=160;Xr.hmacStrength=192;Xr.padLength=64;Xr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],c=i,u=n,b=s,y=o,S=f,I=0;I<80;I++){var M=jb(Of(Vb(i,$b(I,n,s,o),e[Cx[I]+t],Dx(I)),Ox[I]),f);i=f,f=o,o=Of(s,10),s=n,n=M,M=jb(Of(Vb(c,$b(79-I,u,b,y),e[Px[I]+t],Nx(I)),Lx[I]),S),c=S,S=y,y=Of(b,10),b=u,u=M}M=Lo(this.h[1],s,y),this.h[1]=Lo(this.h[2],o,S),this.h[2]=Lo(this.h[3],f,c),this.h[3]=Lo(this.h[4],i,u),this.h[4]=Lo(this.h[0],n,b),this.h[0]=M};Xr.prototype._digest=function(e){return e==="hex"?Cn.toHex32(this.h,"little"):Cn.split32(this.h,"little")};function $b(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function Dx(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function Nx(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var Cx=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Px=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],Ox=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Lx=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var Yb=W((XN,Wb)=>{"use strict";var qx=gr(),Fx=Fi();function As(r,e,t){if(!(this instanceof As))return new As(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(qx.toArray(e,t))}Wb.exports=As;As.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),Fx(e.length<=this.blockSize);for(var t=e.length;t{var yt=Xb;yt.utils=gr();yt.common=xs();yt.sha=Kb();yt.ripemd=Jb();yt.hmac=Yb();yt.sha1=yt.sha.sha1;yt.sha256=yt.sha.sha256;yt.sha224=yt.sha.sha224;yt.sha384=yt.sha.sha384;yt.sha512=yt.sha.sha512;yt.ripemd160=yt.ripemd.ripemd160});function Rs(r,e,t){return t={path:e,exports:{},require:function(i,n){return Ux(i,n??t.path)}},r(t,t.exports),t.exports}function Ux(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}function Qb(r,e){if(!r)throw new Error(e||"Assertion failed")}function zi(r,e){this.type=r,this.p=new Oe.default(e.p,16),this.red=e.prime?Oe.default.red(e.prime):Oe.default.mont(this.p),this.zero=new Oe.default(0).toRed(this.red),this.one=new Oe.default(1).toRed(this.red),this.two=new Oe.default(2).toRed(this.red),this.n=e.n&&new Oe.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function tr(r,e){this.curve=r,this.type=e,this.precomputed=null}function rr(r){Pn.call(this,"short",r),this.a=new Oe.default(r.a,16).toRed(this.red),this.b=new Oe.default(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function dt(r,e,t,i){Pn.BasePoint.call(this,r,"affine"),e===null&&t===null?(this.x=null,this.y=null,this.inf=!0):(this.x=new Oe.default(e,16),this.y=new Oe.default(t,16),i&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function wt(r,e,t,i){Pn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Oe.default(0)):(this.x=new Oe.default(e,16),this.y=new Oe.default(t,16),this.z=new Oe.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}function Bi(r){if(!(this instanceof Bi))return new Bi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=mr.toArray(r.entropy,r.entropyEnc||"hex"),t=mr.toArray(r.nonce,r.nonceEnc||"hex"),i=mr.toArray(r.pers,r.persEnc||"hex");Zh(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}function At(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}function Bf(r,e){if(r instanceof Bf)return r;this._importDER(r,e)||(Kx(r.r&&r.s,"Signature without r or s"),this.r=new Oe.default(r.r,16),this.s=new Oe.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}function jx(){this.place=0}function Wh(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Zb(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}function er(r){if(!(this instanceof er))return new er(r);typeof r=="string"&&(tv(Object.prototype.hasOwnProperty.call(qf,r),"Unknown curve "+r),r=qf[r]),r instanceof qf.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var Oe,Zr,Zh,mr,Kt,Ff,Bx,Uf,Pn,Qh,zx,kx,Lf,qf,ev,Xh,ed,Kx,zf,Vx,tv,$x,Hx,rv,iv=Z(()=>{Oe=Ue(Fh()),Zr=Ue(qo());Zh=Qb;Qb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};mr=Rs(function(r,e){"use strict";var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var c=[];if(typeof o!="string"){for(var u=0;u>8,S=b&255;y?c.push(y,S):c.push(S)}return c}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",c=0;c(S>>1)-1?T=(S>>1)-O:T=O,I.isubn(T)):T=0,y[M]=T,I.iushrn(1)}return y}t.getNAF=i;function n(c,u){var b=[[],[]];c=c.clone(),u=u.clone();for(var y=0,S=0,I;c.cmpn(-y)>0||u.cmpn(-S)>0;){var M=c.andln(3)+y&3,T=u.andln(3)+S&3;M===3&&(M=-1),T===3&&(T=-1);var O;M&1?(I=c.andln(7)+y&7,(I===3||I===5)&&T===2?O=-M:O=M):O=0,b[0].push(O);var N;T&1?(I=u.andln(7)+S&7,(I===3||I===5)&&M===2?N=-T:N=T):N=0,b[1].push(N),2*y===O+1&&(y=1-y),2*S===N+1&&(S=1-S),c.iushrn(1),u.iushrn(1)}return b}t.getJSF=n;function s(c,u,b){var y="_"+u;c.prototype[u]=function(){return this[y]!==void 0?this[y]:this[y]=b.call(this)}}t.cachedProperty=s;function o(c){return typeof c=="string"?t.toArray(c,"hex"):c}t.parseBytes=o;function f(c){return new Oe.default(c,"hex","le")}t.intFromLE=f}),Ff=Kt.getNAF,Bx=Kt.getJSF,Uf=Kt.assert;Pn=zi;zi.prototype.point=function(){throw new Error("Not implemented")};zi.prototype.validate=function(){throw new Error("Not implemented")};zi.prototype._fixedNafMul=function(e,t){Uf(e.precomputed);var i=e._getDoubles(),n=Ff(t,1,this._bitLength),s=(1<=f;u--)c=(c<<1)+n[u];o.push(c)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;c--){for(var u=0;c>=0&&o[c]===0;c--)u++;if(c>=0&&u++,f=f.dblp(u),c<0)break;var b=o[c];Uf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};zi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,c=this._wnafT3,u=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){c[M]=Ff(i[M],o[M],this._bitLength),c[T]=Ff(i[T],o[T],this._bitLength),u=Math.max(c[M].length,u),u=Math.max(c[T].length,u);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],B=Bx(i[M],i[T]);for(u=Math.max(B[0].length,u),c[M]=new Array(u),c[T]=new Array(u),y=0;y=0;b--){for(var L=0;b>=0;){var P=!0;for(y=0;y=0&&L++,k=k.dblp(L),b<0)break;for(y=0;y0?S=f[y][J-1>>1]:J<0&&(S=f[y][-J-1>>1].neg()),S.type==="affine"?k=k.mixedAdd(S):k=k.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};tr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=u,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};rr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),c=o.mul(n.a),u=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(c),S=u.add(b).neg();return{k1:y,k2:S}};rr.prototype.pointFromX=function(e,t){e=new Oe.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};rr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};rr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};dt.prototype.isInfinity=function(){return this.inf};dt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};dt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};dt.prototype.getX=function(){return this.x.fromRed()};dt.prototype.getY=function(){return this.y.fromRed()};dt.prototype.mul=function(e){return e=new Oe.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};dt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};dt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};dt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};dt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};dt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};Qh(wt,Pn.BasePoint);rr.prototype.jpoint=function(e,t,i){return new wt(this,e,t,i)};wt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};wt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};wt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),u=o.redSub(f);if(c.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=c.redSqr(),y=b.redMul(c),S=n.redMul(b),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),M=u.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,M,T)};wt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),c=s.redSub(o);if(f.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=f.redSqr(),b=u.redMul(f),y=i.redMul(u),S=c.redSqr().redIAdd(b).redISub(y).redISub(y),I=c.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};wt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};wt.prototype.inspect=function(){return this.isInfinity()?"":""};wt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};Lf=Rs(function(r,e){"use strict";var t=e;t.base=Pn,t.short=kx,t.mont=null,t.edwards=null}),qf=Rs(function(r,e){"use strict";var t=e,i=Kt.assert;function n(f){f.type==="short"?this.curve=new Lf.short(f):f.type==="edwards"?this.curve=new Lf.edwards(f):this.curve=new Lf.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,c){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var u=new n(c);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:u}),u}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Zr.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Zr.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Zr.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Zr.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Zr.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zr.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zr.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Zr.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});ev=Bi;Bi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Bi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=mr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};Kx=Kt.assert;zf=Bf;Bf.prototype._importDER=function(e,t){e=Kt.toArray(e,t);var i=new jx;if(e[i.place++]!==48)return!1;var n=Wh(e,i);if(n===!1||n+i.place!==e.length||e[i.place++]!==2)return!1;var s=Wh(e,i);if(s===!1)return!1;var o=e.slice(i.place,s+i.place);if(i.place+=s,e[i.place++]!==2)return!1;var f=Wh(e,i);if(f===!1||e.length!==f+i.place)return!1;var c=e.slice(i.place,f+i.place);if(o[0]===0)if(o[1]&128)o=o.slice(1);else return!1;if(c[0]===0)if(c[1]&128)c=c.slice(1);else return!1;return this.r=new Oe.default(o),this.s=new Oe.default(c),this.recoveryParam=null,!0};Bf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Zb(t),i=Zb(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Yh(n,t.length),n=n.concat(t),n.push(2),Yh(n,i.length);var s=n.concat(i),o=[48];return Yh(o,s.length),o=o.concat(s),Kt.encode(o,e)};Vx=function(){throw new Error("unsupported")},tv=Kt.assert;$x=er;er.prototype.keyPair=function(e){return new ed(this,e)};er.prototype.keyFromPrivate=function(e,t){return ed.fromPrivate(this,e,t)};er.prototype.keyFromPublic=function(e,t){return ed.fromPublic(this,e,t)};er.prototype.genKeyPair=function(e){e||(e={});for(var t=new ev({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||Vx(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Oe.default(2));;){var s=new Oe.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};er.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};er.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Oe.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),c=new ev({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Oe.default(1)),b=0;;b++){var y=n.k?n.k(b):new Oe.default(c.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new zf({r:M,s:T,recoveryParam:O})}}}}}};er.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Oe.default(e,16)),i=this.keyFromPublic(i,n),t=new zf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),c=f.mul(e).umod(this.n),u=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};er.prototype.recoverPubKey=function(r,e,t,i){tv((3&t)===t,"The recovery param is more than two bits"),e=new zf(e,i);var n=this.n,s=new Oe.default(r),o=e.r,f=e.s,c=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};er.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new zf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};Hx=Rs(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=Kt,t.rand=function(){throw new Error("unsupported")},t.curve=Lf,t.curves=qf,t.ec=$x,t.eddsa=null}),rv=Hx.ec});var nv,sv=Z(()=>{nv="signing-key/5.7.0"});function Qr(){return td||(td=new rv("secp256k1")),td}function ov(r,e){let t=Df(e),i={r:Xe(t.r),s:Xe(t.s)};return"0x"+Qr().recoverPubKey(Xe(r),i,t.recoveryParam).encode("hex",!1)}function nd(r,e){let t=Xe(r);if(t.length===32){let i=new id(t);return e?"0x"+Qr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Mt(t):"0x"+Qr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Qr().keyFromPublic(t).getPublic(!0,"hex"):Mt(t)}return rd.throwArgumentError("invalid public or private key","key","[REDACTED]")}var rd,td,id,av=Z(()=>{"use strict";iv();Dn();gb();Li();sv();rd=new ht(nv),td=null;id=class{constructor(e){_s(this,"curve","secp256k1"),_s(this,"privateKey",Mt(e)),Rf(this.privateKey)!==32&&rd.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Qr().keyFromPrivate(Xe(this.privateKey));_s(this,"publicKey","0x"+t.getPublic(!1,"hex")),_s(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),_s(this,"_isSigningKey",!0)}_addPoint(e){let t=Qr().keyFromPublic(Xe(this.publicKey)),i=Qr().keyFromPublic(Xe(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=Qr().keyFromPrivate(Xe(this.privateKey)),i=Xe(e);i.length!==32&&rd.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return Df({recoveryParam:n.recoveryParam,r:qi("0x"+n.r.toString(16),32),s:qi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=Qr().keyFromPrivate(Xe(this.privateKey)),i=Qr().keyFromPublic(Xe(nd(e)));return qi("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}}});var fv,cv=Z(()=>{fv="transactions/5.7.0"});function Gx(r){let e=nd(r);return hb(Tf(ws(Tf(e,1)),12))}function hv(r,e){return Gx(ov(Xe(r),e))}var gC,uv,dv=Z(()=>{"use strict";db();Dn();Nf();av();Li();cv();gC=new ht(fv);(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(uv||(uv={}))});var pv=W(kf=>{"use strict";Object.defineProperty(kf,"__esModule",{value:!0});var Rt=fs(),sd=Qt(),Jx=20;function Wx(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],c=t[7]<<24|t[6]<<16|t[5]<<8|t[4],u=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],N=e[11]<<24|e[10]<<16|e[9]<<8|e[8],B=e[15]<<24|e[14]<<16|e[13]<<8|e[12],z=i,F=n,k=s,V=o,L=f,P=c,J=u,D=b,l=y,w=S,p=I,a=M,d=T,v=O,_=N,m=B,h=0;h>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,F=F+P|0,v^=F,v=v>>>16|v<<16,w=w+v|0,P^=w,P=P>>>20|P<<12,k=k+J|0,_^=k,_=_>>>16|_<<16,p=p+_|0,J^=p,J=J>>>20|J<<12,V=V+D|0,m^=V,m=m>>>16|m<<16,a=a+m|0,D^=a,D=D>>>20|D<<12,k=k+J|0,_^=k,_=_>>>24|_<<8,p=p+_|0,J^=p,J=J>>>25|J<<7,V=V+D|0,m^=V,m=m>>>24|m<<8,a=a+m|0,D^=a,D=D>>>25|D<<7,F=F+P|0,v^=F,v=v>>>24|v<<8,w=w+v|0,P^=w,P=P>>>25|P<<7,z=z+L|0,d^=z,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,z=z+P|0,m^=z,m=m>>>16|m<<16,p=p+m|0,P^=p,P=P>>>20|P<<12,F=F+J|0,d^=F,d=d>>>16|d<<16,a=a+d|0,J^=a,J=J>>>20|J<<12,k=k+D|0,v^=k,v=v>>>16|v<<16,l=l+v|0,D^=l,D=D>>>20|D<<12,V=V+L|0,_^=V,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,k=k+D|0,v^=k,v=v>>>24|v<<8,l=l+v|0,D^=l,D=D>>>25|D<<7,V=V+L|0,_^=V,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,F=F+J|0,d^=F,d=d>>>24|d<<8,a=a+d|0,J^=a,J=J>>>25|J<<7,z=z+P|0,m^=z,m=m>>>24|m<<8,p=p+m|0,P^=p,P=P>>>25|P<<7;Rt.writeUint32LE(z+i|0,r,0),Rt.writeUint32LE(F+n|0,r,4),Rt.writeUint32LE(k+s|0,r,8),Rt.writeUint32LE(V+o|0,r,12),Rt.writeUint32LE(L+f|0,r,16),Rt.writeUint32LE(P+c|0,r,20),Rt.writeUint32LE(J+u|0,r,24),Rt.writeUint32LE(D+b|0,r,28),Rt.writeUint32LE(l+y|0,r,32),Rt.writeUint32LE(w+S|0,r,36),Rt.writeUint32LE(p+I|0,r,40),Rt.writeUint32LE(a+M|0,r,44),Rt.writeUint32LE(d+T|0,r,48),Rt.writeUint32LE(v+O|0,r,52),Rt.writeUint32LE(_+N|0,r,56),Rt.writeUint32LE(m+B|0,r,60)}function lv(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var Kf=W(Ts=>{"use strict";Object.defineProperty(Ts,"__esModule",{value:!0});function Zx(r,e,t){return~(r-1)&e|r-1&t}Ts.select=Zx;function Qx(r,e){return(r|0)-(e|0)-1>>>31&1}Ts.lessOrEqual=Qx;function gv(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Ts.compare=gv;function eE(r,e){return r.length===0||e.length===0?!1:gv(r,e)!==0}Ts.equal=eE});var vv=W(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});var tE=Kf(),jf=Qt();wi.DIGEST_LENGTH=16;var bv=function(){function r(e){this.digestLength=wi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var c=e[12]|e[13]<<8;this._r[7]=(f>>>11|c<<5)&8065;var u=e[14]|e[15]<<8;this._r[8]=(c>>>8|u<<8)&8191,this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],c=this._h[3],u=this._h[4],b=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],O=this._r[1],N=this._r[2],B=this._r[3],z=this._r[4],F=this._r[5],k=this._r[6],V=this._r[7],L=this._r[8],P=this._r[9];i>=16;){var J=e[t+0]|e[t+1]<<8;s+=J&8191;var D=e[t+2]|e[t+3]<<8;o+=(J>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;c+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;u+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;y+=(p>>>14|a<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(a>>>11|d<<5)&8191;var v=e[t+14]|e[t+15]<<8;I+=(d>>>8|v<<8)&8191,M+=v>>>5|n;var _=0,m=_;m+=s*T,m+=o*(5*P),m+=f*(5*L),m+=c*(5*V),m+=u*(5*k),_=m>>>13,m&=8191,m+=b*(5*F),m+=y*(5*z),m+=S*(5*B),m+=I*(5*N),m+=M*(5*O),_+=m>>>13,m&=8191;var h=_;h+=s*O,h+=o*T,h+=f*(5*P),h+=c*(5*L),h+=u*(5*V),_=h>>>13,h&=8191,h+=b*(5*k),h+=y*(5*F),h+=S*(5*z),h+=I*(5*B),h+=M*(5*N),_+=h>>>13,h&=8191;var x=_;x+=s*N,x+=o*O,x+=f*T,x+=c*(5*P),x+=u*(5*L),_=x>>>13,x&=8191,x+=b*(5*V),x+=y*(5*k),x+=S*(5*F),x+=I*(5*z),x+=M*(5*B),_+=x>>>13,x&=8191;var A=_;A+=s*B,A+=o*N,A+=f*O,A+=c*T,A+=u*(5*P),_=A>>>13,A&=8191,A+=b*(5*L),A+=y*(5*V),A+=S*(5*k),A+=I*(5*F),A+=M*(5*z),_+=A>>>13,A&=8191;var g=_;g+=s*z,g+=o*B,g+=f*N,g+=c*O,g+=u*T,_=g>>>13,g&=8191,g+=b*(5*P),g+=y*(5*L),g+=S*(5*V),g+=I*(5*k),g+=M*(5*F),_+=g>>>13,g&=8191;var R=_;R+=s*F,R+=o*z,R+=f*B,R+=c*N,R+=u*O,_=R>>>13,R&=8191,R+=b*T,R+=y*(5*P),R+=S*(5*L),R+=I*(5*V),R+=M*(5*k),_+=R>>>13,R&=8191;var K=_;K+=s*k,K+=o*F,K+=f*z,K+=c*B,K+=u*N,_=K>>>13,K&=8191,K+=b*O,K+=y*T,K+=S*(5*P),K+=I*(5*L),K+=M*(5*V),_+=K>>>13,K&=8191;var E=_;E+=s*V,E+=o*k,E+=f*F,E+=c*z,E+=u*B,_=E>>>13,E&=8191,E+=b*N,E+=y*O,E+=S*T,E+=I*(5*P),E+=M*(5*L),_+=E>>>13,E&=8191;var C=_;C+=s*L,C+=o*V,C+=f*k,C+=c*F,C+=u*z,_=C>>>13,C&=8191,C+=b*B,C+=y*N,C+=S*O,C+=I*T,C+=M*(5*P),_+=C>>>13,C&=8191;var q=_;q+=s*P,q+=o*L,q+=f*V,q+=c*k,q+=u*F,_=q>>>13,q&=8191,q+=b*z,q+=y*B,q+=S*N,q+=I*O,q+=M*T,_+=q>>>13,q&=8191,_=(_<<2)+_|0,_=_+m|0,m=_&8191,_=_>>>13,h+=_,s=m,o=h,f=x,c=A,u=g,b=R,y=K,S=E,I=C,M=q,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=c,this._h[4]=u,this._h[5]=b,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});var Vf=pv(),nE=vv(),Fo=Qt(),mv=fs(),sE=Kf();_i.KEY_LENGTH=32;_i.NONCE_LENGTH=12;_i.TAG_LENGTH=16;var yv=new Uint8Array(16),oE=function(){function r(e){if(this.nonceLength=_i.NONCE_LENGTH,this.tagLength=_i.TAG_LENGTH,e.length!==_i.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);Vf.stream(this._key,s,o,4);var f=t.length+this.tagLength,c;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");c=n}else c=new Uint8Array(f);return Vf.streamXOR(this._key,s,t,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),o,c.subarray(0,c.length-this.tagLength),i),Fo.wipe(s),c},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(yv.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(yv.subarray(i.length%16));var o=new Uint8Array(8);n&&mv.writeUint64LE(n.length,o),s.update(o),mv.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),c=0;c{"use strict";Object.defineProperty(od,"__esModule",{value:!0});function aE(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}od.isSerializableHash=aE});var Ev=W(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});var ei=_v(),fE=Kf(),cE=Qt(),xv=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});var Sv=Ev(),Iv=Qt(),hE=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Sv.hmac(this._hash,i,t);this._hmac=new Sv.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});var Hf=fs(),$f=Qt();ki.DIGEST_LENGTH=32;ki.BLOCK_SIZE=64;var Av=function(){function r(){this.digestLength=ki.DIGEST_LENGTH,this.blockSize=ki.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){$f.wipe(this._buffer),$f.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(fd(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=fd(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){$f.wipe(e.state),e.buffer&&$f.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();ki.SHA256=Av;var dE=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function fd(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],c=e[3],u=e[4],b=e[5],y=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=Hf.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],O=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var N=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(O+r[I-7]|0)+(N+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&b^~u&y)|0)+(S+(dE[I]+r[I]|0)|0)|0,N=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=y,y=b,b=u,u=c+O|0,c=f,f=o,o=s,s=O+N|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=c,e[4]+=u,e[5]+=b,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function lE(r){var e=new Av;e.update(r);var t=e.digest();return e.clean(),t}ki.hash=lE});var Cv=W(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.sharedKey=rt.generateKeyPair=rt.generateKeyPairFromSeed=rt.scalarMultBase=rt.scalarMult=rt.SHARED_KEY_LENGTH=rt.SECRET_KEY_LENGTH=rt.PUBLIC_KEY_LENGTH=void 0;var pE=mo(),gE=Qt();rt.PUBLIC_KEY_LENGTH=32;rt.SECRET_KEY_LENGTH=32;rt.SHARED_KEY_LENGTH=32;function ti(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,Bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function mE(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Gf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function Jf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function xi(r,e,t){let i,n,s=0,o=0,f=0,c=0,u=0,b=0,y=0,S=0,I=0,M=0,T=0,O=0,N=0,B=0,z=0,F=0,k=0,V=0,L=0,P=0,J=0,D=0,l=0,w=0,p=0,a=0,d=0,v=0,_=0,m=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],K=t[4],E=t[5],C=t[6],q=t[7],U=t[8],j=t[9],Y=t[10],H=t[11],$=t[12],te=t[13],G=t[14],X=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,c+=i*R,u+=i*K,b+=i*E,y+=i*C,S+=i*q,I+=i*U,M+=i*j,T+=i*Y,O+=i*H,N+=i*$,B+=i*te,z+=i*G,F+=i*X,i=e[1],o+=i*x,f+=i*A,c+=i*g,u+=i*R,b+=i*K,y+=i*E,S+=i*C,I+=i*q,M+=i*U,T+=i*j,O+=i*Y,N+=i*H,B+=i*$,z+=i*te,F+=i*G,k+=i*X,i=e[2],f+=i*x,c+=i*A,u+=i*g,b+=i*R,y+=i*K,S+=i*E,I+=i*C,M+=i*q,T+=i*U,O+=i*j,N+=i*Y,B+=i*H,z+=i*$,F+=i*te,k+=i*G,V+=i*X,i=e[3],c+=i*x,u+=i*A,b+=i*g,y+=i*R,S+=i*K,I+=i*E,M+=i*C,T+=i*q,O+=i*U,N+=i*j,B+=i*Y,z+=i*H,F+=i*$,k+=i*te,V+=i*G,L+=i*X,i=e[4],u+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*K,M+=i*E,T+=i*C,O+=i*q,N+=i*U,B+=i*j,z+=i*Y,F+=i*H,k+=i*$,V+=i*te,L+=i*G,P+=i*X,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*K,T+=i*E,O+=i*C,N+=i*q,B+=i*U,z+=i*j,F+=i*Y,k+=i*H,V+=i*$,L+=i*te,P+=i*G,J+=i*X,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*K,O+=i*E,N+=i*C,B+=i*q,z+=i*U,F+=i*j,k+=i*Y,V+=i*H,L+=i*$,P+=i*te,J+=i*G,D+=i*X,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*K,N+=i*E,B+=i*C,z+=i*q,F+=i*U,k+=i*j,V+=i*Y,L+=i*H,P+=i*$,J+=i*te,D+=i*G,l+=i*X,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,N+=i*K,B+=i*E,z+=i*C,F+=i*q,k+=i*U,V+=i*j,L+=i*Y,P+=i*H,J+=i*$,D+=i*te,l+=i*G,w+=i*X,i=e[9],M+=i*x,T+=i*A,O+=i*g,N+=i*R,B+=i*K,z+=i*E,F+=i*C,k+=i*q,V+=i*U,L+=i*j,P+=i*Y,J+=i*H,D+=i*$,l+=i*te,w+=i*G,p+=i*X,i=e[10],T+=i*x,O+=i*A,N+=i*g,B+=i*R,z+=i*K,F+=i*E,k+=i*C,V+=i*q,L+=i*U,P+=i*j,J+=i*Y,D+=i*H,l+=i*$,w+=i*te,p+=i*G,a+=i*X,i=e[11],O+=i*x,N+=i*A,B+=i*g,z+=i*R,F+=i*K,k+=i*E,V+=i*C,L+=i*q,P+=i*U,J+=i*j,D+=i*Y,l+=i*H,w+=i*$,p+=i*te,a+=i*G,d+=i*X,i=e[12],N+=i*x,B+=i*A,z+=i*g,F+=i*R,k+=i*K,V+=i*E,L+=i*C,P+=i*q,J+=i*U,D+=i*j,l+=i*Y,w+=i*H,p+=i*$,a+=i*te,d+=i*G,v+=i*X,i=e[13],B+=i*x,z+=i*A,F+=i*g,k+=i*R,V+=i*K,L+=i*E,P+=i*C,J+=i*q,D+=i*U,l+=i*j,w+=i*Y,p+=i*H,a+=i*$,d+=i*te,v+=i*G,_+=i*X,i=e[14],z+=i*x,F+=i*A,k+=i*g,V+=i*R,L+=i*K,P+=i*E,J+=i*C,D+=i*q,l+=i*U,w+=i*j,p+=i*Y,a+=i*H,d+=i*$,v+=i*te,_+=i*G,m+=i*X,i=e[15],F+=i*x,k+=i*A,V+=i*g,L+=i*R,P+=i*K,J+=i*E,D+=i*C,l+=i*q,w+=i*U,p+=i*j,a+=i*Y,d+=i*H,v+=i*$,_+=i*te,m+=i*G,h+=i*X,s+=38*k,o+=38*V,f+=38*L,c+=38*P,u+=38*J,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*v,N+=38*_,B+=38*m,z+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=F+n+65535,n=Math.floor(i/65536),F=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=c,r[4]=u,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=N,r[13]=B,r[14]=z,r[15]=F}function zo(r,e){xi(r,e,e)}function yE(r,e){let t=ti();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)zo(t,t),i!==2&&i!==4&&xi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function ud(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=ti(),s=ti(),o=ti(),f=ti(),c=ti(),u=ti();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,mE(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;Bo(n,s,M),Bo(o,f,M),Gf(c,n,o),Jf(n,n,o),Gf(o,s,f),Jf(s,s,f),zo(f,c),zo(u,n),xi(n,o,n),xi(o,s,c),Gf(c,n,o),Jf(n,n,o),zo(s,n),Jf(o,f,u),xi(n,o,bE),Gf(n,n,f),xi(o,o,n),xi(n,f,u),xi(f,s,i),zo(s,c),Bo(n,s,M),Bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),y=i.subarray(16);yE(b,b),xi(y,y,b);let S=new Uint8Array(32);return vE(S,y),S}rt.scalarMult=ud;function Dv(r){return ud(r,Tv)}rt.scalarMultBase=Dv;function Nv(r){if(r.length!==rt.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${rt.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:Dv(e),secretKey:e}}rt.generateKeyPairFromSeed=Nv;function wE(r){let e=(0,pE.randomBytes)(32,r),t=Nv(e);return(0,gE.wipe)(e),t}rt.generateKeyPair=wE;function _E(r,e,t=!1){if(r.length!==rt.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==rt.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=ud(r,e);if(t){let n=0;for(let s=0;s{});var Ov=Z(()=>{});var Lv=Z(()=>{pf()});var hd=Z(()=>{Pv();Zu();Ov();Ih();Sh();Lv()});var qv=W((zC,xE)=>{xE.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var ri=W((Fv,dd)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Lh().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)v=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[d]|=v<<_&67108863,this.words[d+1]=v>>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);else if(p==="le")for(a=0,d=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(d-=18,v+=1,this.words[v]|=_>>>26):d+=8;else{var m=l.length-w;for(a=m%2===0?w+1:w;a=18?(d-=18,v+=1,this.words[v]|=_>>>26):d+=8}this.strip()};function c(D,l,w,p){for(var a=0,d=Math.min(D.length,w),v=l;v=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=w)a++;a--,d=d/w|0;for(var v=l.length-p,_=v%a,m=Math.min(v,v-_)+p,h=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,d=0,v=0;v>>24-a&16777215,d!==0||v!==this.length-1?p=u[6-m.length]+m+p:p=m+p,a+=2,a>=26&&(a-=26,v--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=b[l],x=y[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=u[h-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),d=p||Math.max(1,a);t(a<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var v=w==="le",_=new l(d),m,h,x=this.clone();if(v){for(h=0;!x.isZero();h++)m=x.andln(255),x.iushrn(8),_[h]=m;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var d=0,v=0;v>>26;for(;d!==0&&v>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;vl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;p>0?(a=this,d=l):(a=l,d=this);for(var v=0,_=0;_>26,this.words[_]=w&67108863;for(;v!==0&&_>26,this.words[_]=w&67108863;if(v===0&&_>>26,A=m&67108863,g=Math.min(h,l.length-1),R=Math.max(0,h-D.length+1);R<=g;R++){var K=h-R|0;a=D.words[K]|0,d=l.words[R]|0,v=a*d+A,x+=v/67108864|0,A=v&67108863}w.words[h]=A|0,m=x|0}return m!==0?w.words[h]=m|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,d=w.words,v=p.words,_=0,m,h,x,A=a[0]|0,g=A&8191,R=A>>>13,K=a[1]|0,E=K&8191,C=K>>>13,q=a[2]|0,U=q&8191,j=q>>>13,Y=a[3]|0,H=Y&8191,$=Y>>>13,te=a[4]|0,G=te&8191,X=te>>>13,Rr=a[5]|0,ne=Rr&8191,se=Rr>>>13,Tr=a[6]|0,oe=Tr&8191,ae=Tr>>>13,Dr=a[7]|0,fe=Dr&8191,ce=Dr>>>13,Nr=a[8]|0,ue=Nr&8191,he=Nr>>>13,Cr=a[9]|0,de=Cr&8191,le=Cr>>>13,Pr=d[0]|0,pe=Pr&8191,ge=Pr>>>13,Or=d[1]|0,be=Or&8191,ve=Or>>>13,Lr=d[2]|0,me=Lr&8191,ye=Lr>>>13,qr=d[3]|0,we=qr&8191,_e=qr>>>13,Fr=d[4]|0,xe=Fr&8191,Ee=Fr>>>13,Ur=d[5]|0,Se=Ur&8191,Ie=Ur>>>13,Br=d[6]|0,Me=Br&8191,Ae=Br>>>13,zr=d[7]|0,Re=zr&8191,Te=zr>>>13,kr=d[8]|0,De=kr&8191,Ne=kr>>>13,Kr=d[9]|0,Ce=Kr&8191,Pe=Kr>>>13;p.negative=l.negative^w.negative,p.length=19,m=Math.imul(g,pe),h=Math.imul(g,ge),h=h+Math.imul(R,pe)|0,x=Math.imul(R,ge);var ur=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ur>>>26)|0,ur&=67108863,m=Math.imul(E,pe),h=Math.imul(E,ge),h=h+Math.imul(C,pe)|0,x=Math.imul(C,ge),m=m+Math.imul(g,be)|0,h=h+Math.imul(g,ve)|0,h=h+Math.imul(R,be)|0,x=x+Math.imul(R,ve)|0;var Ke=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,m=Math.imul(U,pe),h=Math.imul(U,ge),h=h+Math.imul(j,pe)|0,x=Math.imul(j,ge),m=m+Math.imul(E,be)|0,h=h+Math.imul(E,ve)|0,h=h+Math.imul(C,be)|0,x=x+Math.imul(C,ve)|0,m=m+Math.imul(g,me)|0,h=h+Math.imul(g,ye)|0,h=h+Math.imul(R,me)|0,x=x+Math.imul(R,ye)|0;var je=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(je>>>26)|0,je&=67108863,m=Math.imul(H,pe),h=Math.imul(H,ge),h=h+Math.imul($,pe)|0,x=Math.imul($,ge),m=m+Math.imul(U,be)|0,h=h+Math.imul(U,ve)|0,h=h+Math.imul(j,be)|0,x=x+Math.imul(j,ve)|0,m=m+Math.imul(E,me)|0,h=h+Math.imul(E,ye)|0,h=h+Math.imul(C,me)|0,x=x+Math.imul(C,ye)|0,m=m+Math.imul(g,we)|0,h=h+Math.imul(g,_e)|0,h=h+Math.imul(R,we)|0,x=x+Math.imul(R,_e)|0;var Gt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,m=Math.imul(G,pe),h=Math.imul(G,ge),h=h+Math.imul(X,pe)|0,x=Math.imul(X,ge),m=m+Math.imul(H,be)|0,h=h+Math.imul(H,ve)|0,h=h+Math.imul($,be)|0,x=x+Math.imul($,ve)|0,m=m+Math.imul(U,me)|0,h=h+Math.imul(U,ye)|0,h=h+Math.imul(j,me)|0,x=x+Math.imul(j,ye)|0,m=m+Math.imul(E,we)|0,h=h+Math.imul(E,_e)|0,h=h+Math.imul(C,we)|0,x=x+Math.imul(C,_e)|0,m=m+Math.imul(g,xe)|0,h=h+Math.imul(g,Ee)|0,h=h+Math.imul(R,xe)|0,x=x+Math.imul(R,Ee)|0;var Jt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Jt>>>26)|0,Jt&=67108863,m=Math.imul(ne,pe),h=Math.imul(ne,ge),h=h+Math.imul(se,pe)|0,x=Math.imul(se,ge),m=m+Math.imul(G,be)|0,h=h+Math.imul(G,ve)|0,h=h+Math.imul(X,be)|0,x=x+Math.imul(X,ve)|0,m=m+Math.imul(H,me)|0,h=h+Math.imul(H,ye)|0,h=h+Math.imul($,me)|0,x=x+Math.imul($,ye)|0,m=m+Math.imul(U,we)|0,h=h+Math.imul(U,_e)|0,h=h+Math.imul(j,we)|0,x=x+Math.imul(j,_e)|0,m=m+Math.imul(E,xe)|0,h=h+Math.imul(E,Ee)|0,h=h+Math.imul(C,xe)|0,x=x+Math.imul(C,Ee)|0,m=m+Math.imul(g,Se)|0,h=h+Math.imul(g,Ie)|0,h=h+Math.imul(R,Se)|0,x=x+Math.imul(R,Ie)|0;var Wt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Wt>>>26)|0,Wt&=67108863,m=Math.imul(oe,pe),h=Math.imul(oe,ge),h=h+Math.imul(ae,pe)|0,x=Math.imul(ae,ge),m=m+Math.imul(ne,be)|0,h=h+Math.imul(ne,ve)|0,h=h+Math.imul(se,be)|0,x=x+Math.imul(se,ve)|0,m=m+Math.imul(G,me)|0,h=h+Math.imul(G,ye)|0,h=h+Math.imul(X,me)|0,x=x+Math.imul(X,ye)|0,m=m+Math.imul(H,we)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul($,we)|0,x=x+Math.imul($,_e)|0,m=m+Math.imul(U,xe)|0,h=h+Math.imul(U,Ee)|0,h=h+Math.imul(j,xe)|0,x=x+Math.imul(j,Ee)|0,m=m+Math.imul(E,Se)|0,h=h+Math.imul(E,Ie)|0,h=h+Math.imul(C,Se)|0,x=x+Math.imul(C,Ie)|0,m=m+Math.imul(g,Me)|0,h=h+Math.imul(g,Ae)|0,h=h+Math.imul(R,Me)|0,x=x+Math.imul(R,Ae)|0;var Yt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Yt>>>26)|0,Yt&=67108863,m=Math.imul(fe,pe),h=Math.imul(fe,ge),h=h+Math.imul(ce,pe)|0,x=Math.imul(ce,ge),m=m+Math.imul(oe,be)|0,h=h+Math.imul(oe,ve)|0,h=h+Math.imul(ae,be)|0,x=x+Math.imul(ae,ve)|0,m=m+Math.imul(ne,me)|0,h=h+Math.imul(ne,ye)|0,h=h+Math.imul(se,me)|0,x=x+Math.imul(se,ye)|0,m=m+Math.imul(G,we)|0,h=h+Math.imul(G,_e)|0,h=h+Math.imul(X,we)|0,x=x+Math.imul(X,_e)|0,m=m+Math.imul(H,xe)|0,h=h+Math.imul(H,Ee)|0,h=h+Math.imul($,xe)|0,x=x+Math.imul($,Ee)|0,m=m+Math.imul(U,Se)|0,h=h+Math.imul(U,Ie)|0,h=h+Math.imul(j,Se)|0,x=x+Math.imul(j,Ie)|0,m=m+Math.imul(E,Me)|0,h=h+Math.imul(E,Ae)|0,h=h+Math.imul(C,Me)|0,x=x+Math.imul(C,Ae)|0,m=m+Math.imul(g,Re)|0,h=h+Math.imul(g,Te)|0,h=h+Math.imul(R,Re)|0,x=x+Math.imul(R,Te)|0;var Xt=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Xt>>>26)|0,Xt&=67108863,m=Math.imul(ue,pe),h=Math.imul(ue,ge),h=h+Math.imul(he,pe)|0,x=Math.imul(he,ge),m=m+Math.imul(fe,be)|0,h=h+Math.imul(fe,ve)|0,h=h+Math.imul(ce,be)|0,x=x+Math.imul(ce,ve)|0,m=m+Math.imul(oe,me)|0,h=h+Math.imul(oe,ye)|0,h=h+Math.imul(ae,me)|0,x=x+Math.imul(ae,ye)|0,m=m+Math.imul(ne,we)|0,h=h+Math.imul(ne,_e)|0,h=h+Math.imul(se,we)|0,x=x+Math.imul(se,_e)|0,m=m+Math.imul(G,xe)|0,h=h+Math.imul(G,Ee)|0,h=h+Math.imul(X,xe)|0,x=x+Math.imul(X,Ee)|0,m=m+Math.imul(H,Se)|0,h=h+Math.imul(H,Ie)|0,h=h+Math.imul($,Se)|0,x=x+Math.imul($,Ie)|0,m=m+Math.imul(U,Me)|0,h=h+Math.imul(U,Ae)|0,h=h+Math.imul(j,Me)|0,x=x+Math.imul(j,Ae)|0,m=m+Math.imul(E,Re)|0,h=h+Math.imul(E,Te)|0,h=h+Math.imul(C,Re)|0,x=x+Math.imul(C,Te)|0,m=m+Math.imul(g,De)|0,h=h+Math.imul(g,Ne)|0,h=h+Math.imul(R,De)|0,x=x+Math.imul(R,Ne)|0;var un=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(un>>>26)|0,un&=67108863,m=Math.imul(de,pe),h=Math.imul(de,ge),h=h+Math.imul(le,pe)|0,x=Math.imul(le,ge),m=m+Math.imul(ue,be)|0,h=h+Math.imul(ue,ve)|0,h=h+Math.imul(he,be)|0,x=x+Math.imul(he,ve)|0,m=m+Math.imul(fe,me)|0,h=h+Math.imul(fe,ye)|0,h=h+Math.imul(ce,me)|0,x=x+Math.imul(ce,ye)|0,m=m+Math.imul(oe,we)|0,h=h+Math.imul(oe,_e)|0,h=h+Math.imul(ae,we)|0,x=x+Math.imul(ae,_e)|0,m=m+Math.imul(ne,xe)|0,h=h+Math.imul(ne,Ee)|0,h=h+Math.imul(se,xe)|0,x=x+Math.imul(se,Ee)|0,m=m+Math.imul(G,Se)|0,h=h+Math.imul(G,Ie)|0,h=h+Math.imul(X,Se)|0,x=x+Math.imul(X,Ie)|0,m=m+Math.imul(H,Me)|0,h=h+Math.imul(H,Ae)|0,h=h+Math.imul($,Me)|0,x=x+Math.imul($,Ae)|0,m=m+Math.imul(U,Re)|0,h=h+Math.imul(U,Te)|0,h=h+Math.imul(j,Re)|0,x=x+Math.imul(j,Te)|0,m=m+Math.imul(E,De)|0,h=h+Math.imul(E,Ne)|0,h=h+Math.imul(C,De)|0,x=x+Math.imul(C,Ne)|0,m=m+Math.imul(g,Ce)|0,h=h+Math.imul(g,Pe)|0,h=h+Math.imul(R,Ce)|0,x=x+Math.imul(R,Pe)|0;var hn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(hn>>>26)|0,hn&=67108863,m=Math.imul(de,be),h=Math.imul(de,ve),h=h+Math.imul(le,be)|0,x=Math.imul(le,ve),m=m+Math.imul(ue,me)|0,h=h+Math.imul(ue,ye)|0,h=h+Math.imul(he,me)|0,x=x+Math.imul(he,ye)|0,m=m+Math.imul(fe,we)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(ce,we)|0,x=x+Math.imul(ce,_e)|0,m=m+Math.imul(oe,xe)|0,h=h+Math.imul(oe,Ee)|0,h=h+Math.imul(ae,xe)|0,x=x+Math.imul(ae,Ee)|0,m=m+Math.imul(ne,Se)|0,h=h+Math.imul(ne,Ie)|0,h=h+Math.imul(se,Se)|0,x=x+Math.imul(se,Ie)|0,m=m+Math.imul(G,Me)|0,h=h+Math.imul(G,Ae)|0,h=h+Math.imul(X,Me)|0,x=x+Math.imul(X,Ae)|0,m=m+Math.imul(H,Re)|0,h=h+Math.imul(H,Te)|0,h=h+Math.imul($,Re)|0,x=x+Math.imul($,Te)|0,m=m+Math.imul(U,De)|0,h=h+Math.imul(U,Ne)|0,h=h+Math.imul(j,De)|0,x=x+Math.imul(j,Ne)|0,m=m+Math.imul(E,Ce)|0,h=h+Math.imul(E,Pe)|0,h=h+Math.imul(C,Ce)|0,x=x+Math.imul(C,Pe)|0;var dn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(dn>>>26)|0,dn&=67108863,m=Math.imul(de,me),h=Math.imul(de,ye),h=h+Math.imul(le,me)|0,x=Math.imul(le,ye),m=m+Math.imul(ue,we)|0,h=h+Math.imul(ue,_e)|0,h=h+Math.imul(he,we)|0,x=x+Math.imul(he,_e)|0,m=m+Math.imul(fe,xe)|0,h=h+Math.imul(fe,Ee)|0,h=h+Math.imul(ce,xe)|0,x=x+Math.imul(ce,Ee)|0,m=m+Math.imul(oe,Se)|0,h=h+Math.imul(oe,Ie)|0,h=h+Math.imul(ae,Se)|0,x=x+Math.imul(ae,Ie)|0,m=m+Math.imul(ne,Me)|0,h=h+Math.imul(ne,Ae)|0,h=h+Math.imul(se,Me)|0,x=x+Math.imul(se,Ae)|0,m=m+Math.imul(G,Re)|0,h=h+Math.imul(G,Te)|0,h=h+Math.imul(X,Re)|0,x=x+Math.imul(X,Te)|0,m=m+Math.imul(H,De)|0,h=h+Math.imul(H,Ne)|0,h=h+Math.imul($,De)|0,x=x+Math.imul($,Ne)|0,m=m+Math.imul(U,Ce)|0,h=h+Math.imul(U,Pe)|0,h=h+Math.imul(j,Ce)|0,x=x+Math.imul(j,Pe)|0;var ln=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ln>>>26)|0,ln&=67108863,m=Math.imul(de,we),h=Math.imul(de,_e),h=h+Math.imul(le,we)|0,x=Math.imul(le,_e),m=m+Math.imul(ue,xe)|0,h=h+Math.imul(ue,Ee)|0,h=h+Math.imul(he,xe)|0,x=x+Math.imul(he,Ee)|0,m=m+Math.imul(fe,Se)|0,h=h+Math.imul(fe,Ie)|0,h=h+Math.imul(ce,Se)|0,x=x+Math.imul(ce,Ie)|0,m=m+Math.imul(oe,Me)|0,h=h+Math.imul(oe,Ae)|0,h=h+Math.imul(ae,Me)|0,x=x+Math.imul(ae,Ae)|0,m=m+Math.imul(ne,Re)|0,h=h+Math.imul(ne,Te)|0,h=h+Math.imul(se,Re)|0,x=x+Math.imul(se,Te)|0,m=m+Math.imul(G,De)|0,h=h+Math.imul(G,Ne)|0,h=h+Math.imul(X,De)|0,x=x+Math.imul(X,Ne)|0,m=m+Math.imul(H,Ce)|0,h=h+Math.imul(H,Pe)|0,h=h+Math.imul($,Ce)|0,x=x+Math.imul($,Pe)|0;var pn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(pn>>>26)|0,pn&=67108863,m=Math.imul(de,xe),h=Math.imul(de,Ee),h=h+Math.imul(le,xe)|0,x=Math.imul(le,Ee),m=m+Math.imul(ue,Se)|0,h=h+Math.imul(ue,Ie)|0,h=h+Math.imul(he,Se)|0,x=x+Math.imul(he,Ie)|0,m=m+Math.imul(fe,Me)|0,h=h+Math.imul(fe,Ae)|0,h=h+Math.imul(ce,Me)|0,x=x+Math.imul(ce,Ae)|0,m=m+Math.imul(oe,Re)|0,h=h+Math.imul(oe,Te)|0,h=h+Math.imul(ae,Re)|0,x=x+Math.imul(ae,Te)|0,m=m+Math.imul(ne,De)|0,h=h+Math.imul(ne,Ne)|0,h=h+Math.imul(se,De)|0,x=x+Math.imul(se,Ne)|0,m=m+Math.imul(G,Ce)|0,h=h+Math.imul(G,Pe)|0,h=h+Math.imul(X,Ce)|0,x=x+Math.imul(X,Pe)|0;var gn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(gn>>>26)|0,gn&=67108863,m=Math.imul(de,Se),h=Math.imul(de,Ie),h=h+Math.imul(le,Se)|0,x=Math.imul(le,Ie),m=m+Math.imul(ue,Me)|0,h=h+Math.imul(ue,Ae)|0,h=h+Math.imul(he,Me)|0,x=x+Math.imul(he,Ae)|0,m=m+Math.imul(fe,Re)|0,h=h+Math.imul(fe,Te)|0,h=h+Math.imul(ce,Re)|0,x=x+Math.imul(ce,Te)|0,m=m+Math.imul(oe,De)|0,h=h+Math.imul(oe,Ne)|0,h=h+Math.imul(ae,De)|0,x=x+Math.imul(ae,Ne)|0,m=m+Math.imul(ne,Ce)|0,h=h+Math.imul(ne,Pe)|0,h=h+Math.imul(se,Ce)|0,x=x+Math.imul(se,Pe)|0;var bn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(bn>>>26)|0,bn&=67108863,m=Math.imul(de,Me),h=Math.imul(de,Ae),h=h+Math.imul(le,Me)|0,x=Math.imul(le,Ae),m=m+Math.imul(ue,Re)|0,h=h+Math.imul(ue,Te)|0,h=h+Math.imul(he,Re)|0,x=x+Math.imul(he,Te)|0,m=m+Math.imul(fe,De)|0,h=h+Math.imul(fe,Ne)|0,h=h+Math.imul(ce,De)|0,x=x+Math.imul(ce,Ne)|0,m=m+Math.imul(oe,Ce)|0,h=h+Math.imul(oe,Pe)|0,h=h+Math.imul(ae,Ce)|0,x=x+Math.imul(ae,Pe)|0;var vn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(vn>>>26)|0,vn&=67108863,m=Math.imul(de,Re),h=Math.imul(de,Te),h=h+Math.imul(le,Re)|0,x=Math.imul(le,Te),m=m+Math.imul(ue,De)|0,h=h+Math.imul(ue,Ne)|0,h=h+Math.imul(he,De)|0,x=x+Math.imul(he,Ne)|0,m=m+Math.imul(fe,Ce)|0,h=h+Math.imul(fe,Pe)|0,h=h+Math.imul(ce,Ce)|0,x=x+Math.imul(ce,Pe)|0;var mn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(mn>>>26)|0,mn&=67108863,m=Math.imul(de,De),h=Math.imul(de,Ne),h=h+Math.imul(le,De)|0,x=Math.imul(le,Ne),m=m+Math.imul(ue,Ce)|0,h=h+Math.imul(ue,Pe)|0,h=h+Math.imul(he,Ce)|0,x=x+Math.imul(he,Pe)|0;var yn=(_+m|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(yn>>>26)|0,yn&=67108863,m=Math.imul(de,Ce),h=Math.imul(de,Pe),h=h+Math.imul(le,Ce)|0,x=Math.imul(le,Pe);var wn=(_+m|0)+((h&8191)<<13)|0;return _=(x+(h>>>13)|0)+(wn>>>26)|0,wn&=67108863,v[0]=ur,v[1]=Ke,v[2]=je,v[3]=Gt,v[4]=Jt,v[5]=Wt,v[6]=Yt,v[7]=Xt,v[8]=un,v[9]=hn,v[10]=dn,v[11]=ln,v[12]=pn,v[13]=gn,v[14]=bn,v[15]=vn,v[16]=mn,v[17]=yn,v[18]=wn,_!==0&&(v[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,d=0;d>>26)|0,a+=v>>>26,v&=67108863}w.words[d]=_,p=v,v=a}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(D,l,w){var p=new N;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=O(this,l,w),p};function N(D,l){this.x=D,this.y=l}N.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},N.prototype.permute=function(l,w,p,a,d,v){for(var _=0;_>>1)d++;return 1<>>13,p[2*v+1]=d&8191,d=d>>>13;for(v=2*w;v>=26,w+=a/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,d;if(w!==0){var v=0;for(d=0;d>>26-w}v&&(this.words[d]=v,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var a;w?a=(w-w%26)/26:a=0;var d=l%26,v=Math.min((l-d)/26,this.length),_=67108863^67108863>>>d<v)for(this.length-=v,h=0;h=0&&(x!==0||h>=a);h--){var A=this.words[h]|0;this.words[h]=x<<26-d|A>>>d,x=A&_}return m&&x!==0&&(m.words[m.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(m/67108864|0),this.words[d+p]=v&67108863}for(;d>26,this.words[d+p]=v&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,d=0;d>26,this.words[d]=v&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),d=l,v=d.words[d.length-1]|0,_=this._countBits(v);p=26-_,p!==0&&(d=d.ushln(p),a.iushln(p),v=d.words[d.length-1]|0);var m=a.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=m+1,h.words=new Array(h.length);for(var x=0;x=0;g--){var R=(a.words[d.length+g]|0)*67108864+(a.words[d.length+g-1]|0);for(R=Math.min(R/v|0,67108863),a._ishlnsubmul(d,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(d,1,g),a.isZero()||(a.negative^=1);h&&(h.words[g]=R)}return h&&h.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:h||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,d,v;return this.negative!==0&&l.negative===0?(v=this.neg().divmod(l,w),w!=="mod"&&(a=v.div.neg()),w!=="div"&&(d=v.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:a,mod:d}):this.negative===0&&l.negative!==0?(v=this.divmod(l.neg(),w),w!=="mod"&&(a=v.div.neg()),{div:a,mod:v.mod}):this.negative&l.negative?(v=this.neg().divmod(l.neg(),w),w!=="div"&&(d=v.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:v.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),d=l.andln(1),v=p.cmp(a);return v<0||d===1&&v===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),v=new n(0),_=new n(1),m=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++m;for(var h=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(h),d.isub(x)),a.iushrn(1),d.iushrn(1);for(var R=0,K=1;!(p.words[0]&K)&&R<26;++R,K<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(v.isOdd()||_.isOdd())&&(v.iadd(h),_.isub(x)),v.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(v),d.isub(_)):(p.isub(w),v.isub(a),_.isub(d))}return{a:v,b:_,gcd:p.iushln(m)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),v=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,m=1;!(w.words[0]&m)&&_<26;++_,m<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(v),a.iushrn(1);for(var h=0,x=1;!(p.words[0]&x)&&h<26;++h,x<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(v),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(d)):(p.isub(w),d.isub(a))}var A;return w.cmpn(1)===0?A=a:A=d,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var v=w;w=p,p=v}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[v]=_}return d!==0&&(this.words[v]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,d=l.words[p]|0;if(a!==d){ad&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new P(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var B={k256:null,p224:null,p192:null,p25519:null};function z(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}z.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},z.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},z.prototype.split=function(l,w){l.iushrn(this.n,0,w)},z.prototype.imulK=function(l){return l.imul(this.k)};function F(){z.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(F,z),F.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),d=0;d>>22,v=_}v>>>=22,l.words[d-10]=v,v===0&&l.length>10?l.length-=10:l.length-=9},F.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(B[l])return B[l];var w;if(l==="k256")w=new F;else if(l==="p224")w=new k;else if(l==="p192")w=new V;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return B[l]=w,w};function P(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}P.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},P.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},P.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},P.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},P.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},P.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},P.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},P.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},P.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},P.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},P.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},P.prototype.isqr=function(l){return this.imul(l,l.clone())},P.prototype.sqr=function(l){return this.mul(l,l)},P.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);t(!a.isZero());var v=new n(1).toRed(this),_=v.redNeg(),m=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,m).cmp(_)!==0;)h.redIAdd(_);for(var x=this.pow(h,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=d;g.cmp(v)!==0;){for(var K=g,E=0;K.cmp(v)!==0;E++)K=K.redSqr();t(E=0;d--){for(var x=w.words[d],A=h-1;A>=0;A--){var g=x>>A&1;if(v!==a[0]&&(v=this.sqr(v)),g===0&&_===0){m=0;continue}_<<=1,_|=g,m++,!(m!==p&&(d!==0||A!==0))&&(v=this.mul(v,a[_]),m=0,_=0)}h=26}return v},P.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},P.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new J(l)};function J(D){P.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(J,P),J.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},J.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},J.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),v=d;return d.cmp(this.m)>=0?v=d.isub(this.m):d.cmpn(0)<0&&(v=d.iadd(this.m)),v._forceRed(this)},J.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),v=d;return d.cmp(this.m)>=0?v=d.isub(this.m):d.cmpn(0)<0&&(v=d.iadd(this.m)),v._forceRed(this)},J.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof dd>"u"||dd,Fv)});var ld=W(zv=>{"use strict";var Wf=zv;function EE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}Wf.toArray=EE;function Uv(r){return r.length===1?"0"+r:r}Wf.zero2=Uv;function Bv(r){for(var e="",t=0;t{"use strict";var yr=kv,SE=ri(),IE=Fi(),Yf=ld();yr.assert=IE;yr.toArray=Yf.toArray;yr.zero2=Yf.zero2;yr.toHex=Yf.toHex;yr.encode=Yf.encode;function ME(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-c:f=c,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}yr.getNAF=ME;function AE(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var c;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?c=-o:c=o):c=0,t[0].push(c);var u;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?u=-f:u=f):u=0,t[1].push(u),2*i===c+1&&(i=1-i),2*n===u+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}yr.getJSF=AE;function RE(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}yr.cachedProperty=RE;function TE(r){return typeof r=="string"?yr.toArray(r,"hex"):r}yr.parseBytes=TE;function DE(r){return new SE(r,"hex","le")}yr.intFromLE=DE});var vd=W((jC,bd)=>{var pd;bd.exports=function(e){return pd||(pd=new Ki(null)),pd.generate(e)};function Ki(r){this.rand=r}bd.exports.Rand=Ki;Ki.prototype.generate=function(e){return this._rand(e)};Ki.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var On=ri(),ko=jt(),Xf=ko.getNAF,NE=ko.getJSF,Zf=ko.assert;function ji(r,e){this.type=r,this.p=new On(e.p,16),this.red=e.prime?On.red(e.prime):On.mont(this.p),this.zero=new On(0).toRed(this.red),this.one=new On(1).toRed(this.red),this.two=new On(2).toRed(this.red),this.n=e.n&&new On(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Kv.exports=ji;ji.prototype.point=function(){throw new Error("Not implemented")};ji.prototype.validate=function(){throw new Error("Not implemented")};ji.prototype._fixedNafMul=function(e,t){Zf(e.precomputed);var i=e._getDoubles(),n=Xf(t,1,this._bitLength),s=(1<=f;u--)c=(c<<1)+n[u];o.push(c)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;c--){for(var u=0;c>=0&&o[c]===0;c--)u++;if(c>=0&&u++,f=f.dblp(u),c<0)break;var b=o[c];Zf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};ji.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,c=this._wnafT3,u=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){c[M]=Xf(i[M],o[M],this._bitLength),c[T]=Xf(i[T],o[T],this._bitLength),u=Math.max(c[M].length,u),u=Math.max(c[T].length,u);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],B=NE(i[M],i[T]);for(u=Math.max(B[0].length,u),c[M]=new Array(u),c[T]=new Array(u),y=0;y=0;b--){for(var L=0;b>=0;){var P=!0;for(y=0;y=0&&L++,k=k.dblp(L),b<0)break;for(y=0;y0?S=f[y][J-1>>1]:J<0&&(S=f[y][-J-1>>1].neg()),S.type==="affine"?k=k.mixedAdd(S):k=k.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};ir.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var CE=jt(),it=ri(),md=Po(),Ds=Ko(),PE=CE.assert;function nr(r){Ds.call(this,"short",r),this.a=new it(r.a,16).toRed(this.red),this.b=new it(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}md(nr,Ds);jv.exports=nr;nr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new it(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new it(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],PE(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new it(f.a,16),b:new it(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};nr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:it.mont(e),i=new it(2).toRed(t).redInvm(),n=i.redNeg(),s=new it(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};nr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new it(1),o=new it(0),f=new it(0),c=new it(1),u,b,y,S,I,M,T,O=0,N,B;i.cmpn(0)!==0;){var z=n.div(i);N=n.sub(z.mul(i)),B=f.sub(z.mul(s));var F=c.sub(z.mul(o));if(!y&&N.cmp(t)<0)u=T.neg(),b=s,y=N.neg(),S=B;else if(y&&++O===2)break;T=N,n=i,i=N,f=s,s=B,c=o,o=F}I=N.neg(),M=B;var k=y.sqr().add(S.sqr()),V=I.sqr().add(M.sqr());return V.cmp(k)>=0&&(I=u,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};nr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),c=o.mul(n.a),u=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(c),S=u.add(b).neg();return{k1:y,k2:S}};nr.prototype.pointFromX=function(e,t){e=new it(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};nr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};nr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};lt.prototype.isInfinity=function(){return this.inf};lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};lt.prototype.getX=function(){return this.x.fromRed()};lt.prototype.getY=function(){return this.y.fromRed()};lt.prototype.mul=function(e){return e=new it(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};lt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};lt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};lt.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function _t(r,e,t,i){Ds.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new it(0)):(this.x=new it(e,16),this.y=new it(t,16),this.z=new it(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}md(_t,Ds.BasePoint);nr.prototype.jpoint=function(e,t,i){return new _t(this,e,t,i)};_t.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};_t.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};_t.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),c=n.redSub(s),u=o.redSub(f);if(c.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=c.redSqr(),y=b.redMul(c),S=n.redMul(b),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),M=u.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(c);return this.curve.jpoint(I,M,T)};_t.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),c=s.redSub(o);if(f.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=f.redSqr(),b=u.redMul(f),y=i.redMul(u),S=c.redSqr().redIAdd(b).redISub(y).redISub(y),I=c.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};_t.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};_t.prototype.inspect=function(){return this.isInfinity()?"":""};_t.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Gv=W((HC,Hv)=>{"use strict";var Ns=ri(),$v=Po(),Qf=Ko(),OE=jt();function Cs(r){Qf.call(this,"mont",r),this.a=new Ns(r.a,16).toRed(this.red),this.b=new Ns(r.b,16).toRed(this.red),this.i4=new Ns(4).toRed(this.red).redInvm(),this.two=new Ns(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}$v(Cs,Qf);Hv.exports=Cs;Cs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function pt(r,e,t){Qf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Ns(e,16),this.z=new Ns(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}$v(pt,Qf.BasePoint);Cs.prototype.decodePoint=function(e,t){return this.point(OE.toArray(e,t),1)};Cs.prototype.point=function(e,t){return new pt(this,e,t)};Cs.prototype.pointFromJSON=function(e){return pt.fromJSON(this,e)};pt.prototype.precompute=function(){};pt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};pt.fromJSON=function(e,t){return new pt(e,t[0],t[1]||e.one)};pt.prototype.inspect=function(){return this.isInfinity()?"":""};pt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};pt.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};pt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};pt.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),c=s.redMul(n),u=t.z.redMul(f.redAdd(c).redSqr()),b=t.x.redMul(f.redISub(c).redSqr());return this.curve.point(u,b)};pt.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};pt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};pt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};pt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};pt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};pt.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Yv=W((GC,Wv)=>{"use strict";var LE=jt(),Ei=ri(),Jv=Po(),ec=Ko(),qE=LE.assert;function ii(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,ec.call(this,"edwards",r),this.a=new Ei(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Ei(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Ei(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),qE(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Jv(ii,ec);Wv.exports=ii;ii.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};ii.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};ii.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};ii.prototype.pointFromX=function(e,t){e=new Ei(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var c=f.fromRed().isOdd();return(t&&!c||!t&&c)&&(f=f.redNeg()),this.point(e,f)};ii.prototype.pointFromY=function(e,t){e=new Ei(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};ii.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function We(r,e,t,i,n){ec.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Ei(e,16),this.y=new Ei(t,16),this.z=i?new Ei(i,16):this.curve.one,this.t=n&&new Ei(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Jv(We,ec.BasePoint);ii.prototype.pointFromJSON=function(e){return We.fromJSON(this,e)};ii.prototype.point=function(e,t,i,n){return new We(this,e,t,i,n)};We.fromJSON=function(e,t){return new We(e,t[0],t[1],t[2])};We.prototype.inspect=function(){return this.isInfinity()?"":""};We.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};We.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),c=n.redSub(t),u=s.redMul(f),b=o.redMul(c),y=s.redMul(c),S=f.redMul(o);return this.curve.point(u,b,S,y)};We.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,c,u;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(c=this.z.redSqr(),u=b.redSub(c).redISub(c),n=e.redSub(t).redISub(i).redMul(u),s=b.redMul(f.redSub(i)),o=b.redMul(u))}else f=t.redAdd(i),c=this.curve._mulC(this.z).redSqr(),u=f.redSub(c).redSub(c),n=this.curve._mulC(e.redISub(f)).redMul(u),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(u);return this.curve.point(n,s,o)};We.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};We.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),c=s.redAdd(n),u=i.redAdd(t),b=o.redMul(f),y=c.redMul(u),S=o.redMul(u),I=f.redMul(c);return this.curve.point(b,y,I,S)};We.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),c=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(u),y,S;return this.curve.twisted?(y=t.redMul(c).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(c)):(y=t.redMul(c).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(c)),this.curve.point(b,y,S)};We.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};We.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};We.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};We.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};We.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};We.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};We.prototype.getX=function(){return this.normalize(),this.x.fromRed()};We.prototype.getY=function(){return this.normalize(),this.y.fromRed()};We.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};We.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};We.prototype.toP=We.prototype.normalize;We.prototype.mixedAdd=We.prototype.add});var yd=W(Xv=>{"use strict";var tc=Xv;tc.base=Ko();tc.short=Vv();tc.mont=Gv();tc.edwards=Yv()});var Qv=W((WC,Zv)=>{Zv.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var rc=W(rm=>{"use strict";var _d=rm,Vi=qo(),wd=yd(),FE=jt(),em=FE.assert;function tm(r){r.type==="short"?this.curve=new wd.short(r):r.type==="edwards"?this.curve=new wd.edwards(r):this.curve=new wd.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,em(this.g.validate(),"Invalid curve"),em(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}_d.PresetCurve=tm;function $i(r,e){Object.defineProperty(_d,r,{configurable:!0,enumerable:!0,get:function(){var t=new tm(e);return Object.defineProperty(_d,r,{configurable:!0,enumerable:!0,value:t}),t}})}$i("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vi.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});$i("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vi.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});$i("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vi.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});$i("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vi.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});$i("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vi.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});$i("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vi.sha256,gRed:!1,g:["9"]});$i("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vi.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var xd;try{xd=Qv()}catch{xd=void 0}$i("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vi.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",xd]})});var sm=W((XC,nm)=>{"use strict";var UE=qo(),Ln=ld(),im=Fi();function Hi(r){if(!(this instanceof Hi))return new Hi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Ln.toArray(r.entropy,r.entropyEnc||"hex"),t=Ln.toArray(r.nonce,r.nonceEnc||"hex"),i=Ln.toArray(r.pers,r.persEnc||"hex");im(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}nm.exports=Hi;Hi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Hi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Ln.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var BE=ri(),zE=jt(),Ed=zE.assert;function Tt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}om.exports=Tt;Tt.fromPublic=function(e,t,i){return t instanceof Tt?t:new Tt(e,{pub:t,pubEnc:i})};Tt.fromPrivate=function(e,t,i){return t instanceof Tt?t:new Tt(e,{priv:t,privEnc:i})};Tt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Tt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};Tt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Tt.prototype._importPrivate=function(e,t){this.priv=new BE(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};Tt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Ed(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Ed(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};Tt.prototype.derive=function(e){return e.validate()||Ed(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Tt.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};Tt.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};Tt.prototype.inspect=function(){return""}});var um=W((QC,cm)=>{"use strict";var ic=ri(),Md=jt(),kE=Md.assert;function nc(r,e){if(r instanceof nc)return r;this._importDER(r,e)||(kE(r.r&&r.s,"Signature without r or s"),this.r=new ic(r.r,16),this.s=new ic(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}cm.exports=nc;function KE(){this.place=0}function Sd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function fm(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}nc.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=fm(t),i=fm(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Id(n,t.length),n=n.concat(t),n.push(2),Id(n,i.length);var s=n.concat(i),o=[48];return Id(o,s.length),o=o.concat(s),Md.encode(o,e)}});var pm=W((eP,lm)=>{"use strict";var qn=ri(),hm=sm(),jE=jt(),Ad=rc(),VE=vd(),dm=jE.assert,Rd=am(),sc=um();function sr(r){if(!(this instanceof sr))return new sr(r);typeof r=="string"&&(dm(Object.prototype.hasOwnProperty.call(Ad,r),"Unknown curve "+r),r=Ad[r]),r instanceof Ad.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}lm.exports=sr;sr.prototype.keyPair=function(e){return new Rd(this,e)};sr.prototype.keyFromPrivate=function(e,t){return Rd.fromPrivate(this,e,t)};sr.prototype.keyFromPublic=function(e,t){return Rd.fromPublic(this,e,t)};sr.prototype.genKeyPair=function(e){e||(e={});for(var t=new hm({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||VE(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new qn(2));;){var s=new qn(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};sr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};sr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new qn(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),c=new hm({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new qn(1)),b=0;;b++){var y=n.k?n.k(b):new qn(c.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new sc({r:M,s:T,recoveryParam:O})}}}}}};sr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new qn(e,16)),i=this.keyFromPublic(i,n),t=new sc(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),c=f.mul(e).umod(this.n),u=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(c,i.getPublic(),u),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};sr.prototype.recoverPubKey=function(r,e,t,i){dm((3&t)===t,"The recovery param is more than two bits"),e=new sc(e,i);var n=this.n,s=new qn(r),o=e.r,f=e.s,c=t&1,u=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");u?o=this.curve.pointFromX(o.add(this.curve.n),c):o=this.curve.pointFromX(o,c);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};sr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new sc(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var mm=W((tP,vm)=>{"use strict";var jo=jt(),bm=jo.assert,gm=jo.parseBytes,Ps=jo.cachedProperty;function gt(r,e){this.eddsa=r,this._secret=gm(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=gm(e.pub)}gt.fromPublic=function(e,t){return t instanceof gt?t:new gt(e,{pub:t})};gt.fromSecret=function(e,t){return t instanceof gt?t:new gt(e,{secret:t})};gt.prototype.secret=function(){return this._secret};Ps(gt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});Ps(gt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});Ps(gt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});Ps(gt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});Ps(gt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});Ps(gt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});gt.prototype.sign=function(e){return bm(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};gt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};gt.prototype.getSecret=function(e){return bm(this._secret,"KeyPair is public only"),jo.encode(this.secret(),e)};gt.prototype.getPublic=function(e){return jo.encode(this.pubBytes(),e)};vm.exports=gt});var _m=W((rP,wm)=>{"use strict";var $E=ri(),oc=jt(),ym=oc.assert,ac=oc.cachedProperty,HE=oc.parseBytes;function Fn(r,e){this.eddsa=r,typeof e!="object"&&(e=HE(e)),Array.isArray(e)&&(ym(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),ym(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof $E&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}ac(Fn,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});ac(Fn,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});ac(Fn,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});ac(Fn,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Fn.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Fn.prototype.toHex=function(){return oc.encode(this.toBytes(),"hex").toUpperCase()};wm.exports=Fn});var Mm=W((iP,Im)=>{"use strict";var GE=qo(),JE=rc(),Os=jt(),WE=Os.assert,Em=Os.parseBytes,Sm=mm(),xm=_m();function Bt(r){if(WE(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Bt))return new Bt(r);r=JE[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=GE.sha512}Im.exports=Bt;Bt.prototype.sign=function(e,t){e=Em(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),c=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:c,Rencoded:o})};Bt.prototype.verify=function(e,t,i){if(e=Em(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Bt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Un=Am;Un.version=qv().version;Un.utils=jt();Un.rand=vd();Un.curve=yd();Un.curves=rc();Un.ec=pm();Un.eddsa=Mm()});var Tm,Dm=Z(()=>{Tm={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}}});function Go(r){let[e,t]=r.split(YE);return{namespace:e,reference:t}}function $m(r,e){return r.includes(":")?[r]:e.chains||[]}function Jo(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function kn(){return!(0,Ii.getDocument)()&&!!(0,Ii.getNavigator)()&&navigator.product===e9}function Fs(){return!Jo()&&!!(0,Ii.getNavigator)()&&!!(0,Ii.getDocument)()}function Wo(){return kn()?zt.reactNative:Jo()?zt.node:Fs()?zt.browser:zt.unknown}function Hm(){var r;try{return kn()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function r9(r,e){let t=Ls.parse(r);return t=Pm(Pm({},t),e),r=Ls.stringify(t),r}function Us(){return(0,Km.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function i9(){if(Wo()===zt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){let{OS:t,Version:i}=global.Platform;return[t,i].join("-")}let r=ug();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function n9(){var r;let e=Wo();return e===zt.browser?[e,((r=(0,Ii.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function Nd(r,e,t){let i=i9(),n=n9();return[[r,e].join("-"),[t9,t].join("-"),i,n].join("/")}function Gm({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){let c=t.split("?"),u=Nd(r,e,i),b={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},y=r9(c[1]||"",b);return c[0]+"?"+y}function Bn(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Cd(r){return Object.fromEntries(r.entries())}function Pd(r){return new Map(Object.entries(r))}function Mi(r=Si.FIVE_MINUTES,e){let t=(0,Si.toMiliseconds)(r||Si.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Kn(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Jm(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Wm(r){return Jm("topic",r)}function Ym(r){return Jm("id",r)}function uc(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ft(r,e){return(0,Si.fromMiliseconds)((e||Date.now())+(0,Si.toMiliseconds)(r))}function ni(r){return Date.now()>=(0,Si.toMiliseconds)(r)}function Le(r,e){return`${r}${e?`:${e}`:""}`}function s9(r=[],e=[]){return[...new Set([...r,...e])]}async function Xm({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=o9(s,r,e),f=Wo();if(f===zt.browser){if(!((i=(0,Ii.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,a9()?"_blank":"_self","noreferrer noopener")}else f===zt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function o9(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${f9(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Zm(r,e){let t="";try{if(Fs()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Od(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ld(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Yo(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function a9(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function f9(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Qm(r){return Buffer.from(r,"base64").toString("utf-8")}async function u9(r,e,t,i,n,s){switch(t.t){case"eip191":return h9(r,e,t.s);case"eip1271":return await d9(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function h9(r,e,t){return hv(Cf(e),t).toLowerCase()===r.toLowerCase()}async function d9(r,e,t,i,n,s){let o=Go(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let f="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),y=Cf(e).substring(2),S=f+y+c+u+b,I=await fetch(`${s||c9}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:l9(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:M}=await I.json();return M?M.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function l9(){return Date.now()+Math.floor(Math.random()*1e3)}async function Fd(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Ud(n,n.iss),o=Xo(n.iss);return await u9(o,s,i,hc(n.iss),t)}function E9(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function S9(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function zn(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function I9(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:M9(e,t,i)}}}function M9(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function ey(r){return zn(r),`urn:recap:${E9(r).replace(/=/g,"")}`}function $o(r){let e=S9(r.replace("urn:recap:",""));return zn(e),e}function ty(r,e,t){let i=I9(r,e,t);return ey(i)}function A9(r){return r&&r.includes("urn:recap:")}function ry(r,e){let t=$o(r),i=$o(e),n=R9(t,i);return ey(n)}function R9(r,e){zn(r),zn(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,c)=>f.localeCompare(c)).forEach(f=>{var c,u;i.att[n]=w9(y9({},i.att[n]),{[f]:((c=r.att[n])==null?void 0:c[f])||((u=e.att[n])==null?void 0:u[f])})})}),i}function T9(r="",e){zn(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(f=>{let c=Object.keys(e.att[f]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));c.sort((y,S)=>y.action.localeCompare(S.action));let u={};c.forEach(y=>{u[y.ability]||(u[y.ability]=[]),u[y.ability].push(y.action)});let b=Object.keys(u).map(y=>(n++,`(${n}) '${y}': '${u[y].join("', '")}' for '${f}'.`));i.push(b.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Bd(r){var e;let t=$o(r);zn(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function zd(r){let e=$o(r);zn(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Zo(r){if(!r)return;let e=r?.[r.length-1];return A9(e)?e:void 0}function sy(){let r=cc.generateKeyPair();return{privateKey:tt(r.secretKey,Dt),publicKey:tt(r.publicKey,Dt)}}function dc(){let r=(0,Ho.randomBytes)(kd);return tt(r,Dt)}function oy(r,e){let t=cc.sharedKey(st(r,Dt),st(e,Dt),!0),i=new jm.HKDF(qs.SHA256,t).expand(kd);return tt(i,Dt)}function ks(r){let e=(0,qs.hash)(st(r,Dt));return tt(e,Dt)}function _r(r){let e=(0,qs.hash)(st(r,Qo));return tt(e,Dt)}function ay(r){return st(`${r}`,iy)}function Gi(r){return Number(tt(r,iy))}function fy(r){let e=ay(typeof r.type<"u"?r.type:ny);if(Gi(e)===wr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?st(r.senderPublicKey,Dt):void 0,i=typeof r.iv<"u"?st(r.iv,Dt):(0,Ho.randomBytes)(Vo),n=new Dd.ChaCha20Poly1305(st(r.symKey,Dt)).seal(i,st(r.message,Qo));return dy({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function cy(r,e){let t=ay(zs),i=(0,Ho.randomBytes)(Vo),n=st(r,Qo);return dy({type:t,sealed:n,iv:i,encoding:e})}function uy(r){let e=new Dd.ChaCha20Poly1305(st(r.symKey,Dt)),{sealed:t,iv:i}=Ks({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return tt(n,Qo)}function hy(r,e){let{sealed:t}=Ks({encoded:r,encoding:e});return tt(t,Qo)}function dy(r){let{encoding:e=si}=r;if(Gi(r.type)===zs)return tt(An([r.type,r.sealed]),e);if(Gi(r.type)===wr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return tt(An([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return tt(An([r.type,r.iv,r.sealed]),e)}function Ks(r){let{encoded:e,encoding:t=si}=r,i=st(e,t),n=i.slice(D9,qm),s=qm;if(Gi(n)===wr){let u=s+kd,b=u+Vo,y=i.slice(s,u),S=i.slice(u,b),I=i.slice(b);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(Gi(n)===zs){let u=i.slice(s),b=(0,Ho.randomBytes)(Vo);return{type:n,sealed:u,iv:b}}let o=s+Vo,f=i.slice(s,o),c=i.slice(o);return{type:n,sealed:c,iv:f}}function ly(r,e){let t=Ks({encoded:r,encoding:e?.encoding});return Kd({type:Gi(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?tt(t.senderPublicKey,Dt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Kd(r){let e=r?.type||ny;if(e===wr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function jd(r){return r.type===wr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function Vd(r){return r.type===zs}function N9(r){return new Vm.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function C9(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function P9(r){return Buffer.from(C9(r),"base64")}function py(r,e){let[t,i,n]=r.split("."),s=P9(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),c=`${t}.${i}`,u=new qs.SHA256().update(Buffer.from(c)).digest(),b=N9(e),y=Buffer.from(u).toString("hex");if(!b.verify(y,{r:o,s:f}))throw new Error("Invalid signature");return vs(r).payload}function lc(r){return r?.relay||{protocol:O9}}function js(r){let e=Tm[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}function k9(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function $d(r){if(!r.includes("wc:")){let c=Qm(r);c!=null&&c.includes("wc:")&&(r=c)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=Ls.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:K9(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:k9(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function K9(r){return r.startsWith("//")?r.substring(2):r}function j9(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function Hd(r){return`${r.protocol}:${r.topic}@${r.version}?`+Ls.stringify(Bm(z9(Bm({symKey:r.symKey},j9(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function ea(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Vs(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function V9(r){let e=[];return Object.values(r).forEach(t=>{e.push(...Vs(t.accounts))}),e}function $9(r,e){let t=[];return Object.values(r).forEach(i=>{Vs(i.accounts).includes(e)&&t.push(...i.methods)}),t}function H9(r,e){let t=[];return Object.values(r).forEach(i=>{Vs(i.accounts).includes(e)&&t.push(...i.events)}),t}function G9(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Gd(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=G9(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=s9(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}function Q(r,e){let{message:t,code:i}=W9[r];return{message:e?`${t} ${e}`:t,code:i}}function Be(r,e){let{message:t,code:i}=J9[r];return{message:e?`${t} ${e}`:t,code:i}}function Wi(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function ta(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function xt(r){return typeof r>"u"}function Qe(r,e){return e&&xt(r)?!0:typeof r=="string"&&!!r.trim().length}function Jd(r,e){return e&&xt(r)?!0:typeof r=="number"&&!isNaN(r)}function gy(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return Bn(n,i)?(i.forEach(o=>{let{accounts:f,methods:c,events:u}=r.namespaces[o],b=Vs(f),y=t[o];(!Bn($m(o,y),b)||!Bn(y.methods,c)||!Bn(y.events,u))&&(s=!1)}),s):!1}function fc(r){return Qe(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function Y9(r){if(Qe(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&fc(t)}}return!1}function by(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Qe(r,!1)){if(e(r))return!0;let t=Qm(r);return e(t)}}catch{}return!1}function vy(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function my(r){return r?.topic}function yy(r,e){let t=null;return Qe(r?.publicKey,!1)||(t=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function zm(r){let e=!0;return Wi(r)?r.length&&(e=r.every(t=>Qe(t,!1))):e=!1,e}function X9(r,e,t){let i=null;return Wi(e)&&e.length?e.forEach(n=>{i||fc(n)||(i=Be("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):fc(r)||(i=Be("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Z9(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=X9(n,$m(n,s),`${e} ${t}`);o&&(i=o)}),i}function Q9(r,e){let t=null;return Wi(r)?r.forEach(i=>{t||Y9(i)||(t=Be("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Be("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function e7(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=Q9(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function t7(r,e){let t=null;return zm(r?.methods)?zm(r?.events)||(t=Be("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Be("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function wy(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=t7(i,`${e}, namespace`);n&&(t=n)}),t}function _y(r,e,t){let i=null;if(r&&ta(r)){let n=wy(r,e);n&&(i=n);let s=Z9(r,e,t);s&&(i=s)}else i=Q("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function pc(r,e){let t=null;if(r&&ta(r)){let i=wy(r,e);i&&(t=i);let n=e7(r,e);n&&(t=n)}else t=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Wd(r){return Qe(r.protocol,!0)}function xy(r,e){let t=!1;return e&&!r?t=!0:r&&Wi(r)&&r.length&&r.forEach(i=>{t=Wd(i)}),t}function Ey(r){return typeof r=="number"}function Nt(r){return typeof r<"u"&&typeof r!==null}function Sy(r){return!(!r||typeof r!="object"||!r.code||!Jd(r.code,!1)||!r.message||!Qe(r.message,!1))}function Iy(r){return!(xt(r)||!Qe(r.method,!1))}function My(r){return!(xt(r)||xt(r.result)&&xt(r.error)||!Jd(r.id,!1)||!Qe(r.jsonrpc,!1))}function Ay(r){return!(xt(r)||!Qe(r.name,!1))}function Yd(r,e){return!(!fc(e)||!V9(r).includes(e))}function Ry(r,e,t){return Qe(t,!1)?$9(r,e).includes(t):!1}function Ty(r,e,t){return Qe(t,!1)?H9(r,e).includes(t):!1}function Xd(r,e,t){let i=null,n=r7(r),s=i7(e),o=Object.keys(n),f=Object.keys(s),c=km(Object.keys(r)),u=km(Object.keys(e)),b=c.filter(y=>!u.includes(y));return b.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. - Required: ${b.toString()} - Received: ${Object.keys(e).toString()}`)),Bn(o,f)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. +`});var wd=P(()=>{yd();$n();Ut();nc();pi()});var cc,L3,bd=P(()=>{Hl();Gl();Wl();Jl();Yl();Ya();Xl();Za();Ql();ed();ud();dd();fd();pd();wd();cc={...ja,...$a,...Ha,...Ga,...Wa,...Ja,...Xa,...Qa,...ec,...tc},L3={...oc,...ac}});function _d(i,e,r,t){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:r},decoder:{decode:t}}}var Ed,uc,eb,Jn,hc=P(()=>{bd();Kn();Ed=_d("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),uc=_d("ascii","a",i=>{let e="a";for(let r=0;r{i=i.substring(1);let e=hi(i.length);for(let r=0;r{hc()});function _e(i,e="utf8"){let r=Jn[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(i,"utf8"):r.decoder.decode(`${r.prefix}${i}`)}var dc=P(()=>{hc()});function vd(i){return ut(we(_e(i,ui),Ma))}function Yn(i){return we(_e($e(i),Ma),ui)}function Xn(i){let e=_e(kl,ka),r=Fl+we(ir([e,i]),ka);return[Ul,Ml,r].join(Ll)}function tb(i){return we(i,ui)}function rb(i){return _e(i,ui)}function xd(i){return _e([Yn(i.header),Yn(i.payload)].join(ci),Fa)}function Sd(i){return[Yn(i.header),Yn(i.payload),tb(i.signature)].join(ci)}function Lr(i){let e=i.split(ci),r=vd(e[0]),t=vd(e[1]),s=rb(e[2]),n=_e(e.slice(0,2).join(ci),Fa);return{header:r,payload:t,signature:s,data:n}}var fc=P(()=>{Ba();lc();dc();Sr();Vn()});function pc(i=(0,Id.randomBytes)(32)){return mi.generateKeyPairFromSeed(i)}async function Td(i,e,r,t,s=(0,Dd.fromMiliseconds)(Date.now())){let n={alg:Ol,typ:Pl},o=Xn(t.publicKey),a=s+r,c={iss:o,sub:i,aud:e,iat:s,exp:a},h=xd({header:n,payload:c}),d=mi.sign(t.secretKey,h);return Sd({header:n,payload:c,signature:d})}var mi,Id,Dd,Rd=P(()=>{mi=pe(Al()),Id=pe(ni()),Dd=pe(xr());Vn();fc()});var Cd=P(()=>{});var Qn=P(()=>{Rd();Vn();Cd();fc()});function Ld(i){return i?Pd(i):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ub:typeof navigator<"u"?Pd(navigator.userAgent):gb()}function fb(i){return i!==""&&db.reduce(function(e,r){var t=r[0],s=r[1];if(e)return e;var n=s.exec(i);return!!n&&[t,n]},!1)}function Pd(i){var e=fb(i);if(!e)return null;var r=e[0],t=e[1];if(r==="searchbot")return new cb;var s=t[1]&&t[1].split(".").join("_").split("_").slice(0,3);s?s.length{Nd=function(i,e,r){if(r||arguments.length===2)for(var t=0,s=e.length,n;t{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.getLocalStorage=fe.getLocalStorageOrThrow=fe.getCrypto=fe.getCryptoOrThrow=fe.getLocation=fe.getLocationOrThrow=fe.getNavigator=fe.getNavigatorOrThrow=fe.getDocument=fe.getDocumentOrThrow=fe.getFromWindowOrThrow=fe.getFromWindow=void 0;function nr(i){let e;return typeof window<"u"&&typeof window[i]<"u"&&(e=window[i]),e}fe.getFromWindow=nr;function Ur(i){let e=nr(i);if(!e)throw new Error(`${i} is not defined in Window`);return e}fe.getFromWindowOrThrow=Ur;function yb(){return Ur("document")}fe.getDocumentOrThrow=yb;function wb(){return nr("document")}fe.getDocument=wb;function bb(){return Ur("navigator")}fe.getNavigatorOrThrow=bb;function Eb(){return nr("navigator")}fe.getNavigator=Eb;function _b(){return Ur("location")}fe.getLocationOrThrow=_b;function vb(){return nr("location")}fe.getLocation=vb;function xb(){return Ur("crypto")}fe.getCryptoOrThrow=xb;function Sb(){return nr("crypto")}fe.getCrypto=Sb;function Ib(){return Ur("localStorage")}fe.getLocalStorageOrThrow=Ib;function Db(){return nr("localStorage")}fe.getLocalStorage=Db});var Fd=oe(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.getWindowMetadata=void 0;var Md=Zn();function Tb(){let i,e;try{i=Md.getDocumentOrThrow(),e=Md.getLocationOrThrow()}catch{return null}function r(){let l=i.getElementsByTagName("link"),p=[];for(let f=0;f-1){let b=g.getAttribute("href");if(b)if(b.toLowerCase().indexOf("https:")===-1&&b.toLowerCase().indexOf("http:")===-1&&b.indexOf("//")!==0){let v=e.protocol+"//"+e.host;if(b.indexOf("/")===0)v+=b;else{let x=e.pathname.split("/");x.pop();let I=x.join("/");v+=I+"/"+b}p.push(v)}else if(b.indexOf("//")===0){let v=e.protocol+b;p.push(v)}else p.push(b)}}return p}function t(...l){let p=i.getElementsByTagName("meta");for(let f=0;fg.getAttribute(b)).filter(b=>b?l.includes(b):!1);if(w.length&&w){let b=g.getAttribute("content");if(b)return b}}return""}function s(){let l=t("name","og:site_name","og:title","twitter:title");return l||(l=i.title),l}function n(){return t("description","og:description","twitter:description","keywords")}let o=s(),a=n(),c=e.origin,h=r();return{description:a,url:c,icons:h,name:o}}eo.getWindowMetadata=Tb});function gc(i){let e=new URLSearchParams(i),r={};for(let[t,s]of e.entries())r[t]=s;return r}function mc(i){let e=new URLSearchParams;for(let r in i)i[r]!=null&&e.append(r,i[r]);return e.toString()}var kd=P(()=>{});var Bd=oe((aS,to)=>{(function(){"use strict";var i="input is invalid type",e="finalize already called",r=typeof window=="object",t=r?window:{};t.JS_SHA3_NO_WINDOW&&(r=!1);var s=!r&&typeof self=="object",n=!t.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;n?t=window:s&&(t=self);var o=!t.JS_SHA3_NO_COMMON_JS&&typeof to=="object"&&to.exports,a=typeof define=="function"&&define.amd,c=!t.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),d=[31,7936,2031616,520093696],l=[4,1024,262144,67108864],p=[1,256,65536,16777216],f=[6,1536,393216,100663296],g=[0,8,16,24],w=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],b=[224,256,384,512],v=[128,256],x=["hex","buffer","arrayBuffer","array","digest"],I={128:168,256:136};(t.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(u){return Object.prototype.toString.call(u)==="[object Array]"}),c&&(t.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(u){return typeof u=="object"&&u.buffer&&u.buffer.constructor===ArrayBuffer});for(var S=function(u,E,_){return function(D){return new V(u,E,u).update(D)[_]()}},T=function(u,E,_){return function(D,A){return new V(u,E,A).update(D)[_]()}},L=function(u,E,_){return function(D,A,U,F){return N["cshake"+u].update(D,A,U,F)[_]()}},y=function(u,E,_){return function(D,A,U,F){return N["kmac"+u].update(D,A,U,F)[_]()}},m=function(u,E,_,D){for(var A=0;A>5,this.byteCount=this.blockCount<<2,this.outputBlocks=_>>5,this.extraBytes=(_&31)>>3;for(var D=0;D<50;++D)this.s[D]=0}V.prototype.update=function(u){if(this.finalized)throw new Error(e);var E,_=typeof u;if(_!=="string"){if(_==="object"){if(u===null)throw new Error(i);if(c&&u.constructor===ArrayBuffer)u=new Uint8Array(u);else if(!Array.isArray(u)&&(!c||!ArrayBuffer.isView(u)))throw new Error(i)}else throw new Error(i);E=!0}for(var D=this.blocks,A=this.byteCount,U=u.length,F=this.blockCount,M=0,Q=this.s,z,ee;M>2]|=u[M]<>2]|=ee<>2]|=(192|ee>>6)<>2]|=(128|ee&63)<=57344?(D[z>>2]|=(224|ee>>12)<>2]|=(128|ee>>6&63)<>2]|=(128|ee&63)<>2]|=(240|ee>>18)<>2]|=(128|ee>>12&63)<>2]|=(128|ee>>6&63)<>2]|=(128|ee&63)<=A){for(this.start=z-A,this.block=D[F],z=0;z>8,_=u&255;_>0;)A.unshift(_),u=u>>8,_=u&255,++D;return E?A.push(D):A.unshift(D),this.update(A),A.length},V.prototype.encodeString=function(u){var E,_=typeof u;if(_!=="string"){if(_==="object"){if(u===null)throw new Error(i);if(c&&u.constructor===ArrayBuffer)u=new Uint8Array(u);else if(!Array.isArray(u)&&(!c||!ArrayBuffer.isView(u)))throw new Error(i)}else throw new Error(i);E=!0}var D=0,A=u.length;if(E)D=A;else for(var U=0;U=57344?D+=3:(F=65536+((F&1023)<<10|u.charCodeAt(++U)&1023),D+=4)}return D+=this.encode(D*8),this.update(u),D},V.prototype.bytepad=function(u,E){for(var _=this.encode(E),D=0;D>2]|=this.padding[E&3],this.lastByteIndex===this.byteCount)for(u[0]=u[_],E=1;E<_+1;++E)u[E]=0;for(u[_-1]|=2147483648,E=0;E<_;++E)D[E]^=u[E];X(D)}},V.prototype.toString=V.prototype.hex=function(){this.finalize();for(var u=this.blockCount,E=this.s,_=this.outputBlocks,D=this.extraBytes,A=0,U=0,F="",M;U<_;){for(A=0;A>4&15]+h[M&15]+h[M>>12&15]+h[M>>8&15]+h[M>>20&15]+h[M>>16&15]+h[M>>28&15]+h[M>>24&15];U%u===0&&(X(E),A=0)}return D&&(M=E[A],F+=h[M>>4&15]+h[M&15],D>1&&(F+=h[M>>12&15]+h[M>>8&15]),D>2&&(F+=h[M>>20&15]+h[M>>16&15])),F},V.prototype.arrayBuffer=function(){this.finalize();var u=this.blockCount,E=this.s,_=this.outputBlocks,D=this.extraBytes,A=0,U=0,F=this.outputBits>>3,M;D?M=new ArrayBuffer(_+1<<2):M=new ArrayBuffer(F);for(var Q=new Uint32Array(M);U<_;){for(A=0;A>8&255,F[M+2]=Q>>16&255,F[M+3]=Q>>24&255;U%u===0&&X(E)}return D&&(M=U<<2,Q=E[A],F[M]=Q&255,D>1&&(F[M+1]=Q>>8&255),D>2&&(F[M+2]=Q>>16&255)),F};function J(u,E,_){V.call(this,u,E,_)}J.prototype=new V,J.prototype.finalize=function(){return this.encode(this.outputBits,!0),V.prototype.finalize.call(this)};var X=function(u){var E,_,D,A,U,F,M,Q,z,ee,ns,os,as,cs,us,hs,ls,ds,fs,ps,gs,ms,ys,ws,bs,Es,_s,vs,xs,Ss,Is,Ds,Ts,Rs,Cs,Ns,As,Os,Ps,Ls,Us,Ms,Fs,ks,Bs,qs,zs,Vs,Ks,js,$s,Hs,Gs,Ws,Js,Ys,Xs,Qs,Zs,en,tn,rn,sn;for(D=0;D<48;D+=2)A=u[0]^u[10]^u[20]^u[30]^u[40],U=u[1]^u[11]^u[21]^u[31]^u[41],F=u[2]^u[12]^u[22]^u[32]^u[42],M=u[3]^u[13]^u[23]^u[33]^u[43],Q=u[4]^u[14]^u[24]^u[34]^u[44],z=u[5]^u[15]^u[25]^u[35]^u[45],ee=u[6]^u[16]^u[26]^u[36]^u[46],ns=u[7]^u[17]^u[27]^u[37]^u[47],os=u[8]^u[18]^u[28]^u[38]^u[48],as=u[9]^u[19]^u[29]^u[39]^u[49],E=os^(F<<1|M>>>31),_=as^(M<<1|F>>>31),u[0]^=E,u[1]^=_,u[10]^=E,u[11]^=_,u[20]^=E,u[21]^=_,u[30]^=E,u[31]^=_,u[40]^=E,u[41]^=_,E=A^(Q<<1|z>>>31),_=U^(z<<1|Q>>>31),u[2]^=E,u[3]^=_,u[12]^=E,u[13]^=_,u[22]^=E,u[23]^=_,u[32]^=E,u[33]^=_,u[42]^=E,u[43]^=_,E=F^(ee<<1|ns>>>31),_=M^(ns<<1|ee>>>31),u[4]^=E,u[5]^=_,u[14]^=E,u[15]^=_,u[24]^=E,u[25]^=_,u[34]^=E,u[35]^=_,u[44]^=E,u[45]^=_,E=Q^(os<<1|as>>>31),_=z^(as<<1|os>>>31),u[6]^=E,u[7]^=_,u[16]^=E,u[17]^=_,u[26]^=E,u[27]^=_,u[36]^=E,u[37]^=_,u[46]^=E,u[47]^=_,E=ee^(A<<1|U>>>31),_=ns^(U<<1|A>>>31),u[8]^=E,u[9]^=_,u[18]^=E,u[19]^=_,u[28]^=E,u[29]^=_,u[38]^=E,u[39]^=_,u[48]^=E,u[49]^=_,cs=u[0],us=u[1],qs=u[11]<<4|u[10]>>>28,zs=u[10]<<4|u[11]>>>28,vs=u[20]<<3|u[21]>>>29,xs=u[21]<<3|u[20]>>>29,en=u[31]<<9|u[30]>>>23,tn=u[30]<<9|u[31]>>>23,Ms=u[40]<<18|u[41]>>>14,Fs=u[41]<<18|u[40]>>>14,Rs=u[2]<<1|u[3]>>>31,Cs=u[3]<<1|u[2]>>>31,hs=u[13]<<12|u[12]>>>20,ls=u[12]<<12|u[13]>>>20,Vs=u[22]<<10|u[23]>>>22,Ks=u[23]<<10|u[22]>>>22,Ss=u[33]<<13|u[32]>>>19,Is=u[32]<<13|u[33]>>>19,rn=u[42]<<2|u[43]>>>30,sn=u[43]<<2|u[42]>>>30,Ws=u[5]<<30|u[4]>>>2,Js=u[4]<<30|u[5]>>>2,Ns=u[14]<<6|u[15]>>>26,As=u[15]<<6|u[14]>>>26,ds=u[25]<<11|u[24]>>>21,fs=u[24]<<11|u[25]>>>21,js=u[34]<<15|u[35]>>>17,$s=u[35]<<15|u[34]>>>17,Ds=u[45]<<29|u[44]>>>3,Ts=u[44]<<29|u[45]>>>3,ws=u[6]<<28|u[7]>>>4,bs=u[7]<<28|u[6]>>>4,Ys=u[17]<<23|u[16]>>>9,Xs=u[16]<<23|u[17]>>>9,Os=u[26]<<25|u[27]>>>7,Ps=u[27]<<25|u[26]>>>7,ps=u[36]<<21|u[37]>>>11,gs=u[37]<<21|u[36]>>>11,Hs=u[47]<<24|u[46]>>>8,Gs=u[46]<<24|u[47]>>>8,ks=u[8]<<27|u[9]>>>5,Bs=u[9]<<27|u[8]>>>5,Es=u[18]<<20|u[19]>>>12,_s=u[19]<<20|u[18]>>>12,Qs=u[29]<<7|u[28]>>>25,Zs=u[28]<<7|u[29]>>>25,Ls=u[38]<<8|u[39]>>>24,Us=u[39]<<8|u[38]>>>24,ms=u[48]<<14|u[49]>>>18,ys=u[49]<<14|u[48]>>>18,u[0]=cs^~hs&ds,u[1]=us^~ls&fs,u[10]=ws^~Es&vs,u[11]=bs^~_s&xs,u[20]=Rs^~Ns&Os,u[21]=Cs^~As&Ps,u[30]=ks^~qs&Vs,u[31]=Bs^~zs&Ks,u[40]=Ws^~Ys&Qs,u[41]=Js^~Xs&Zs,u[2]=hs^~ds&ps,u[3]=ls^~fs&gs,u[12]=Es^~vs&Ss,u[13]=_s^~xs&Is,u[22]=Ns^~Os&Ls,u[23]=As^~Ps&Us,u[32]=qs^~Vs&js,u[33]=zs^~Ks&$s,u[42]=Ys^~Qs&en,u[43]=Xs^~Zs&tn,u[4]=ds^~ps&ms,u[5]=fs^~gs&ys,u[14]=vs^~Ss&Ds,u[15]=xs^~Is&Ts,u[24]=Os^~Ls&Ms,u[25]=Ps^~Us&Fs,u[34]=Vs^~js&Hs,u[35]=Ks^~$s&Gs,u[44]=Qs^~en&rn,u[45]=Zs^~tn&sn,u[6]=ps^~ms&cs,u[7]=gs^~ys&us,u[16]=Ss^~Ds&ws,u[17]=Is^~Ts&bs,u[26]=Ls^~Ms&Rs,u[27]=Us^~Fs&Cs,u[36]=js^~Hs&ks,u[37]=$s^~Gs&Bs,u[46]=en^~rn&Ws,u[47]=tn^~sn&Js,u[8]=ms^~cs&hs,u[9]=ys^~us&ls,u[18]=Ds^~ws&Es,u[19]=Ts^~bs&_s,u[28]=Ms^~Rs&Ns,u[29]=Fs^~Cs&As,u[38]=Hs^~ks&qs,u[39]=Gs^~Bs&zs,u[48]=rn^~Ws&Ys,u[49]=sn^~Js&Xs,u[0]^=w[D],u[1]^=w[D+1]};if(o)to.exports=N;else{for(H=0;H{qd="logger/5.7.0"});function Cb(){try{let i=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{i.push(e)}}),i.length)throw new Error("missing "+i.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(i){return i.message}return null}var Vd,Kd,ro,jd,yc,$d,wc,et,Hd,Fe,Mr=P(()=>{"use strict";zd();Vd=!1,Kd=!1,ro={debug:1,default:2,info:2,warning:3,error:4,off:5},jd=ro.default,yc=null;$d=Cb();(function(i){i.DEBUG="DEBUG",i.INFO="INFO",i.WARNING="WARNING",i.ERROR="ERROR",i.OFF="OFF"})(wc||(wc={}));(function(i){i.UNKNOWN_ERROR="UNKNOWN_ERROR",i.NOT_IMPLEMENTED="NOT_IMPLEMENTED",i.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",i.NETWORK_ERROR="NETWORK_ERROR",i.SERVER_ERROR="SERVER_ERROR",i.TIMEOUT="TIMEOUT",i.BUFFER_OVERRUN="BUFFER_OVERRUN",i.NUMERIC_FAULT="NUMERIC_FAULT",i.MISSING_NEW="MISSING_NEW",i.INVALID_ARGUMENT="INVALID_ARGUMENT",i.MISSING_ARGUMENT="MISSING_ARGUMENT",i.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",i.CALL_EXCEPTION="CALL_EXCEPTION",i.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",i.NONCE_EXPIRED="NONCE_EXPIRED",i.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",i.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",i.TRANSACTION_REPLACED="TRANSACTION_REPLACED",i.ACTION_REJECTED="ACTION_REJECTED"})(et||(et={}));Hd="0123456789abcdef",Fe=class i{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){let t=e.toLowerCase();ro[t]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(jd>ro[t])&&console.log.apply(console,r)}debug(...e){this._log(i.levels.DEBUG,e)}info(...e){this._log(i.levels.INFO,e)}warn(...e){this._log(i.levels.WARNING,e)}makeError(e,r,t){if(Kd)return this.makeError("censored error",r,{});r||(r=i.errors.UNKNOWN_ERROR),t||(t={});let s=[];Object.keys(t).forEach(c=>{let h=t[c];try{if(h instanceof Uint8Array){let d="";for(let l=0;l>4],d+=Hd[h[l]&15];s.push(c+"=Uint8Array(0x"+d+")")}else s.push(c+"="+JSON.stringify(h))}catch{s.push(c+"="+JSON.stringify(t[c].toString()))}}),s.push(`code=${r}`),s.push(`version=${this.version}`);let n=e,o="";switch(r){case et.NUMERIC_FAULT:{o="NUMERIC_FAULT";let c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case et.CALL_EXCEPTION:case et.INSUFFICIENT_FUNDS:case et.MISSING_NEW:case et.NONCE_EXPIRED:case et.REPLACEMENT_UNDERPRICED:case et.TRANSACTION_REPLACED:case et.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),s.length&&(e+=" ("+s.join(", ")+")");let a=new Error(e);return a.reason=n,a.code=r,Object.keys(t).forEach(function(c){a[c]=t[c]}),a}throwError(e,r,t){throw this.makeError(e,r,t)}throwArgumentError(e,r,t){return this.throwError(e,i.errors.INVALID_ARGUMENT,{argument:r,value:t})}assert(e,r,t,s){e||this.throwError(r,t,s)}assertArgument(e,r,t,s){e||this.throwArgumentError(r,t,s)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),$d&&this.throwError("platform missing String.prototype.normalize",i.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:$d})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,i.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,i.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,t){t?t=": "+t:t="",er&&this.throwError("too many arguments"+t,i.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",i.errors.MISSING_NEW,{name:r.name})}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",i.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",i.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return yc||(yc=new i(qd)),yc}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",i.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Vd){if(!e)return;this.globalLogger().throwError("error censorship permanent",i.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Kd=!!e,Vd=!!r}static setLogLevel(e){let r=ro[e.toLowerCase()];if(r==null){i.globalLogger().warn("invalid log level - "+e);return}jd=r}static from(e){return new i(e)}};Fe.errors=et;Fe.levels=wc});var Gd,Wd=P(()=>{Gd="bytes/5.7.0"});function Yd(i){return!!i.toHexString}function yi(i){return i.slice||(i.slice=function(){let e=Array.prototype.slice.call(arguments);return yi(new Uint8Array(Array.prototype.slice.apply(i,e)))}),i}function Jd(i){return typeof i=="number"&&i==i&&i%1===0}function Xd(i){if(i==null)return!1;if(i.constructor===Uint8Array)return!0;if(typeof i=="string"||!Jd(i.length)||i.length<0)return!1;for(let e=0;e=256)return!1}return!0}function ke(i,e){if(e||(e={}),typeof i=="number"){or.checkSafeUint53(i,"invalid arrayify value");let r=[];for(;i;)r.unshift(i&255),i=parseInt(String(i/256));return r.length===0&&r.push(0),yi(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof i=="string"&&i.substring(0,2)!=="0x"&&(i="0x"+i),Yd(i)&&(i=i.toHexString()),wi(i)){let r=i.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":or.throwArgumentError("hex data is odd-length","value",i));let t=[];for(let s=0;ske(s)),r=e.reduce((s,n)=>s+n.length,0),t=new Uint8Array(r);return e.reduce((s,n)=>(t.set(n,s),s+n.length),0),yi(t)}function wi(i,e){return!(typeof i!="string"||!i.match(/^0x[0-9A-Fa-f]*$/)||e&&i.length!==2+2*e)}function bi(i,e){if(e||(e={}),typeof i=="number"){or.checkSafeUint53(i,"invalid hexlify value");let r="";for(;i;)r=bc[i&15]+r,i=Math.floor(i/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof i=="bigint")return i=i.toString(16),i.length%2?"0x0"+i:"0x"+i;if(e.allowMissingPrefix&&typeof i=="string"&&i.substring(0,2)!=="0x"&&(i="0x"+i),Yd(i))return i.toHexString();if(wi(i))return i.length%2&&(e.hexPad==="left"?i="0x0"+i.substring(2):e.hexPad==="right"?i+="0":or.throwArgumentError("hex data is odd-length","value",i)),i.toLowerCase();if(Xd(i)){let r="0x";for(let t=0;t>4]+bc[s&15]}return r}return or.throwArgumentError("invalid hexlify value","value",i)}function io(i,e,r){return typeof i!="string"?i=bi(i):(!wi(i)||i.length%2)&&or.throwArgumentError("invalid hexData","value",i),e=2+2*e,r!=null?"0x"+i.substring(e,2+2*r):"0x"+i.substring(e)}var or,bc,ar=P(()=>{"use strict";Mr();Wd();or=new Fe(Gd);bc="0123456789abcdef"});function Fr(i){return"0x"+Qd.default.keccak_256(ke(i))}var Qd,so=P(()=>{"use strict";Qd=pe(Bd());ar()});var _c,Zd,ef=P(()=>{_c=class{constructor(e){this.value=BigInt(e)}toString(e=10){return this.value.toString(e)}toNumber(){return Number(this.value)}},Zd=_c});var tf,rf=P(()=>{tf="bignumber/5.7.0"});function vc(i){return new Nb(i,36).toString(16)}var Nb,vS,sf=P(()=>{"use strict";ef();Mr();rf();Nb=Zd.BN,vS=new Fe(tf)});var nf=P(()=>{sf()});var of,af=P(()=>{of="strings/5.7.0"});function Ob(i,e,r,t,s){return cf.throwArgumentError(`invalid codepoint at offset ${e}; ${i}`,"bytes",r)}function uf(i,e,r,t,s){if(i===cr.BAD_PREFIX||i===cr.UNEXPECTED_CONTINUE){let n=0;for(let o=e+1;o>6===2;o++)n++;return n}return i===cr.OVERRUN?r.length-e-1:0}function Pb(i,e,r,t,s){return i===cr.OVERLONG?(t.push(s),0):(t.push(65533),uf(i,e,r,t,s))}function _i(i,e=Ei.current){e!=Ei.current&&(cf.checkNormalize(),i=i.normalize(e));let r=[];for(let t=0;t>6|192),r.push(s&63|128);else if((s&64512)==55296){t++;let n=i.charCodeAt(t);if(t>=i.length||(n&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((s&1023)<<10)+(n&1023);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(o&63|128)}else r.push(s>>12|224),r.push(s>>6&63|128),r.push(s&63|128)}return ke(r)}var cf,Ei,cr,Lb,hf=P(()=>{"use strict";ar();Mr();af();cf=new Fe(of);(function(i){i.current="",i.NFC="NFC",i.NFD="NFD",i.NFKC="NFKC",i.NFKD="NFKD"})(Ei||(Ei={}));(function(i){i.UNEXPECTED_CONTINUE="unexpected continuation byte",i.BAD_PREFIX="bad codepoint prefix",i.OVERRUN="string overrun",i.MISSING_CONTINUE="missing continuation byte",i.OUT_OF_RANGE="out of UTF-8 range",i.UTF16_SURROGATE="UTF-16 surrogate",i.OVERLONG="overlong representation"})(cr||(cr={}));Lb=Object.freeze({error:Ob,ignore:uf,replace:Pb})});var lf=P(()=>{"use strict";hf()});function no(i){return typeof i=="string"&&(i=_i(i)),Fr(Ec([_i(df),_i(String(i.length)),i]))}var df,ff=P(()=>{ar();so();lf();df=`Ethereum Signed Message: +`});var pf,gf=P(()=>{pf="address/5.7.0"});function mf(i){wi(i,20)||vi.throwArgumentError("invalid address","address",i),i=i.toLowerCase();let e=i.substring(2).split(""),r=new Uint8Array(40);for(let s=0;s<40;s++)r[s]=e[s].charCodeAt(0);let t=ke(Fr(r));for(let s=0;s<40;s+=2)t[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(t[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}function kb(i){return Math.log10?Math.log10(i):Math.log(i)/Math.LN10}function Bb(i){i=i.toUpperCase(),i=i.substring(4)+i.substring(0,2)+"00";let e=i.split("").map(t=>xc[t]).join("");for(;e.length>=yf;){let t=e.substring(0,yf);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function wf(i){let e=null;if(typeof i!="string"&&vi.throwArgumentError("invalid address","address",i),i.match(/^(0x)?[0-9a-fA-F]{40}$/))i.substring(0,2)!=="0x"&&(i="0x"+i),e=mf(i),i.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==i&&vi.throwArgumentError("bad address checksum","address",i);else if(i.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(i.substring(2,4)!==Bb(i)&&vi.throwArgumentError("bad icap checksum","address",i),e=vc(i.substring(4));e.length<40;)e="0"+e;e=mf("0x"+e)}else vi.throwArgumentError("invalid address","address",i);return e}var vi,Fb,xc,yf,bf=P(()=>{"use strict";ar();nf();so();Mr();gf();vi=new Fe(pf);Fb=9007199254740991;xc={};for(let i=0;i<10;i++)xc[String(i)]=String(i);for(let i=0;i<26;i++)xc[String.fromCharCode(65+i)]=String(10+i);yf=Math.floor(kb(Fb))});var Ef=P(()=>{"use strict";ff()});var Tc,Ft,Be,Df,Tf,Rf,Ge,_f,ge,lo,Cf,Sc,co,qb,Ic,Si,hr,W,vf,We,kt,oo,Nf,Rc,Ii,Di,uo,Cc,xi,xf,fo,zb,Dc,Af,po,ho,Vb,Of,Sf,ao,Kb,Pf,Lf,Uf,Ti,ur,jb,If,$b,Nc=P(()=>{Tc=2n**256n,Ft=Tc-0x1000003d1n,Be=Tc-0x14551231950b75fc4402da1732fc9bebfn,Df=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Tf=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,Rf={p:Ft,n:Be,a:0n,b:7n,Gx:Df,Gy:Tf},Ge=32,_f=i=>W(W(i*i)*i+Rf.b),ge=(i="")=>{throw new Error(i)},lo=i=>typeof i=="bigint",Cf=i=>typeof i=="string",Sc=i=>lo(i)&&0nlo(i)&&0ni instanceof Uint8Array||i!=null&&typeof i=="object"&&i.constructor.name==="Uint8Array",Ic=(i,e)=>!qb(i)||typeof e=="number"&&e>0&&i.length!==e?ge("Uint8Array expected"):i,Si=i=>new Uint8Array(i),hr=(i,e)=>Ic(Cf(i)?Ii(i):Si(Ic(i)),e),W=(i,e=Ft)=>{let r=i%e;return r>=0n?r:e+r},vf=i=>i instanceof We?i:ge("Point expected"),We=class i{constructor(e,r,t){this.px=e,this.py=r,this.pz=t}static fromAffine(e){return e.x===0n&&e.y===0n?i.ZERO:new i(e.x,e.y,1n)}static fromHex(e){e=hr(e);let r,t=e[0],s=e.subarray(1),n=uo(s,0,Ge),o=e.length;if(o===33&&[2,3].includes(t)){Sc(n)||ge("Point hex invalid: x not FE");let a=zb(_f(n)),c=(a&1n)===1n;(t&1)===1!==c&&(a=W(-a)),r=new i(n,a,1n)}return o===65&&t===4&&(r=new i(n,uo(s,Ge,2*Ge),1n)),r?r.ok():ge("Point is not on curve")}static fromPrivateKey(e){return kt.mul(Dc(e))}get x(){return this.aff().x}get y(){return this.aff().y}equals(e){let{px:r,py:t,pz:s}=this,{px:n,py:o,pz:a}=vf(e),c=W(r*a),h=W(n*s),d=W(t*a),l=W(o*s);return c===h&&d===l}negate(){return new i(this.px,W(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:t,pz:s}=this,{px:n,py:o,pz:a}=vf(e),{a:c,b:h}=Rf,d=0n,l=0n,p=0n,f=W(h*3n),g=W(r*n),w=W(t*o),b=W(s*a),v=W(r+t),x=W(n+o);v=W(v*x),x=W(g+w),v=W(v-x),x=W(r+s);let I=W(n+a);return x=W(x*I),I=W(g+b),x=W(x-I),I=W(t+s),d=W(o+a),I=W(I*d),d=W(w+b),I=W(I-d),p=W(c*x),d=W(f*b),p=W(d+p),d=W(w-p),p=W(w+p),l=W(d*p),w=W(g+g),w=W(w+g),b=W(c*b),x=W(f*x),w=W(w+b),b=W(g-b),b=W(c*b),x=W(x+b),g=W(w*x),l=W(l+g),g=W(I*x),d=W(v*d),d=W(d-g),g=W(v*w),p=W(I*p),p=W(p+g),new i(d,l,p)}mul(e,r=!0){if(!r&&e===0n)return oo;if(co(e)||ge("invalid scalar"),this.equals(kt))return $b(e).p;let t=oo,s=kt;for(let n=this;e>0n;n=n.double(),e>>=1n)e&1n?t=t.add(n):r&&(s=s.add(n));return t}mulAddQUns(e,r,t){return this.mul(r,!1).add(e.mul(t,!1)).ok()}toAffine(){let{px:e,py:r,pz:t}=this;if(this.equals(oo))return{x:0n,y:0n};if(t===1n)return{x:e,y:r};let s=fo(t);return W(t*s)!==1n&&ge("invalid inverse"),{x:W(e*s),y:W(r*s)}}assertValidity(){let{x:e,y:r}=this.aff();return(!Sc(e)||!Sc(r))&&ge("Point invalid: x or y"),W(r*r)===_f(e)?this:ge("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:t}=this.aff();return(e?(t&1n)===0n?"02":"03":"04")+xi(r)+(e?"":xi(t))}toRawBytes(e=!0){return Ii(this.toHex(e))}};We.BASE=new We(Df,Tf,1n);We.ZERO=new We(0n,1n,0n);({BASE:kt,ZERO:oo}=We),Nf=(i,e)=>i.toString(16).padStart(e,"0"),Rc=i=>Array.from(i).map(e=>Nf(e,2)).join(""),Ii=i=>{let e=i.length;(!Cf(i)||e%2)&&ge("hex invalid 1");let r=Si(e/2);for(let t=0;tBigInt("0x"+(Rc(i)||"0")),uo=(i,e,r)=>Di(i.slice(e,r)),Cc=i=>lo(i)&&i>=0n&&iRc(Cc(i)),xf=(...i)=>{let e=Si(i.reduce((t,s)=>t+Ic(s).length,0)),r=0;return i.forEach(t=>{e.set(t,r),r+=t.length}),e},fo=(i,e=Ft)=>{(i===0n||e<=0n)&&ge("no inverse n="+i+" mod="+e);let r=W(i,e),t=e,s=0n,n=1n,o=1n,a=0n;for(;r!==0n;){let c=t/r,h=t%r,d=s-o*c,l=n-a*c;t=r,r=h,s=o,n=a,o=d,a=l}return t===1n?W(s,e):ge("no inverse")},zb=i=>{let e=1n;for(let r=i,t=(Ft+1n)/4n;t>0n;t>>=1n)t&1n&&(e=e*r%Ft),r=r*r%Ft;return W(e*e)===i?e:ge("sqrt invalid")},Dc=i=>(lo(i)||(i=Di(hr(i,Ge))),co(i)?i:ge("private key out of range")),Af=i=>i>Be>>1n,po=(i,e=!0)=>We.fromPrivateKey(i).toRawBytes(e),ho=class i{constructor(e,r,t){this.r=e,this.s=r,this.recovery=t,this.assertValidity()}static fromCompact(e){return e=hr(e,64),new i(uo(e,0,Ge),uo(e,Ge,2*Ge))}assertValidity(){return co(this.r)&&co(this.s)?this:ge()}addRecoveryBit(e){return new i(this.r,this.s,e)}hasHighS(){return Af(this.s)}normalizeS(){return this.hasHighS()?new i(this.r,W(this.s,Be),this.recovery):this}recoverPublicKey(e){let{r,s:t,recovery:s}=this;[0,1,2,3].includes(s)||ge("recovery id invalid");let n=Of(hr(e,Ge)),o=s===2||s===3?r+Be:r;o>=Ft&&ge("q.x invalid");let a=s&1?"03":"02",c=We.fromHex(a+xi(o)),h=fo(o,Be),d=W(-n*h,Be),l=W(t*h,Be);return kt.mulAddQUns(c,d,l)}toCompactRawBytes(){return Ii(this.toCompactHex())}toCompactHex(){return xi(this.r)+xi(this.s)}},Vb=i=>{let e=i.length*8-256,r=Di(i);return e>0?r>>BigInt(e):r},Of=i=>W(Vb(i),Be),Sf=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,Kb={lowS:!0},Pf=(i,e,r,t=Kb)=>{let{lowS:s}=t;s==null&&(s=!0),"strict"in t&&ge("verify() legacy options not supported");let n,o,a,c=i&&typeof i=="object"&&"r"in i;!c&&hr(i).length!==2*Ge&&ge("signature must be 64 bytes");try{n=c?new ho(i.r,i.s).assertValidity():ho.fromCompact(i),o=Of(hr(e)),a=r instanceof We?r.ok():We.fromHex(r)}catch{return!1}if(!n)return!1;let{r:h,s:d}=n;if(s&&Af(d))return!1;let l;try{let f=fo(d,Be),g=W(o*f,Be),w=W(h*f,Be);l=kt.mulAddQUns(a,g,w).aff()}catch{return!1}return l?W(l.x,Be)===h:!1},Lf=i=>{i=hr(i);let e=Ge+8;(i.length1024)&&ge("expected proper params");let r=W(Di(i),Be-1n)+1n;return Cc(r)},Uf={hexToBytes:Ii,bytesToHex:Rc,concatBytes:xf,bytesToNumberBE:Di,numberToBytesBE:Cc,mod:W,invert:fo,hmacSha256Async:async(i,...e)=>{let r=Sf(),t=r&&r.subtle;if(!t)return ge("etc.hmacSha256Async not set");let s=await t.importKey("raw",i,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Si(await t.sign("HMAC",s,xf(...e)))},hmacSha256Sync:ao,hashToPrivateKey:Lf,randomBytes:(i=32)=>{let e=Sf();return(!e||!e.getRandomValues)&&ge("crypto.getRandomValues must be defined"),e.getRandomValues(Si(i))}},Ti={normPrivateKeyToScalar:Dc,isValidPrivateKey:i=>{try{return!!Dc(i)}catch{return!1}},randomPrivateKey:()=>Lf(Uf.randomBytes(Ge+16)),precompute(i=8,e=kt){return e.multiply(3n),e}};Object.defineProperties(Uf,{hmacSha256Sync:{configurable:!1,get(){return ao},set(i){ao||(ao=i)}}});ur=8,jb=()=>{let i=[],e=256/ur+1,r=kt,t=r;for(let s=0;s{let e=If||(If=jb()),r=(d,l)=>{let p=l.negate();return d?p:l},t=oo,s=kt,n=1+256/ur,o=2**(ur-1),a=BigInt(2**ur-1),c=2**ur,h=BigInt(ur);for(let d=0;d>=h,p>o&&(p-=c,i+=1n);let f=l,g=l+Math.abs(p)-1,w=d%2!==0,b=p<0;p===0?s=s.add(r(w,e[f])):t=t.add(r(b,e[g]))}return{p:t,f:s}}});function Mf(i,e=!1){let r=po(ke(i),e);return bi(r)}function Ff(i,e,r){let t=new Uint8Array(64);t.set(ke(e.r),0),t.set(ke(e.s),32);let s=Ti.recoverPublicKey(ke(i),t,r,!1);return bi(s)}var kf=P(()=>{Nc();ar()});var Bf,qf=P(()=>{Bf="transactions/5.7.0"});function Gb(i){let e=Mf(i);return wf(io(Fr(io(e,1)),12))}function Vf(i,e){return Gb(Ff(ke(i),e))}var lI,zf,Kf=P(()=>{"use strict";bf();ar();so();kf();Mr();qf();lI=new Fe(Bf);(function(i){i[i.legacy=0]="legacy",i[i.eip2930=1]="eip2930",i[i.eip1559=2]="eip1559"})(zf||(zf={}))});var $f=oe(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Ne=Ir(),Ac=He(),Wb=20;function Jb(i,e,r){for(var t=1634760805,s=857760878,n=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],c=r[7]<<24|r[6]<<16|r[5]<<8|r[4],h=r[11]<<24|r[10]<<16|r[9]<<8|r[8],d=r[15]<<24|r[14]<<16|r[13]<<8|r[12],l=r[19]<<24|r[18]<<16|r[17]<<8|r[16],p=r[23]<<24|r[22]<<16|r[21]<<8|r[20],f=r[27]<<24|r[26]<<16|r[25]<<8|r[24],g=r[31]<<24|r[30]<<16|r[29]<<8|r[28],w=e[3]<<24|e[2]<<16|e[1]<<8|e[0],b=e[7]<<24|e[6]<<16|e[5]<<8|e[4],v=e[11]<<24|e[10]<<16|e[9]<<8|e[8],x=e[15]<<24|e[14]<<16|e[13]<<8|e[12],I=t,S=s,T=n,L=o,y=a,m=c,k=h,$=d,O=l,C=p,R=f,N=g,G=w,H=b,q=v,j=x,re=0;re>>16|G<<16,O=O+G|0,y^=O,y=y>>>20|y<<12,S=S+m|0,H^=S,H=H>>>16|H<<16,C=C+H|0,m^=C,m=m>>>20|m<<12,T=T+k|0,q^=T,q=q>>>16|q<<16,R=R+q|0,k^=R,k=k>>>20|k<<12,L=L+$|0,j^=L,j=j>>>16|j<<16,N=N+j|0,$^=N,$=$>>>20|$<<12,T=T+k|0,q^=T,q=q>>>24|q<<8,R=R+q|0,k^=R,k=k>>>25|k<<7,L=L+$|0,j^=L,j=j>>>24|j<<8,N=N+j|0,$^=N,$=$>>>25|$<<7,S=S+m|0,H^=S,H=H>>>24|H<<8,C=C+H|0,m^=C,m=m>>>25|m<<7,I=I+y|0,G^=I,G=G>>>24|G<<8,O=O+G|0,y^=O,y=y>>>25|y<<7,I=I+m|0,j^=I,j=j>>>16|j<<16,R=R+j|0,m^=R,m=m>>>20|m<<12,S=S+k|0,G^=S,G=G>>>16|G<<16,N=N+G|0,k^=N,k=k>>>20|k<<12,T=T+$|0,H^=T,H=H>>>16|H<<16,O=O+H|0,$^=O,$=$>>>20|$<<12,L=L+y|0,q^=L,q=q>>>16|q<<16,C=C+q|0,y^=C,y=y>>>20|y<<12,T=T+$|0,H^=T,H=H>>>24|H<<8,O=O+H|0,$^=O,$=$>>>25|$<<7,L=L+y|0,q^=L,q=q>>>24|q<<8,C=C+q|0,y^=C,y=y>>>25|y<<7,S=S+k|0,G^=S,G=G>>>24|G<<8,N=N+G|0,k^=N,k=k>>>25|k<<7,I=I+m|0,j^=I,j=j>>>24|j<<8,R=R+j|0,m^=R,m=m>>>25|m<<7;Ne.writeUint32LE(I+t|0,i,0),Ne.writeUint32LE(S+s|0,i,4),Ne.writeUint32LE(T+n|0,i,8),Ne.writeUint32LE(L+o|0,i,12),Ne.writeUint32LE(y+a|0,i,16),Ne.writeUint32LE(m+c|0,i,20),Ne.writeUint32LE(k+h|0,i,24),Ne.writeUint32LE($+d|0,i,28),Ne.writeUint32LE(O+l|0,i,32),Ne.writeUint32LE(C+p|0,i,36),Ne.writeUint32LE(R+f|0,i,40),Ne.writeUint32LE(N+g|0,i,44),Ne.writeUint32LE(G+w|0,i,48),Ne.writeUint32LE(H+b|0,i,52),Ne.writeUint32LE(q+v|0,i,56),Ne.writeUint32LE(j+x|0,i,60)}function jf(i,e,r,t,s){if(s===void 0&&(s=0),i.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(t.length>>=8,e++;if(t>0)throw new Error("ChaCha: counter overflow")}});var mo=oe(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});function Qb(i,e,r){return~(i-1)&e|i-1&r}kr.select=Qb;function Zb(i,e){return(i|0)-(e|0)-1>>>31&1}kr.lessOrEqual=Zb;function Hf(i,e){if(i.length!==e.length)return 0;for(var r=0,t=0;t>>8}kr.compare=Hf;function e1(i,e){return i.length===0||e.length===0?!1:Hf(i,e)!==0}kr.equal=e1});var Wf=oe(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});var t1=mo(),yo=He();xt.DIGEST_LENGTH=16;var Gf=function(){function i(e){this.digestLength=xt.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=e[0]|e[1]<<8;this._r[0]=r&8191;var t=e[2]|e[3]<<8;this._r[1]=(r>>>13|t<<3)&8191;var s=e[4]|e[5]<<8;this._r[2]=(t>>>10|s<<6)&7939;var n=e[6]|e[7]<<8;this._r[3]=(s>>>7|n<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(n>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=(o>>>14|a<<2)&8191;var c=e[12]|e[13]<<8;this._r[7]=(a>>>11|c<<5)&8065;var h=e[14]|e[15]<<8;this._r[8]=(c>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return i.prototype._blocks=function(e,r,t){for(var s=this._fin?0:2048,n=this._h[0],o=this._h[1],a=this._h[2],c=this._h[3],h=this._h[4],d=this._h[5],l=this._h[6],p=this._h[7],f=this._h[8],g=this._h[9],w=this._r[0],b=this._r[1],v=this._r[2],x=this._r[3],I=this._r[4],S=this._r[5],T=this._r[6],L=this._r[7],y=this._r[8],m=this._r[9];t>=16;){var k=e[r+0]|e[r+1]<<8;n+=k&8191;var $=e[r+2]|e[r+3]<<8;o+=(k>>>13|$<<3)&8191;var O=e[r+4]|e[r+5]<<8;a+=($>>>10|O<<6)&8191;var C=e[r+6]|e[r+7]<<8;c+=(O>>>7|C<<9)&8191;var R=e[r+8]|e[r+9]<<8;h+=(C>>>4|R<<12)&8191,d+=R>>>1&8191;var N=e[r+10]|e[r+11]<<8;l+=(R>>>14|N<<2)&8191;var G=e[r+12]|e[r+13]<<8;p+=(N>>>11|G<<5)&8191;var H=e[r+14]|e[r+15]<<8;f+=(G>>>8|H<<8)&8191,g+=H>>>5|s;var q=0,j=q;j+=n*w,j+=o*(5*m),j+=a*(5*y),j+=c*(5*L),j+=h*(5*T),q=j>>>13,j&=8191,j+=d*(5*S),j+=l*(5*I),j+=p*(5*x),j+=f*(5*v),j+=g*(5*b),q+=j>>>13,j&=8191;var re=q;re+=n*b,re+=o*w,re+=a*(5*m),re+=c*(5*y),re+=h*(5*L),q=re>>>13,re&=8191,re+=d*(5*T),re+=l*(5*S),re+=p*(5*I),re+=f*(5*x),re+=g*(5*v),q+=re>>>13,re&=8191;var Y=q;Y+=n*v,Y+=o*b,Y+=a*w,Y+=c*(5*m),Y+=h*(5*y),q=Y>>>13,Y&=8191,Y+=d*(5*L),Y+=l*(5*T),Y+=p*(5*S),Y+=f*(5*I),Y+=g*(5*x),q+=Y>>>13,Y&=8191;var Z=q;Z+=n*x,Z+=o*v,Z+=a*b,Z+=c*w,Z+=h*(5*m),q=Z>>>13,Z&=8191,Z+=d*(5*y),Z+=l*(5*L),Z+=p*(5*T),Z+=f*(5*S),Z+=g*(5*I),q+=Z>>>13,Z&=8191;var V=q;V+=n*I,V+=o*x,V+=a*v,V+=c*b,V+=h*w,q=V>>>13,V&=8191,V+=d*(5*m),V+=l*(5*y),V+=p*(5*L),V+=f*(5*T),V+=g*(5*S),q+=V>>>13,V&=8191;var J=q;J+=n*S,J+=o*I,J+=a*x,J+=c*v,J+=h*b,q=J>>>13,J&=8191,J+=d*w,J+=l*(5*m),J+=p*(5*y),J+=f*(5*L),J+=g*(5*T),q+=J>>>13,J&=8191;var X=q;X+=n*T,X+=o*S,X+=a*I,X+=c*x,X+=h*v,q=X>>>13,X&=8191,X+=d*b,X+=l*w,X+=p*(5*m),X+=f*(5*y),X+=g*(5*L),q+=X>>>13,X&=8191;var u=q;u+=n*L,u+=o*T,u+=a*S,u+=c*I,u+=h*x,q=u>>>13,u&=8191,u+=d*v,u+=l*b,u+=p*w,u+=f*(5*m),u+=g*(5*y),q+=u>>>13,u&=8191;var E=q;E+=n*y,E+=o*L,E+=a*T,E+=c*S,E+=h*I,q=E>>>13,E&=8191,E+=d*x,E+=l*v,E+=p*b,E+=f*w,E+=g*(5*m),q+=E>>>13,E&=8191;var _=q;_+=n*m,_+=o*y,_+=a*L,_+=c*T,_+=h*S,q=_>>>13,_&=8191,_+=d*I,_+=l*x,_+=p*v,_+=f*b,_+=g*w,q+=_>>>13,_&=8191,q=(q<<2)+q|0,q=q+j|0,j=q&8191,q=q>>>13,re+=q,n=j,o=re,a=Y,c=Z,h=V,d=J,l=X,p=u,f=E,g=_,r+=16,t-=16}this._h[0]=n,this._h[1]=o,this._h[2]=a,this._h[3]=c,this._h[4]=h,this._h[5]=d,this._h[6]=l,this._h[7]=p,this._h[8]=f,this._h[9]=g},i.prototype.finish=function(e,r){r===void 0&&(r=0);var t=new Uint16Array(10),s,n,o,a;if(this._leftover){for(a=this._leftover,this._buffer[a++]=1;a<16;a++)this._buffer[a]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(s=this._h[1]>>>13,this._h[1]&=8191,a=2;a<10;a++)this._h[a]+=s,s=this._h[a]>>>13,this._h[a]&=8191;for(this._h[0]+=s*5,s=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=s,s=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=s,t[0]=this._h[0]+5,s=t[0]>>>13,t[0]&=8191,a=1;a<10;a++)t[a]=this._h[a]+s,s=t[a]>>>13,t[a]&=8191;for(t[9]-=8192,n=(s^1)-1,a=0;a<10;a++)t[a]&=n;for(n=~n,a=0;a<10;a++)this._h[a]=this._h[a]&n|t[a];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,a=1;a<8;a++)o=(this._h[a]+this._pad[a]|0)+(o>>>16)|0,this._h[a]=o&65535;return e[r+0]=this._h[0]>>>0,e[r+1]=this._h[0]>>>8,e[r+2]=this._h[1]>>>0,e[r+3]=this._h[1]>>>8,e[r+4]=this._h[2]>>>0,e[r+5]=this._h[2]>>>8,e[r+6]=this._h[3]>>>0,e[r+7]=this._h[3]>>>8,e[r+8]=this._h[4]>>>0,e[r+9]=this._h[4]>>>8,e[r+10]=this._h[5]>>>0,e[r+11]=this._h[5]>>>8,e[r+12]=this._h[6]>>>0,e[r+13]=this._h[6]>>>8,e[r+14]=this._h[7]>>>0,e[r+15]=this._h[7]>>>8,this._finished=!0,this},i.prototype.update=function(e){var r=0,t=e.length,s;if(this._leftover){s=16-this._leftover,s>t&&(s=t);for(var n=0;n=16&&(s=t-t%16,this._blocks(e,r,s),r+=s,t-=s),t){for(var n=0;n{"use strict";Object.defineProperty(St,"__esModule",{value:!0});var wo=$f(),s1=Wf(),Ri=He(),Jf=Ir(),n1=mo();St.KEY_LENGTH=32;St.NONCE_LENGTH=12;St.TAG_LENGTH=16;var Yf=new Uint8Array(16),o1=function(){function i(e){if(this.nonceLength=St.NONCE_LENGTH,this.tagLength=St.TAG_LENGTH,e.length!==St.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return i.prototype.seal=function(e,r,t,s){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var n=new Uint8Array(16);n.set(e,n.length-e.length);var o=new Uint8Array(32);wo.stream(this._key,n,o,4);var a=r.length+this.tagLength,c;if(s){if(s.length!==a)throw new Error("ChaCha20Poly1305: incorrect destination length");c=s}else c=new Uint8Array(a);return wo.streamXOR(this._key,n,r,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),o,c.subarray(0,c.length-this.tagLength),t),Ri.wipe(n),c},i.prototype.open=function(e,r,t,s){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(r.length0&&n.update(Yf.subarray(s.length%16))),n.update(t),t.length%16>0&&n.update(Yf.subarray(t.length%16));var o=new Uint8Array(8);s&&Jf.writeUint64LE(s.length,o),n.update(o),Jf.writeUint64LE(t.length,o),n.update(o);for(var a=n.digest(),c=0;c{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function a1(i){return typeof i.saveState<"u"&&typeof i.restoreState<"u"&&typeof i.cleanSavedState<"u"}Oc.isSerializableHash=a1});var ep=oe(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});var lt=Qf(),c1=mo(),u1=He(),Zf=function(){function i(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var t=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(t).clean():t.set(r);for(var s=0;s{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var tp=ep(),rp=He(),l1=function(){function i(e,r,t,s){t===void 0&&(t=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=s;var n=tp.hmac(this._hash,t,r);this._hmac=new tp.HMAC(e,n),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return i.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},i.prototype.expand=function(e){for(var r=new Uint8Array(e),t=0;t{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});var Eo=Ir(),bo=He();Bt.DIGEST_LENGTH=32;Bt.BLOCK_SIZE=64;var sp=function(){function i(){this.digestLength=Bt.DIGEST_LENGTH,this.blockSize=Bt.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return i.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},i.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},i.prototype.clean=function(){bo.wipe(this._buffer),bo.wipe(this._temp),this.reset()},i.prototype.update=function(e,r){if(r===void 0&&(r=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var t=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[t++],r--;this._bufferLength===this.blockSize&&(Lc(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(t=Lc(this._temp,this._state,e,t,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=e[t++],r--;return this},i.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,t=this._bufferLength,s=r/536870912|0,n=r<<3,o=r%64<56?64:128;this._buffer[t]=128;for(var a=t+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},i.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},i.prototype.cleanSavedState=function(e){bo.wipe(e.state),e.buffer&&bo.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},i}();Bt.SHA256=sp;var d1=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Lc(i,e,r,t,s){for(;s>=64;){for(var n=e[0],o=e[1],a=e[2],c=e[3],h=e[4],d=e[5],l=e[6],p=e[7],f=0;f<16;f++){var g=t+f*4;i[f]=Eo.readUint32BE(r,g)}for(var f=16;f<64;f++){var w=i[f-2],b=(w>>>17|w<<15)^(w>>>19|w<<13)^w>>>10;w=i[f-15];var v=(w>>>7|w<<25)^(w>>>18|w<<14)^w>>>3;i[f]=(b+i[f-7]|0)+(v+i[f-16]|0)}for(var f=0;f<64;f++){var b=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&d^~h&l)|0)+(p+(d1[f]+i[f]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&o^n&a^o&a)|0;p=l,l=d,d=h,h=c+b|0,c=a,a=o,o=n,n=b+v|0}e[0]+=n,e[1]+=o,e[2]+=a,e[3]+=c,e[4]+=h,e[5]+=d,e[6]+=l,e[7]+=p,t+=64,s-=64}return t}function f1(i){var e=new sp;e.update(i);var r=e.digest();return e.clean(),r}Bt.hash=f1});var up=oe(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.sharedKey=be.generateKeyPair=be.generateKeyPairFromSeed=be.scalarMultBase=be.scalarMult=be.SHARED_KEY_LENGTH=be.SECRET_KEY_LENGTH=be.PUBLIC_KEY_LENGTH=void 0;var p1=ni(),g1=He();be.PUBLIC_KEY_LENGTH=32;be.SECRET_KEY_LENGTH=32;be.SHARED_KEY_LENGTH=32;function dt(i){let e=new Float64Array(16);if(i)for(let r=0;r>16&1),r[o-1]&=65535;r[15]=t[15]-32767-(r[14]>>16&1);let n=r[15]>>16&1;r[14]&=65535,Ni(t,r,1-n)}for(let s=0;s<16;s++)i[2*s]=t[s]&255,i[2*s+1]=t[s]>>8}function w1(i,e){for(let r=0;r<16;r++)i[r]=e[2*r]+(e[2*r+1]<<8);i[15]&=32767}function _o(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]+r[t]}function vo(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]-r[t]}function It(i,e,r){let t,s,n=0,o=0,a=0,c=0,h=0,d=0,l=0,p=0,f=0,g=0,w=0,b=0,v=0,x=0,I=0,S=0,T=0,L=0,y=0,m=0,k=0,$=0,O=0,C=0,R=0,N=0,G=0,H=0,q=0,j=0,re=0,Y=r[0],Z=r[1],V=r[2],J=r[3],X=r[4],u=r[5],E=r[6],_=r[7],D=r[8],A=r[9],U=r[10],F=r[11],M=r[12],Q=r[13],z=r[14],ee=r[15];t=e[0],n+=t*Y,o+=t*Z,a+=t*V,c+=t*J,h+=t*X,d+=t*u,l+=t*E,p+=t*_,f+=t*D,g+=t*A,w+=t*U,b+=t*F,v+=t*M,x+=t*Q,I+=t*z,S+=t*ee,t=e[1],o+=t*Y,a+=t*Z,c+=t*V,h+=t*J,d+=t*X,l+=t*u,p+=t*E,f+=t*_,g+=t*D,w+=t*A,b+=t*U,v+=t*F,x+=t*M,I+=t*Q,S+=t*z,T+=t*ee,t=e[2],a+=t*Y,c+=t*Z,h+=t*V,d+=t*J,l+=t*X,p+=t*u,f+=t*E,g+=t*_,w+=t*D,b+=t*A,v+=t*U,x+=t*F,I+=t*M,S+=t*Q,T+=t*z,L+=t*ee,t=e[3],c+=t*Y,h+=t*Z,d+=t*V,l+=t*J,p+=t*X,f+=t*u,g+=t*E,w+=t*_,b+=t*D,v+=t*A,x+=t*U,I+=t*F,S+=t*M,T+=t*Q,L+=t*z,y+=t*ee,t=e[4],h+=t*Y,d+=t*Z,l+=t*V,p+=t*J,f+=t*X,g+=t*u,w+=t*E,b+=t*_,v+=t*D,x+=t*A,I+=t*U,S+=t*F,T+=t*M,L+=t*Q,y+=t*z,m+=t*ee,t=e[5],d+=t*Y,l+=t*Z,p+=t*V,f+=t*J,g+=t*X,w+=t*u,b+=t*E,v+=t*_,x+=t*D,I+=t*A,S+=t*U,T+=t*F,L+=t*M,y+=t*Q,m+=t*z,k+=t*ee,t=e[6],l+=t*Y,p+=t*Z,f+=t*V,g+=t*J,w+=t*X,b+=t*u,v+=t*E,x+=t*_,I+=t*D,S+=t*A,T+=t*U,L+=t*F,y+=t*M,m+=t*Q,k+=t*z,$+=t*ee,t=e[7],p+=t*Y,f+=t*Z,g+=t*V,w+=t*J,b+=t*X,v+=t*u,x+=t*E,I+=t*_,S+=t*D,T+=t*A,L+=t*U,y+=t*F,m+=t*M,k+=t*Q,$+=t*z,O+=t*ee,t=e[8],f+=t*Y,g+=t*Z,w+=t*V,b+=t*J,v+=t*X,x+=t*u,I+=t*E,S+=t*_,T+=t*D,L+=t*A,y+=t*U,m+=t*F,k+=t*M,$+=t*Q,O+=t*z,C+=t*ee,t=e[9],g+=t*Y,w+=t*Z,b+=t*V,v+=t*J,x+=t*X,I+=t*u,S+=t*E,T+=t*_,L+=t*D,y+=t*A,m+=t*U,k+=t*F,$+=t*M,O+=t*Q,C+=t*z,R+=t*ee,t=e[10],w+=t*Y,b+=t*Z,v+=t*V,x+=t*J,I+=t*X,S+=t*u,T+=t*E,L+=t*_,y+=t*D,m+=t*A,k+=t*U,$+=t*F,O+=t*M,C+=t*Q,R+=t*z,N+=t*ee,t=e[11],b+=t*Y,v+=t*Z,x+=t*V,I+=t*J,S+=t*X,T+=t*u,L+=t*E,y+=t*_,m+=t*D,k+=t*A,$+=t*U,O+=t*F,C+=t*M,R+=t*Q,N+=t*z,G+=t*ee,t=e[12],v+=t*Y,x+=t*Z,I+=t*V,S+=t*J,T+=t*X,L+=t*u,y+=t*E,m+=t*_,k+=t*D,$+=t*A,O+=t*U,C+=t*F,R+=t*M,N+=t*Q,G+=t*z,H+=t*ee,t=e[13],x+=t*Y,I+=t*Z,S+=t*V,T+=t*J,L+=t*X,y+=t*u,m+=t*E,k+=t*_,$+=t*D,O+=t*A,C+=t*U,R+=t*F,N+=t*M,G+=t*Q,H+=t*z,q+=t*ee,t=e[14],I+=t*Y,S+=t*Z,T+=t*V,L+=t*J,y+=t*X,m+=t*u,k+=t*E,$+=t*_,O+=t*D,C+=t*A,R+=t*U,N+=t*F,G+=t*M,H+=t*Q,q+=t*z,j+=t*ee,t=e[15],S+=t*Y,T+=t*Z,L+=t*V,y+=t*J,m+=t*X,k+=t*u,$+=t*E,O+=t*_,C+=t*D,R+=t*A,N+=t*U,G+=t*F,H+=t*M,q+=t*Q,j+=t*z,re+=t*ee,n+=38*T,o+=38*L,a+=38*y,c+=38*m,h+=38*k,d+=38*$,l+=38*O,p+=38*C,f+=38*R,g+=38*N,w+=38*G,b+=38*H,v+=38*q,x+=38*j,I+=38*re,s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),i[0]=n,i[1]=o,i[2]=a,i[3]=c,i[4]=h,i[5]=d,i[6]=l,i[7]=p,i[8]=f,i[9]=g,i[10]=w,i[11]=b,i[12]=v,i[13]=x,i[14]=I,i[15]=S}function Ai(i,e){It(i,e,e)}function b1(i,e){let r=dt();for(let t=0;t<16;t++)r[t]=e[t];for(let t=253;t>=0;t--)Ai(r,r),t!==2&&t!==4&&It(r,r,e);for(let t=0;t<16;t++)i[t]=r[t]}function Mc(i,e){let r=new Uint8Array(32),t=new Float64Array(80),s=dt(),n=dt(),o=dt(),a=dt(),c=dt(),h=dt();for(let f=0;f<31;f++)r[f]=i[f];r[31]=i[31]&127|64,r[0]&=248,w1(t,e);for(let f=0;f<16;f++)n[f]=t[f];s[0]=a[0]=1;for(let f=254;f>=0;--f){let g=r[f>>>3]>>>(f&7)&1;Ni(s,n,g),Ni(o,a,g),_o(c,s,o),vo(s,s,o),_o(o,n,a),vo(n,n,a),Ai(a,c),Ai(h,s),It(s,o,s),It(o,n,c),_o(c,s,o),vo(s,s,o),Ai(n,s),vo(o,a,h),It(s,o,m1),_o(s,s,a),It(o,o,s),It(s,a,h),It(a,n,t),Ai(n,c),Ni(s,n,g),Ni(o,a,g)}for(let f=0;f<16;f++)t[f+16]=s[f],t[f+32]=o[f],t[f+48]=n[f],t[f+64]=a[f];let d=t.subarray(32),l=t.subarray(16);b1(d,d),It(l,l,d);let p=new Uint8Array(32);return y1(p,l),p}be.scalarMult=Mc;function ap(i){return Mc(i,op)}be.scalarMultBase=ap;function cp(i){if(i.length!==be.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${be.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(i);return{publicKey:ap(e),secretKey:e}}be.generateKeyPairFromSeed=cp;function E1(i){let e=(0,p1.randomBytes)(32,i),r=cp(e);return(0,g1.wipe)(e),r}be.generateKeyPair=E1;function _1(i,e,r=!1){if(i.length!==be.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==be.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let t=Mc(i,e);if(r){let s=0;for(let n=0;n{});var lp=P(()=>{});var dp=P(()=>{Kn()});var Fc=P(()=>{hp();Ba();lp();dc();lc();dp()});var kc,fp,pp=P(()=>{Nc();kc=class{constructor(e){if(e!=="secp256k1")throw new Error("Only secp256k1 is supported")}keyFromPrivate(e){let r=typeof e=="string"?Ti.hexToBytes(e.replace("0x","")):e;return{getPublic:(t=!1)=>{let s=po(r);return{encode:n=>s}}}}keyFromPublic(e){let r=typeof e=="string"?Ti.hexToBytes(e.replace("0x","")):e;return{verify:async(t,s)=>Pf(s,t,r)}}},fp=kc});var gp,mp=P(()=>{gp={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}}});function Ui(i){let[e,r]=i.split(v1);return{namespace:e,reference:r}}function Np(i,e){return i.includes(":")?[i]:e.chains||[]}function Mi(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function fr(){return!(0,Tt.getDocument)()&&!!(0,Tt.getNavigator)()&&navigator.product===D1}function qr(){return!Mi()&&!!(0,Tt.getNavigator)()&&!!(0,Tt.getDocument)()}function Fi(){return fr()?qe.reactNative:Mi()?qe.node:qr()?qe.browser:qe.unknown}function Ap(){var i;try{return fr()&&typeof window<"u"&&typeof window?.Application<"u"?(i=window.Application)==null?void 0:i.applicationId:void 0}catch{return}}function R1(i,e){let r=gc(i);return r=bp(bp({},r),e),i=mc(r),i}function zr(){return(0,Rp.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function C1(){if(Fi()===qe.reactNative&&typeof window<"u"&&typeof window?.Platform<"u"){let{OS:r,Version:t}=window.Platform;return[r,t].join("-")}let i=Ld();if(i===null)return"unknown";let e=i.os?i.os.replace(" ","").toLowerCase():"unknown";return i.type==="browser"?[e,i.name,i.version].join("-"):[e,i.version].join("-")}function N1(){var i;let e=Fi();return e===qe.browser?[e,((i=(0,Tt.getLocation)())==null?void 0:i.host)||"unknown"].join(":"):e}function zc(i,e,r){let t=C1(),s=N1();return[[i,e].join("-"),[T1,r].join("-"),t,s].join("/")}function Op({protocol:i,version:e,relayUrl:r,sdkVersion:t,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a}){let c=r.split("?"),h=zc(i,e,t),d={auth:s,ua:h,projectId:n,useOnCloseEvent:o||void 0,origin:a||void 0},l=R1(c[1]||"",d);return c[0]+"?"+l}function lr(i,e){return i.filter(r=>e.includes(r)).length===i.length}function Vc(i){return Object.fromEntries(i.entries())}function Kc(i){return new Map(Object.entries(i))}function Rt(i=Dt.FIVE_MINUTES,e){let r=(0,Dt.toMiliseconds)(i||Dt.FIVE_MINUTES),t,s,n;return{resolve:o=>{n&&t&&(clearTimeout(n),t(o))},reject:o=>{n&&s&&(clearTimeout(n),s(o))},done:()=>new Promise((o,a)=>{n=setTimeout(()=>{a(new Error(e))},r),t=o,s=a})}}function pr(i,e,r){return new Promise(async(t,s)=>{let n=setTimeout(()=>s(new Error(r)),e);try{let o=await i;t(o)}catch(o){s(o)}clearTimeout(n)})}function Pp(i,e){if(typeof e=="string"&&e.startsWith(`${i}:`))return e;if(i.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(i.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${i}`)}function Lp(i){return Pp("topic",i)}function Up(i){return Pp("id",i)}function Io(i){let[e,r]=i.split(":"),t={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")t.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))t.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return t}function ve(i,e){return(0,Dt.fromMiliseconds)((e||Date.now())+(0,Dt.toMiliseconds)(i))}function ft(i){return Date.now()>=(0,Dt.toMiliseconds)(i)}function se(i,e){return`${i}${e?`:${e}`:""}`}function A1(i=[],e=[]){return[...new Set([...i,...e])]}async function Mp({id:i,topic:e,wcDeepLink:r}){var t;try{if(!r)return;let s=typeof r=="string"?JSON.parse(r):r,n=s?.href;if(typeof n!="string")return;let o=O1(n,i,e),a=Fi();if(a===qe.browser){if(!((t=(0,Tt.getDocument)())!=null&&t.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,P1()?"_blank":"_self","noreferrer noopener")}else a===qe.reactNative&&typeof window?.Linking<"u"&&await window.Linking.openURL(o)}catch(s){console.error(s)}}function O1(i,e,r){let t=`requestId=${e}&sessionTopic=${r}`;i.endsWith("/")&&(i=i.slice(0,-1));let s=`${i}`;if(i.startsWith("https://t.me")){let n=i.includes("?")?"&startapp=":"?startapp=";s=`${s}${n}${L1(t,!0)}`}else s=`${s}/wc?${t}`;return s}async function Fp(i,e){let r="";try{if(qr()&&(r=localStorage.getItem(e),r))return r;r=await i.getItem(e)}catch(t){console.error(t)}return r}function jc(i,e){if(!i.includes(e))return null;let r=i.split(/([&,?,=])/),t=r.indexOf(e);return r[t+2]}function $c(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,i=>{let e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}function ki(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function P1(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function L1(i,e=!1){let r=Buffer.from(i).toString("base64");return e?r.replace(/[=]/g,""):r}function kp(i){return Buffer.from(i,"base64").toString("utf-8")}async function M1(i,e,r,t,s,n){switch(r.t){case"eip191":return F1(i,e,r.s);case"eip1271":return await k1(i,e,r.s,t,s,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function F1(i,e,r){return Vf(no(e),r).toLowerCase()===i.toLowerCase()}async function k1(i,e,r,t,s,n){let o=Ui(t);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${t}`);try{let a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",d=r.substring(2),l=no(e).substring(2),p=a+l+c+h+d,f=await fetch(`${n||U1}/?chainId=${t}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:B1(),jsonrpc:"2.0",method:"eth_call",params:[{to:i,data:p},"latest"]})}),{result:g}=await f.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function B1(){return Date.now()+Math.floor(Math.random()*1e3)}async function Gc(i){let{cacao:e,projectId:r}=i,{s:t,p:s}=e,n=Wc(s,s.iss),o=Bi(s.iss);return await M1(o,n,t,Do(s.iss),r)}function J1(i){return Buffer.from(JSON.stringify(i)).toString("base64")}function Y1(i){return JSON.parse(Buffer.from(i,"base64").toString("utf-8"))}function dr(i){if(!i)throw new Error("No recap provided, value is undefined");if(!i.att)throw new Error("No `att` property found");let e=Object.keys(i.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{let t=i.att[r];if(Array.isArray(t))throw new Error(`Resource must be an object: ${r}`);if(typeof t!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(t).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(t).forEach(s=>{let n=t[s];if(!Array.isArray(n))throw new Error(`Ability limits ${s} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${o}`)})})})}function X1(i,e,r,t={}){return r?.sort((s,n)=>s.localeCompare(n)),{att:{[i]:Q1(e,r,t)}}}function Q1(i,e,r={}){e=e?.sort((s,n)=>s.localeCompare(n));let t=e.map(s=>({[`${i}/${s}`]:[r]}));return Object.assign({},...t)}function Bp(i){return dr(i),`urn:recap:${J1(i).replace(/=/g,"")}`}function Pi(i){let e=Y1(i.replace("urn:recap:",""));return dr(e),e}function qp(i,e,r){let t=X1(i,e,r);return Bp(t)}function Z1(i){return i&&i.includes("urn:recap:")}function zp(i,e){let r=Pi(i),t=Pi(e),s=eE(r,t);return Bp(s)}function eE(i,e){dr(i),dr(e);let r=Object.keys(i.att).concat(Object.keys(e.att)).sort((s,n)=>s.localeCompare(n)),t={att:{}};return r.forEach(s=>{var n,o;Object.keys(((n=i.att)==null?void 0:n[s])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[s])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,h;t.att[s]=H1($1({},t.att[s]),{[a]:((c=i.att[s])==null?void 0:c[a])||((h=e.att[s])==null?void 0:h[a])})})}),t}function tE(i="",e){dr(e);let r="I further authorize the stated URI to perform the following actions on my behalf: ";if(i.includes(r))return i;let t=[],s=0;Object.keys(e.att).forEach(a=>{let c=Object.keys(e.att[a]).map(l=>({ability:l.split("/")[0],action:l.split("/")[1]}));c.sort((l,p)=>l.action.localeCompare(p.action));let h={};c.forEach(l=>{h[l.ability]||(h[l.ability]=[]),h[l.ability].push(l.action)});let d=Object.keys(h).map(l=>(s++,`(${s}) '${l}': '${h[l].join("', '")}' for '${a}'.`));t.push(d.join(", ").replace(".,","."))});let n=t.join(" "),o=`${r}${n}`;return`${i?i+" ":""}${o}`}function Jc(i){var e;let r=Pi(i);dr(r);let t=(e=r.att)==null?void 0:e.eip155;return t?Object.keys(t).map(s=>s.split("/")[1]):[]}function Yc(i){let e=Pi(i);dr(e);let r=[];return Object.values(e.att).forEach(t=>{Object.values(t).forEach(s=>{var n;(n=s?.[0])!=null&&n.chains&&r.push(s[0].chains)})}),[...new Set(r.flat())]}function qi(i){if(!i)return;let e=i?.[i.length-1];return Z1(e)?e:void 0}function jp(){let i=So.generateKeyPair();return{privateKey:we(i.secretKey,Ae),publicKey:we(i.publicKey,Ae)}}function To(){let i=(0,Li.randomBytes)(Xc);return we(i,Ae)}function $p(i,e){let r=So.sharedKey(_e(i,Ae),_e(e,Ae),!0),t=new Cp.HKDF(Br.SHA256,r).expand(Xc);return we(t,Ae)}function jr(i){let e=(0,Br.hash)(_e(i,Ae));return we(e,Ae)}function rt(i){let e=(0,Br.hash)(_e(i,zi));return we(e,Ae)}function Hp(i){return _e(`${i}`,Vp)}function qt(i){return Number(we(i,Vp))}function Gp(i){let e=Hp(typeof i.type<"u"?i.type:Kp);if(qt(e)===tt&&typeof i.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let r=typeof i.senderPublicKey<"u"?_e(i.senderPublicKey,Ae):void 0,t=typeof i.iv<"u"?_e(i.iv,Ae):(0,Li.randomBytes)(Oi),s=new qc.ChaCha20Poly1305(_e(i.symKey,Ae)).seal(t,_e(i.message,zi));return Xp({type:e,sealed:s,iv:t,senderPublicKey:r,encoding:i.encoding})}function Wp(i,e){let r=Hp(Kr),t=(0,Li.randomBytes)(Oi),s=_e(i,zi);return Xp({type:r,sealed:s,iv:t,encoding:e})}function Jp(i){let e=new qc.ChaCha20Poly1305(_e(i.symKey,Ae)),{sealed:r,iv:t}=$r({encoded:i.encoded,encoding:i?.encoding}),s=e.open(t,r);if(s===null)throw new Error("Failed to decrypt");return we(s,zi)}function Yp(i,e){let{sealed:r}=$r({encoded:i,encoding:e});return we(r,zi)}function Xp(i){let{encoding:e=pt}=i;if(qt(i.type)===Kr)return we(ir([i.type,i.sealed]),e);if(qt(i.type)===tt){if(typeof i.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return we(ir([i.type,i.senderPublicKey,i.iv,i.sealed]),e)}return we(ir([i.type,i.iv,i.sealed]),e)}function $r(i){let{encoded:e,encoding:r=pt}=i,t=_e(e,r),s=t.slice(rE,vp),n=vp;if(qt(s)===tt){let h=n+Xc,d=h+Oi,l=t.slice(n,h),p=t.slice(h,d),f=t.slice(d);return{type:s,sealed:f,iv:p,senderPublicKey:l}}if(qt(s)===Kr){let h=t.slice(n),d=(0,Li.randomBytes)(Oi);return{type:s,sealed:h,iv:d}}let o=n+Oi,a=t.slice(n,o),c=t.slice(o);return{type:s,sealed:c,iv:a}}function Qp(i,e){let r=$r({encoded:i,encoding:e?.encoding});return Qc({type:qt(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?we(r.senderPublicKey,Ae):void 0,receiverPublicKey:e?.receiverPublicKey})}function Qc(i){let e=i?.type||Kp;if(e===tt){if(typeof i?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof i?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:i?.senderPublicKey,receiverPublicKey:i?.receiverPublicKey}}function Zc(i){return i.type===tt&&typeof i.senderPublicKey=="string"&&typeof i.receiverPublicKey=="string"}function eu(i){return i.type===Kr}function iE(i){return new fp("p256").keyFromPublic({x:Buffer.from(i.x,"base64").toString("hex"),y:Buffer.from(i.y,"base64").toString("hex")},"hex")}function sE(i){let e=i.replace(/-/g,"+").replace(/_/g,"/"),r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function nE(i){return Buffer.from(sE(i),"base64")}function Zp(i,e){let[r,t,s]=i.split("."),n=nE(s);if(n.length!==64)throw new Error("Invalid signature length");let o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),c=`${r}.${t}`,h=new Br.SHA256().update(Buffer.from(c)).digest(),d=iE(e),l=Buffer.from(h).toString("hex");if(!d.verify(l,{r:o,s:a}))throw new Error("Invalid signature");return Lr(i).payload}function Ro(i){return i?.relay||{protocol:oE}}function Hr(i){let e=gp[i];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${i}`);return e}function fE(i,e="-"){let r={},t="relay"+e;return Object.keys(i).forEach(s=>{if(s.startsWith(t)){let n=s.replace(t,""),o=i[s];r[n]=o}}),r}function tu(i){if(!i.includes("wc:")){let c=kp(i);c!=null&&c.includes("wc:")&&(i=c)}i=i.includes("wc://")?i.replace("wc://",""):i,i=i.includes("wc:")?i.replace("wc:",""):i;let e=i.indexOf(":"),r=i.indexOf("?")!==-1?i.indexOf("?"):void 0,t=i.substring(0,e),s=i.substring(e+1,r).split("@"),n=typeof r<"u"?i.substring(r):"",o=gc(n),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:t,topic:pE(s[0]),version:parseInt(s[1],10),symKey:o.symKey,relay:fE(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function pE(i){return i.startsWith("//")?i.substring(2):i}function gE(i,e="-"){let r="relay",t={};return Object.keys(i).forEach(s=>{let n=r+e+s;i[s]&&(t[n]=i[s])}),t}function ru(i){return`${i.protocol}:${i.topic}@${i.version}?`+mc(Ip(dE(Ip({symKey:i.symKey},gE(i.relay)),{expiryTimestamp:i.expiryTimestamp}),i.methods?{methods:i.methods.join(",")}:{}))}function Vi(i,e,r){return`${i}?wc_ev=${r}&topic=${e}`}function Gr(i){let e=[];return i.forEach(r=>{let[t,s]=r.split(":");e.push(`${t}:${s}`)}),e}function mE(i){let e=[];return Object.values(i).forEach(r=>{e.push(...Gr(r.accounts))}),e}function yE(i,e){let r=[];return Object.values(i).forEach(t=>{Gr(t.accounts).includes(e)&&r.push(...t.methods)}),r}function wE(i,e){let r=[];return Object.values(i).forEach(t=>{Gr(t.accounts).includes(e)&&r.push(...t.events)}),r}function bE(i){let e={};return i?.forEach(r=>{let[t,s]=r.split(":");e[t]||(e[t]={accounts:[],chains:[],events:[]}),e[t].accounts.push(r),e[t].chains.push(`${t}:${s}`)}),e}function iu(i,e){e=e.map(t=>t.replace("did:pkh:",""));let r=bE(e);for(let[t,s]of Object.entries(r))s.methods?s.methods=A1(s.methods,i):s.methods=i,s.events=["chainChanged","accountsChanged"];return r}function B(i,e){let{message:r,code:t}=_E[i];return{message:e?`${r} ${e}`:r,code:t}}function ce(i,e){let{message:r,code:t}=EE[i];return{message:e?`${r} ${e}`:r,code:t}}function Vt(i,e){return Array.isArray(i)?typeof e<"u"&&i.length?i.every(e):!0:!1}function Ki(i){return Object.getPrototypeOf(i)===Object.prototype&&Object.keys(i).length}function De(i){return typeof i>"u"}function me(i,e){return e&&De(i)?!0:typeof i=="string"&&!!i.trim().length}function su(i,e){return e&&De(i)?!0:typeof i=="number"&&!isNaN(i)}function eg(i,e){let{requiredNamespaces:r}=e,t=Object.keys(i.namespaces),s=Object.keys(r),n=!0;return lr(s,t)?(t.forEach(o=>{let{accounts:a,methods:c,events:h}=i.namespaces[o],d=Gr(a),l=r[o];(!lr(Np(o,l),d)||!lr(l.methods,c)||!lr(l.events,h))&&(n=!1)}),n):!1}function xo(i){return me(i,!1)&&i.includes(":")?i.split(":").length===2:!1}function vE(i){if(me(i,!1)&&i.includes(":")){let e=i.split(":");if(e.length===3){let r=e[0]+":"+e[1];return!!e[2]&&xo(r)}}return!1}function tg(i){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(me(i,!1)){if(e(i))return!0;let r=kp(i);return e(r)}}catch{}return!1}function rg(i){var e;return(e=i?.proposer)==null?void 0:e.publicKey}function ig(i){return i?.topic}function sg(i,e){let r=null;return me(i?.publicKey,!1)||(r=B("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Dp(i){let e=!0;return Vt(i)?i.length&&(e=i.every(r=>me(r,!1))):e=!1,e}function xE(i,e,r){let t=null;return Vt(e)&&e.length?e.forEach(s=>{t||xo(s)||(t=ce("UNSUPPORTED_CHAINS",`${r}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):xo(i)||(t=ce("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),t}function SE(i,e,r){let t=null;return Object.entries(i).forEach(([s,n])=>{if(t)return;let o=xE(s,Np(s,n),`${e} ${r}`);o&&(t=o)}),t}function IE(i,e){let r=null;return Vt(i)?i.forEach(t=>{r||vE(t)||(r=ce("UNSUPPORTED_ACCOUNTS",`${e}, account ${t} should be a string and conform to "namespace:chainId:address" format`))}):r=ce("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function DE(i,e){let r=null;return Object.values(i).forEach(t=>{if(r)return;let s=IE(t?.accounts,`${e} namespace`);s&&(r=s)}),r}function TE(i,e){let r=null;return Dp(i?.methods)?Dp(i?.events)||(r=ce("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ce("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function ng(i,e){let r=null;return Object.values(i).forEach(t=>{if(r)return;let s=TE(t,`${e}, namespace`);s&&(r=s)}),r}function og(i,e,r){let t=null;if(i&&Ki(i)){let s=ng(i,e);s&&(t=s);let n=SE(i,e,r);n&&(t=n)}else t=B("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return t}function Co(i,e){let r=null;if(i&&Ki(i)){let t=ng(i,e);t&&(r=t);let s=DE(i,e);s&&(r=s)}else r=B("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function nu(i){return me(i.protocol,!0)}function ag(i,e){let r=!1;return e&&!i?r=!0:i&&Vt(i)&&i.length&&i.forEach(t=>{r=nu(t)}),r}function cg(i){return typeof i=="number"}function Oe(i){return typeof i<"u"&&typeof i!==null}function ug(i){return!(!i||typeof i!="object"||!i.code||!su(i.code,!1)||!i.message||!me(i.message,!1))}function hg(i){return!(De(i)||!me(i.method,!1))}function lg(i){return!(De(i)||De(i.result)&&De(i.error)||!su(i.id,!1)||!me(i.jsonrpc,!1))}function dg(i){return!(De(i)||!me(i.name,!1))}function ou(i,e){return!(!xo(e)||!mE(i).includes(e))}function fg(i,e,r){return me(r,!1)?yE(i,e).includes(r):!1}function pg(i,e,r){return me(r,!1)?wE(i,e).includes(r):!1}function au(i,e,r){let t=null,s=RE(i),n=CE(e),o=Object.keys(s),a=Object.keys(n),c=Tp(Object.keys(i)),h=Tp(Object.keys(e)),d=c.filter(l=>!h.includes(l));return d.length&&(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces. + Required: ${d.toString()} + Received: ${Object.keys(e).toString()}`)),lr(o,a)||(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces. Required: ${o.toString()} - Approved: ${f.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=Vs(e[y].accounts);S.includes(y)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} - Required: ${y} - Approved: ${S.toString()}`))}),o.forEach(y=>{i||(Bn(n[y].methods,s[y].methods)?Bn(n[y].events,s[y].events)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function r7(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function km(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function i7(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Vs(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Dy(r,e){return Jd(r,!1)&&r<=e.max&&r>=e.min}function Zd(){let r=Wo();return new Promise(e=>{switch(r){case zt.browser:e(n7());break;case zt.reactNative:e(s7());break;case zt.node:e(o7());break;default:e(!0)}})}function n7(){return Fs()&&navigator?.onLine}async function s7(){return kn()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function o7(){return!0}function Ny(r){switch(Wo()){case zt.browser:a7(r);break;case zt.reactNative:f7(r);break;case zt.node:break}}function a7(r){!kn()&&Fs()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function f7(r){kn()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>r(e?.isConnected))}var Si,Ii,Km,Ls,Dd,jm,Ho,qs,cc,Vm,YE,XE,Nm,ZE,QE,Cm,Pm,e9,zt,t9,c9,p9,g9,b9,Om,v9,m9,Lm,y9,w9,_9,qd,x9,hc,Xo,Ud,iy,Dt,si,Bs,Qo,ny,wr,zs,D9,qm,Vo,kd,O9,L9,q9,F9,Fm,U9,B9,Um,Bm,z9,J9,W9,Td,Ji,ra=Z(()=>{hg();Si=Ue(ns()),Ii=Ue(Sf()),Km=Ue(lg()),Ls=Ue(Cg());bb();dv();Dd=Ue(wv()),jm=Ue(Mv()),Ho=Ue(mo()),qs=Ue(Rv()),cc=Ue(Cv());hd();Vm=Ue(Rm());Ef();Dm();YE=":";XE=Object.defineProperty,Nm=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,Cm=(r,e,t)=>e in r?XE(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Pm=(r,e)=>{for(var t in e||(e={}))ZE.call(e,t)&&Cm(r,t,e[t]);if(Nm)for(var t of Nm(e))QE.call(e,t)&&Cm(r,t,e[t]);return r},e9="ReactNative",zt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},t9="js";c9="https://rpc.walletconnect.org/v1";p9=Object.defineProperty,g9=Object.defineProperties,b9=Object.getOwnPropertyDescriptors,Om=Object.getOwnPropertySymbols,v9=Object.prototype.hasOwnProperty,m9=Object.prototype.propertyIsEnumerable,Lm=(r,e,t)=>e in r?p9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,y9=(r,e)=>{for(var t in e||(e={}))v9.call(e,t)&&Lm(r,t,e[t]);if(Om)for(var t of Om(e))m9.call(e,t)&&Lm(r,t,e[t]);return r},w9=(r,e)=>g9(r,b9(e)),_9="did:pkh:",qd=r=>r?.split(":"),x9=r=>{let e=r&&qd(r);if(e)return r.includes(_9)?e[3]:e[1]},hc=r=>{let e=r&&qd(r);if(e)return e[2]+":"+e[3]},Xo=r=>{let e=r&&qd(r);if(e)return e.pop()};Ud=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Xo(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${x9(e)}`,c=`Nonce: ${r.nonce}`,u=`Issued At: ${r.iat}`,b=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(T=>` -- ${T}`).join("")}`:void 0,M=Zo(r.resources);if(M){let T=$o(M);n=T9(n,T)}return[t,i,"",n,"",s,o,f,c,u,b,y,S,I].filter(T=>T!=null).join(` -`)};iy="base10",Dt="base16",si="base64pad",Bs="base64url",Qo="utf8",ny=0,wr=1,zs=2,D9=0,qm=1,Vo=12,kd=32;O9="irn";L9=Object.defineProperty,q9=Object.defineProperties,F9=Object.getOwnPropertyDescriptors,Fm=Object.getOwnPropertySymbols,U9=Object.prototype.hasOwnProperty,B9=Object.prototype.propertyIsEnumerable,Um=(r,e,t)=>e in r?L9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bm=(r,e)=>{for(var t in e||(e={}))U9.call(e,t)&&Um(r,t,e[t]);if(Fm)for(var t of Fm(e))B9.call(e,t)&&Um(r,t,e[t]);return r},z9=(r,e)=>q9(r,F9(e));J9={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},W9={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};Td={},Ji=class{static get(e){return Td[e]}static set(e,t){Td[e]=t}static delete(e){delete Td[e]}}});var Cy,Py,Oy,Ly,gc,ia,Qd,bc,Yi,na,vc=Z(()=>{Cy="PARSE_ERROR",Py="INVALID_REQUEST",Oy="METHOD_NOT_FOUND",Ly="INVALID_PARAMS",gc="INTERNAL_ERROR",ia="SERVER_ERROR",Qd=[-32700,-32600,-32601,-32602,-32603],bc=[-32e3,-32099],Yi={[Cy]:{code:-32700,message:"Parse error"},[Py]:{code:-32600,message:"Invalid Request"},[Oy]:{code:-32601,message:"Method not found"},[Ly]:{code:-32602,message:"Invalid params"},[gc]:{code:-32603,message:"Internal error"},[ia]:{code:-32e3,message:"Server error"}},na=ia});function c7(r){return r<=bc[0]&&r>=bc[1]}function mc(r){return Qd.includes(r)}function qy(r){return typeof r=="number"}function yc(r){return Object.keys(Yi).includes(r)?Yi[r]:Yi[na]}function wc(r){let e=Object.values(Yi).find(t=>t.code===r);return e||Yi[na]}function u7(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!qy(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(mc(r.error.code)){let e=wc(r.error.code);if(e.message!==Yi[na].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function el(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var tl=Z(()=>{vc()});var Uy=W(Xi=>{"use strict";Object.defineProperty(Xi,"__esModule",{value:!0});Xi.isBrowserCryptoAvailable=Xi.getSubtleCrypto=Xi.getBrowerCrypto=void 0;function rl(){return(global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}Xi.getBrowerCrypto=rl;function Fy(){let r=rl();return r.subtle||r.webkitSubtle}Xi.getSubtleCrypto=Fy;function h7(){return!!rl()&&!!Fy()}Xi.isBrowserCryptoAvailable=h7});var ky=W(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.isBrowser=Zi.isNode=Zi.isReactNative=void 0;function By(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Zi.isReactNative=By;function zy(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Zi.isNode=zy;function d7(){return!By()&&!zy()}Zi.isBrowser=d7});var il=W(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var Ky=(es(),so(Qn));Ky.__exportStar(Uy(),_c);Ky.__exportStar(ky(),_c)});var Ct={};vt(Ct,{isNodeJs:()=>Vy});var jy,Vy,$y=Z(()=>{jy=Ue(il());Lt(Ct,Ue(il()));Vy=jy.isNode});function oi(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function xr(r=6){return BigInt(oi(r))}function Er(r,e,t){return{id:t||oi(),jsonrpc:"2.0",method:r,params:e}}function $s(r,e){return{id:r,jsonrpc:"2.0",result:e}}function jn(r,e,t){return{id:r,jsonrpc:"2.0",error:Hy(e,t)}}function Hy(r,e){return typeof r>"u"?yc(gc):(typeof r=="string"&&(r=Object.assign(Object.assign({},yc(ia)),{message:r})),typeof e<"u"&&(r.data=e),mc(r.code)&&(r=wc(r.code)),r)}var Gy=Z(()=>{tl();vc()});function l7(r){return r.includes("*")?Ec(r):!/\W/g.test(r)}function xc(r){return r==="*"}function Ec(r){return xc(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function p7(r){return!xc(r)&&Ec(r)&&!r.split("*")[0].trim()}function g7(r){return!xc(r)&&Ec(r)&&!r.split("*")[1].trim()}var Jy=Z(()=>{});var sa,nl,Sc,oa,Wy=Z(()=>{sa=class{},nl=class extends sa{constructor(e){super()}},Sc=class extends sa{constructor(){super()}},oa=class extends Sc{constructor(e){super()}}});var Yy=Z(()=>{Wy()});function m7(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Xy(r,e){let t=m7(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function y7(r){return Xy(r,b7)}function Ic(r){return Xy(r,v7)}function sl(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}var b7,v7,Zy=Z(()=>{b7="^https?:",v7="^wss?:"});function ol(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Hs(r){return ol(r)&&"method"in r}function Qi(r){return ol(r)&&(Vt(r)||Pt(r))}function Vt(r){return"result"in r}function Pt(r){return"error"in r}function w7(r){return"error"in r&&r.valid===!1}var Qy=Z(()=>{});var $t={};vt($t,{DEFAULT_ERROR:()=>na,IBaseJsonRpcProvider:()=>Sc,IEvents:()=>sa,IJsonRpcConnection:()=>nl,IJsonRpcProvider:()=>oa,INTERNAL_ERROR:()=>gc,INVALID_PARAMS:()=>Ly,INVALID_REQUEST:()=>Py,METHOD_NOT_FOUND:()=>Oy,PARSE_ERROR:()=>Cy,RESERVED_ERROR_CODES:()=>Qd,SERVER_ERROR:()=>ia,SERVER_ERROR_CODE_RANGE:()=>bc,STANDARD_ERROR_MAP:()=>Yi,formatErrorMessage:()=>Hy,formatJsonRpcError:()=>jn,formatJsonRpcRequest:()=>Er,formatJsonRpcResult:()=>$s,getBigIntRpcId:()=>xr,getError:()=>yc,getErrorByCode:()=>wc,isHttpUrl:()=>y7,isJsonRpcError:()=>Pt,isJsonRpcPayload:()=>ol,isJsonRpcRequest:()=>Hs,isJsonRpcResponse:()=>Qi,isJsonRpcResult:()=>Vt,isJsonRpcValidationInvalid:()=>w7,isLocalhostUrl:()=>sl,isNodeJs:()=>Vy,isReservedErrorCode:()=>mc,isServerErrorCode:()=>c7,isValidDefaultRoute:()=>xc,isValidErrorCode:()=>qy,isValidLeadingWildcardRoute:()=>p7,isValidRoute:()=>l7,isValidTrailingWildcardRoute:()=>g7,isValidWildcardRoute:()=>Ec,isWsUrl:()=>Ic,parseConnectionError:()=>el,payloadId:()=>oi,validateJsonRpcError:()=>u7});var aa=Z(()=>{vc();tl();$y();Lt($t,Ct);Gy();Jy();Yy();Zy();Qy()});var e2,Mc,t2=Z(()=>{e2=Ue(_n());aa();Mc=class extends oa{constructor(e){super(e),this.events=new e2.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Er(e.method,e.params||[],e.id||xr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Pt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Qi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}});var i2=W((BP,r2)=>{"use strict";r2.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var o2,_7,x7,n2,s2,E7,Ac,a2=Z(()=>{o2=Ue(_n());ss();aa();_7=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:i2(),x7=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",n2=r=>r.split("?")[0],s2=10,E7=_7(),Ac=class{constructor(e){if(this.url=e,this.events=new o2.EventEmitter,this.registering=!1,!Ic(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Zt(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Ic(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,$t.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!sl(e)},o=new E7(e,[],s);x7()?o.onerror=f=>{let c=f;i(this.emitError(c.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?jr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=jn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return el(e,n2(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>s2&&this.events.setMaxListeners(s2)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${n2(this.url)}`));return this.events.emit("register_error",t),t}}});var K2=W((fa,Js)=>{var S7=200,vl="__lodash_hash_undefined__",Lc=1,y2=2,w2=9007199254740991,Rc="[object Arguments]",ul="[object Array]",I7="[object AsyncFunction]",_2="[object Boolean]",x2="[object Date]",E2="[object Error]",S2="[object Function]",M7="[object GeneratorFunction]",Tc="[object Map]",I2="[object Number]",A7="[object Null]",Gs="[object Object]",f2="[object Promise]",R7="[object Proxy]",M2="[object RegExp]",Dc="[object Set]",A2="[object String]",T7="[object Symbol]",D7="[object Undefined]",hl="[object WeakMap]",R2="[object ArrayBuffer]",Nc="[object DataView]",N7="[object Float32Array]",C7="[object Float64Array]",P7="[object Int8Array]",O7="[object Int16Array]",L7="[object Int32Array]",q7="[object Uint8Array]",F7="[object Uint8ClampedArray]",U7="[object Uint16Array]",B7="[object Uint32Array]",z7=/[\\^$.*+?()[\]{}|]/g,k7=/^\[object .+?Constructor\]$/,K7=/^(?:0|[1-9]\d*)$/,Ze={};Ze[N7]=Ze[C7]=Ze[P7]=Ze[O7]=Ze[L7]=Ze[q7]=Ze[F7]=Ze[U7]=Ze[B7]=!0;Ze[Rc]=Ze[ul]=Ze[R2]=Ze[_2]=Ze[Nc]=Ze[x2]=Ze[E2]=Ze[S2]=Ze[Tc]=Ze[I2]=Ze[Gs]=Ze[M2]=Ze[Dc]=Ze[A2]=Ze[hl]=!1;var T2=typeof global=="object"&&global&&global.Object===Object&&global,j7=typeof self=="object"&&self&&self.Object===Object&&self,Ai=T2||j7||Function("return this")(),D2=typeof fa=="object"&&fa&&!fa.nodeType&&fa,c2=D2&&typeof Js=="object"&&Js&&!Js.nodeType&&Js,N2=c2&&c2.exports===D2,al=N2&&T2.process,u2=function(){try{return al&&al.binding&&al.binding("util")}catch{}}(),h2=u2&&u2.isTypedArray;function V7(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function wS(r,e){var t=this.__data__,i=Fc(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}Ri.prototype.clear=bS;Ri.prototype.delete=vS;Ri.prototype.get=mS;Ri.prototype.has=yS;Ri.prototype.set=wS;function Hn(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var u=s.get(r);if(u&&s.get(e))return u==e;var b=-1,y=!0,S=t&y2?new Pc:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=w2}function z2(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function ha(r){return r!=null&&typeof r=="object"}var k2=h2?J7(h2):FS;function XS(r){return WS(r)?PS(r):US(r)}function ZS(){return[]}function QS(){return!1}Js.exports=YS});function LI(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,F=new Uint8Array(z);N!==B;){for(var k=M[N],V=0,L=z-1;(k!==0||V>>0,F[L]=k%f>>>0,k=k/f>>>0;if(k!==0)throw new Error("Non-zero carry");O=V,N++}for(var P=z-O;P!==z&&F[P]===0;)P++;for(var J=c.repeat(T);P>>0,z=new Uint8Array(B);M[T];){var F=t[M.charCodeAt(T)];if(F===255)return;for(var k=0,V=B-1;(F!==0||k>>0,z[V]=F%256>>>0,F=F/256>>>0;if(F!==0)throw new Error("Non-zero carry");N=k,T++}if(M[T]!==" "){for(var L=B-N;L!==B&&z[L]===0;)L++;for(var P=new Uint8Array(O+(B-L)),J=O;L!==B;)P[J++]=z[L++];return P}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}function xM(r){return r.reduce((e,t)=>(e+=wM[t],e),"")}function EM(r){let e=[];for(let t of r){let i=_M[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}function y3(r,e,t){e=e||[],t=t||0;for(var i=t;r>=TM;)e[t++]=r&255|$2,r/=128;for(;r&RM;)e[t++]=r&255|$2,r>>>=7;return e[t]=r|0,y3.bytes=t-i+1,e}function Il(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw Il.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&H2)<=NM);return Il.bytes=s-i,t}function YM(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function I3(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}function ZM(r,e="utf8"){let t=XM[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r,"utf8"):t.decoder.decode(`${t.prefix}${r}`)}var Ti,ie,u3,h3,d3,l3,jl,ui,eI,tI,rI,j2,iI,nI,sI,oI,aI,fI,cI,Vl,uI,p3,hI,Ot,dI,or,lI,wl,Ge,pI,gI,V2,fi,bI,vI,mI,yI,wI,la,rn,Sr,_I,xI,EI,Ht,SI,II,MI,g3,Ys,AI,RI,TI,DI,Ir,ci,ar,nn,sn,Xs,NI,CI,PI,OI,qI,FI,b3,UI,BI,_l,xl,El,v3,Sl,Bc,ba,zI,kI,Et,KI,jI,VI,$I,HI,GI,JI,WI,YI,XI,ZI,QI,eM,tM,rM,iM,nM,sM,oM,aM,fM,cM,uM,hM,dM,lM,pM,gM,bM,vM,mM,yM,m3,wM,_M,SM,IM,MM,$2,AM,RM,TM,DM,NM,H2,CM,PM,OM,LM,qM,FM,UM,BM,zM,kM,KM,w3,G2,J2,Ml,Al,_3,Rl,x3,jM,VM,$M,E3,HM,S3,GM,JM,WM,W2,Y2,ml,XM,Tl,Dl,Nl,Cl,Pl,QM,eA,tA,X2,rA,iA,Z2,pa,yl,Ol,nA,Q2,sA,oA,e3,t3,Ll,aA,r3,fA,cA,i3,n3,hi,ql,Fl,Ul,Bl,zl,uA,s3,hA,dA,o3,ga,kl,lA,a3,pA,gA,f3,c3,Kl,M3,A3=Z(()=>{Ti=Ue(_n());np();_p();Tu();Du();ie=Ue(ns());ss();Ef();Ef();ra();hd();t2();aa();a2();u3=Ue(K2()),h3=Ue(Sf()),d3="wc",l3=2,jl="core",ui=`${d3}@2:${jl}:`,eI={name:jl,logger:"error"},tI={database:":memory:"},rI="crypto",j2="client_ed25519_seed",iI=ie.ONE_DAY,nI="keychain",sI="0.3",oI="messages",aI="0.3",fI=ie.SIX_HOURS,cI="publisher",Vl="irn",uI="error",p3="wss://relay.walletconnect.org",hI="relayer",Ot={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},dI="_subscription",or={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},lI=.1,wl="2.17.1",Ge={link_mode:"link_mode",relay:"relay"},pI="0.3",gI="WALLETCONNECT_CLIENT_ID",V2="WALLETCONNECT_LINK_MODE_APPS",fi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},bI="subscription",vI="0.3",mI=ie.FIVE_SECONDS*1e3,yI="pairing",wI="0.3",la={wc_pairingDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:0},res:{ttl:ie.ONE_DAY,prompt:!1,tag:0}}},rn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Sr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},_I="history",xI="0.3",EI="expirer",Ht={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},SI="0.3",II="verify-api",MI="https://verify.walletconnect.com",g3="https://verify.walletconnect.org",Ys=g3,AI=`${Ys}/v3`,RI=[MI,g3],TI="echo",DI="https://echo.walletconnect.com",Ir={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ci={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ar={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},nn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},sn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Xs={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},NI=.1,CI="event-client",PI=86400,OI="https://pulse.walletconnect.org/batch";qI=LI,FI=qI,b3=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},UI=r=>new TextEncoder().encode(r),BI=r=>new TextDecoder().decode(r),_l=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},xl=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return v3(this,e)}},El=class{constructor(e){this.decoders=e}or(e){return v3(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},v3=(r,e)=>new El({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Sl=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new _l(e,t,i),this.decoder=new xl(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Bc=({name:r,prefix:e,encode:t,decode:i})=>new Sl(r,e,t,i),ba=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=FI(t,e);return Bc({prefix:r,name:e,encode:i,decode:s=>b3(n(s))})},zI=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[u++]=255&c>>f)}if(f>=t||255&c<<8-f)throw new SyntaxError("Unexpected end of data");return o},kI=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Bc({prefix:e,name:r,encode(n){return kI(n,i,t)},decode(n){return zI(n,i,t,r)}}),KI=Bc({prefix:"\0",name:"identity",encode:r=>BI(r),decode:r=>UI(r)}),jI=Object.freeze({__proto__:null,identity:KI}),VI=Et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$I=Object.freeze({__proto__:null,base2:VI}),HI=Et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),GI=Object.freeze({__proto__:null,base8:HI}),JI=ba({prefix:"9",name:"base10",alphabet:"0123456789"}),WI=Object.freeze({__proto__:null,base10:JI}),YI=Et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),XI=Et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ZI=Object.freeze({__proto__:null,base16:YI,base16upper:XI}),QI=Et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),eM=Et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tM=Et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),rM=Et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),iM=Et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nM=Et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),sM=Et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),oM=Et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),aM=Et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),fM=Object.freeze({__proto__:null,base32:QI,base32upper:eM,base32pad:tM,base32padupper:rM,base32hex:iM,base32hexupper:nM,base32hexpad:sM,base32hexpadupper:oM,base32z:aM}),cM=ba({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),uM=ba({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),hM=Object.freeze({__proto__:null,base36:cM,base36upper:uM}),dM=ba({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lM=ba({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),pM=Object.freeze({__proto__:null,base58btc:dM,base58flickr:lM}),gM=Et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bM=Et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vM=Et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mM=Et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),yM=Object.freeze({__proto__:null,base64:gM,base64pad:bM,base64url:vM,base64urlpad:mM}),m3=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),wM=m3.reduce((r,e,t)=>(r[t]=e,r),[]),_M=m3.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);SM=Bc({prefix:"\u{1F680}",name:"base256emoji",encode:xM,decode:EM}),IM=Object.freeze({__proto__:null,base256emoji:SM}),MM=y3,$2=128,AM=127,RM=~AM,TM=Math.pow(2,31);DM=Il,NM=128,H2=127;CM=Math.pow(2,7),PM=Math.pow(2,14),OM=Math.pow(2,21),LM=Math.pow(2,28),qM=Math.pow(2,35),FM=Math.pow(2,42),UM=Math.pow(2,49),BM=Math.pow(2,56),zM=Math.pow(2,63),kM=function(r){return r(w3.encode(r,e,t),e),J2=r=>w3.encodingLength(r),Ml=(r,e)=>{let t=e.byteLength,i=J2(r),n=i+J2(t),s=new Uint8Array(n+t);return G2(r,s,0),G2(t,s,i),s.set(e,n),new Al(r,t,e,s)},Al=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},_3=({name:r,code:e,encode:t})=>new Rl(r,e,t),Rl=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ml(this.code,t):t.then(i=>Ml(this.code,i))}else throw Error("Unknown type, must be binary type")}},x3=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),jM=_3({name:"sha2-256",code:18,encode:x3("SHA-256")}),VM=_3({name:"sha2-512",code:19,encode:x3("SHA-512")}),$M=Object.freeze({__proto__:null,sha256:jM,sha512:VM}),E3=0,HM="identity",S3=b3,GM=r=>Ml(E3,S3(r)),JM={code:E3,name:HM,encode:S3,digest:GM},WM=Object.freeze({__proto__:null,identity:JM});new TextEncoder,new TextDecoder;W2={...jI,...$I,...GI,...WI,...ZI,...fM,...hM,...pM,...yM,...IM};({...$M,...WM});Y2=I3("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ml=I3("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=YM(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=mt(t,this.name)}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Cd(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Pd(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Dl=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=rI,this.randomSessionIdentifier=dc(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=Ah(n);return xf(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=sy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=Ah(s),f=this.randomSessionIdentifier;return await ig(f,n,iI,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let f=this.getPrivateKey(n),c=oy(f,s);return this.setSymKey(c,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||ks(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let f=Kd(o),c=Zt(s);if(Vd(f))return cy(c,o?.encoding);if(jd(f)){let S=f.senderPublicKey,I=f.receiverPublicKey;n=await this.generateSharedKey(S,I)}let u=this.getSymKey(n),{type:b,senderPublicKey:y}=f;return fy({type:b,symKey:u,message:c,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let f=ly(s,o);if(Vd(f)){let c=hy(s,o?.encoding);return jr(c)}if(jd(f)){let c=f.receiverPublicKey,u=f.senderPublicKey;n=await this.generateSharedKey(c,u)}try{let c=this.getSymKey(n),u=uy({symKey:c,encoded:s,encoding:o?.encoding});return jr(u)}catch(c){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(n,s=si)=>{let o=Ks({encoded:n,encoding:s});return Gi(o.type)},this.getPayloadSenderPublicKey=(n,s=si)=>{let o=Ks({encoded:n,encoding:s});return o.senderPublicKey?tt(o.senderPublicKey,Dt):void 0},this.core=e,this.logger=mt(t,this.name),this.keychain=i||new Tl(this.core,this.logger)}get context(){return St(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(j2)}catch{e=dc(),await this.keychain.set(j2,e)}return ZM(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Nl=class extends Ya{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=oI,this.version=aI,this.initialized=!1,this.storagePrefix=ui,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=_r(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=_r(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=mt(e,this.name),this.core=t}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Cd(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Pd(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Cl=class extends Xa{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Ti.EventEmitter,this.name=cI,this.queue=new Map,this.publishTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.failedPublishTimeout=(0,ie.toMiliseconds)(ie.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let f=s?.ttl||fI,c=lc(s),u=s?.prompt||!1,b=s?.tag||0,y=s?.id||xr().toString(),S={topic:i,message:n,opts:{ttl:f,relay:c,prompt:u,tag:b,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${b}`,M=Date.now(),T,O=1;try{for(;T===void 0;){if(Date.now()-M>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:O},`publisher.publish - attempt ${O}`),T=await await Kn(this.rpcPublish(i,n,f,c,u,b,y,s?.attestation).catch(N=>this.logger.warn(N)),this.publishTimeout,I),O++,T||await new Promise(N=>setTimeout(N,this.failedPublishTimeout))}this.relayer.events.emit(Ot.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw N;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=mt(t,this.name),this.registerEventListeners()}get context(){return St(this.logger)}rpcPublish(e,t,i,n,s,o,f,c){var u,b,y,S;let I={method:js(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:c},id:f};return xt((u=I.params)==null?void 0:u.prompt)&&((b=I.params)==null||delete b.prompt),xt((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ot.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ot.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Pl=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},QM=Object.defineProperty,eA=Object.defineProperties,tA=Object.getOwnPropertyDescriptors,X2=Object.getOwnPropertySymbols,rA=Object.prototype.hasOwnProperty,iA=Object.prototype.propertyIsEnumerable,Z2=(r,e,t)=>e in r?QM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pa=(r,e)=>{for(var t in e||(e={}))rA.call(e,t)&&Z2(r,t,e[t]);if(X2)for(var t of X2(e))iA.call(e,t)&&Z2(r,t,e[t]);return r},yl=(r,e)=>eA(r,tA(e)),Ol=class extends ef{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Pl,this.events=new Ti.EventEmitter,this.name=bI,this.version=vI,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ui,this.subscribeTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=lc(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let f=new ie.Watch;f.start(n);let c=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(c),f.stop(n),s(!0)),f.elapsed(n)>=mI&&(clearInterval(c),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=mt(t,this.name),this.clientId=""}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=lc(i);await this.rpcUnsubscribe(e,t,n);let s=Be("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===Ge.relay&&await this.restartToComplete();let s={method:js(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let f=_r(e+this.clientId);if(i?.transportType===Ge.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},(0,ie.toMiliseconds)(ie.ONE_SECOND)),f;let c=await Kn(this.relayer.request(s).catch(u=>this.logger.warn(u)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ot.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:js(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Kn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ot.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:js(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Kn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ot.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:js(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,yl(pa({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,pa({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,pa({},t)),this.topicMap.set(t.topic,e),this.events.emit(fi.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(fi.deleted,yl(pa({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(fi.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);Wi(t)&&this.onBatchSubscribe(t.map((i,n)=>yl(pa({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(xn.pulse,async()=>{await this.checkPending()}),this.events.on(fi.created,async e=>{let t=fi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(fi.deleted,async e=>{let t=fi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},nA=Object.defineProperty,Q2=Object.getOwnPropertySymbols,sA=Object.prototype.hasOwnProperty,oA=Object.prototype.propertyIsEnumerable,e3=(r,e,t)=>e in r?nA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,t3=(r,e)=>{for(var t in e||(e={}))sA.call(e,t)&&e3(r,t,e[t]);if(Q2)for(var t of Q2(e))oA.call(e,t)&&e3(r,t,e[t]);return r},Ll=class extends Za{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ti.EventEmitter,this.name=hI,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ie.toMiliseconds)(ie.THIRTY_SECONDS+ie.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||xr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let f=await new Promise(async(c,u)=>{let b=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(or.disconnect,b);let y=await o;this.provider.off(or.disconnect,b),c(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Jo())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ot.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Ot.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(or.payload,this.onPayloadHandler),this.provider.on(or.connect,this.onConnectHandler),this.provider.on(or.disconnect,this.onDisconnectHandler),this.provider.on(or.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?mt(e.logger,this.name):(0,go.default)(vo({level:e.logger||uI})),this.messages=new Nl(this.logger,e.core),this.subscriber=new Ol(this,this.logger),this.publisher=new Cl(this,this.logger),this.relayUrl=e?.relayUrl||p3,this.projectId=e.projectId,this.bundleId=Hm(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return St(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Ge.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",c,u=b=>{b.topic===e&&(this.subscriber.off(fi.created,u),c())};return await Promise.all([new Promise(b=>{c=b,this.subscriber.on(fi.created,u)}),new Promise(async(b,y)=>{f=await this.subscriber.subscribe(e,t3({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||f,b()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await Kn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(or.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(or.disconnect,n),await Kn(this.provider.connect(),(0,ie.toMiliseconds)(ie.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Zd())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=ft(ie.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ot.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Jo())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Mc(new Ac(Gm({sdkVersion:wl,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Hs(e)){if(!e.method.endsWith(dI))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:Ge.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(t3({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Qi(e)&&this.events.emit(Ot.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ot.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=$s(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(or.payload,this.onPayloadHandler),this.provider.off(or.connect,this.onConnectHandler),this.provider.off(or.disconnect,this.onDisconnectHandler),this.provider.off(or.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Zd();Ny(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ot.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ie.toMiliseconds)(lI))))}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},aA=Object.defineProperty,r3=Object.getOwnPropertySymbols,fA=Object.prototype.hasOwnProperty,cA=Object.prototype.propertyIsEnumerable,i3=(r,e,t)=>e in r?aA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,n3=(r,e)=>{for(var t in e||(e={}))fA.call(e,t)&&i3(r,t,e[t]);if(r3)for(var t of r3(e))cA.call(e,t)&&i3(r,t,e[t]);return r},hi=class extends Qa{constructor(e,t,i,n=ui,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=pI,this.cached=[],this.initialized=!1,this.storagePrefix=ui,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!xt(o)?this.map.set(this.getKey(o),o):vy(o)?this.map.set(o.id,o):my(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(c=>(0,u3.default)(f[c],o[c]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});let c=n3(n3({},this.getData(o)),f);this.map.set(o,c),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=mt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},ql=class{constructor(e,t){this.core=e,this.logger=t,this.name=yI,this.version=wI,this.events=new Ti.default,this.initialized=!1,this.storagePrefix=ui,this.ignoredPayloadTypes=[wr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=dc(),s=await this.core.crypto.setSymKey(n),o=ft(ie.FIVE_MINUTES),f={protocol:Vl},c={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},u=Hd({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(rn.create,c),this.core.expirer.set(s,o),await this.pairings.set(s,c),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Ir.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:f,expiryTimestamp:c,methods:u}=$d(i.uri);n.props.properties.topic=s,n.addTrace(Ir.pairing_uri_validation_success),n.addTrace(Ir.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(Ir.existing_pairing),b.active)throw n.setError(ci.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Ir.pairing_not_expired)}let y=c||ft(ie.FIVE_MINUTES),S={topic:s,relay:f,expiry:y,active:!1,methods:u};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(Ir.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(rn.create,S),n.addTrace(Ir.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Ir.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ci.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(I){throw n.setError(ci.subscribe_pairing_topic_failure),I}return n.addTrace(Ir.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=ft(ie.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:c}=Mi();this.events.once(Le("pairing_ping",s),({error:u})=>{u?c(u):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Be("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:f}=i,c=this.core.crypto.keychain.get(n);return Hd({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:c,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{let o=Er(n,s),f=await this.core.crypto.encode(i,o),c=la[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,c),o.id},this.sendResult=async(i,n,s)=>{let o=$s(i,s),f=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),u=la[c.request.method].res;await this.core.relayer.publish(n,f,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=jn(i,s),f=await this.core.crypto.encode(n,o),c=await this.core.history.get(n,i),u=la[c.request.method]?la[c.request.method].res:la.unregistered_method.res;await this.core.relayer.publish(n,f,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Be("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>ni(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(rn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{Vt(n)?this.events.emit(Le("pairing_ping",s),{}):Pt(n)&&this.events.emit(Le("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(rn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let f=Be("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Be("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Nt(i)){let{message:f}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(!by(i.uri)){let{message:f}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ci.malformed_pairing_uri),new Error(f)}let o=$d(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:f}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){let{message:f}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ci.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&(0,ie.toMiliseconds)(o?.expiryTimestamp){if(!Nt(i)){let{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Nt(i)){let{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!Qe(i,!1)){let{message:n}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(ni(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=mt(t,this.name),this.pairings=new hi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return St(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ot.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===Ge.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{Hs(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Qi(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Ht.expired,async e=>{let{topic:t}=uc(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(rn.expire,{topic:t}))})}},Fl=class extends Wa{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Ti.EventEmitter,this.name=_I,this.version=xI,this.cached=[],this.initialized=!1,this.storagePrefix=ui,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:ft(ie.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Sr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Pt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Sr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Sr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=mt(t,this.name)}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:Er(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Sr.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Sr.created,e=>{let t=Sr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Sr.updated,e=>{let t=Sr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Sr.deleted,e=>{let t=Sr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(xn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,ie.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Sr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Ul=class extends tf{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Ti.EventEmitter,this.name=EI,this.version=SI,this.cached=[],this.initialized=!1,this.storagePrefix=ui,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Ht.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Ht.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=mt(t,this.name)}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Wm(e);if(typeof e=="number")return Ym(e);let{message:t}=Q("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Ht.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,ie.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ht.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(xn.pulse,()=>this.checkExpirations()),this.events.on(Ht.created,e=>{let t=Ht.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ht.expired,e=>{let t=Ht.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Ht.deleted,e=>{let t=Ht.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},Bl=class extends rf{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=II,this.verifyUrlV3=AI,this.storagePrefix=ui,this.version=l3,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ie.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!Fs()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:f}=n,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{let u=(0,h3.getDocument)(),b=this.startAbortTimer(ie.ONE_SECOND*5),y=await new Promise((S,I)=>{let M=()=>{window.removeEventListener("message",O),u.body.removeChild(T),I("attestation aborted")};this.abortController.signal.addEventListener("abort",M);let T=u.createElement("iframe");T.src=c,T.style.display="none",T.addEventListener("error",M,{signal:this.abortController.signal});let O=N=>{if(N.data&&typeof N.data=="string")try{let B=JSON.parse(N.data);if(B.type==="verify_attestation"){if(vs(B.attestation).payload.id!==o)return;clearInterval(b),u.body.removeChild(T),this.abortController.signal.removeEventListener("abort",M),window.removeEventListener("message",O),S(B.attestation===null?"":B.attestation)}}catch(B){this.logger.warn(B)}};u.body.appendChild(T),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(vs(s).payload.id!==f)return;let u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;let c=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,c)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(ie.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||Ys;return RI.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Ys}`),s=Ys),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(ie.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=py(n,s.publicKey),f={hasExpired:(0,ie.toMiliseconds)(o.exp)this.abortController.abort(),(0,ie.toMiliseconds)(e))}},zl=class extends nf{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=TI,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,c=`${DI}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=mt(t,this.context)}},uA=Object.defineProperty,s3=Object.getOwnPropertySymbols,hA=Object.prototype.hasOwnProperty,dA=Object.prototype.propertyIsEnumerable,o3=(r,e,t)=>e in r?uA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ga=(r,e)=>{for(var t in e||(e={}))hA.call(e,t)&&o3(r,t,e[t]);if(s3)for(var t of s3(e))dA.call(e,t)&&o3(r,t,e[t]);return r},kl=class extends sf{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=CI,this.storagePrefix=ui,this.storageVersion=NI,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Yo())try{let n={eventId:Ld(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Nd(this.core.relayer.protocol,this.core.relayer.version,wl)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:f,trace:c}}=n,u=Ld(),b=this.core.projectId||"",y=Date.now(),S=ga({eventId:u,timestamp:y,props:{event:s,type:o,properties:{topic:f,trace:c}},bundleId:b,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let f=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(f)return ga(ga({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(xn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,ie.fromMiliseconds)(Date.now())-(0,ie.fromMiliseconds)(n.timestamp)>PI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,ga(ga({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${OI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${wl}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>Us().url,this.logger=mt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},lA=Object.defineProperty,a3=Object.getOwnPropertySymbols,pA=Object.prototype.hasOwnProperty,gA=Object.prototype.propertyIsEnumerable,f3=(r,e,t)=>e in r?lA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c3=(r,e)=>{for(var t in e||(e={}))pA.call(e,t)&&f3(r,t,e[t]);if(a3)for(var t of a3(e))gA.call(e,t)&&f3(r,t,e[t]);return r},Kl=class r extends Ja{constructor(e){var t;super(e),this.protocol=d3,this.version=l3,this.name=jl,this.events=new Ti.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:c})=>{if(!o||!f)return;let u={topic:o,message:f,publishedAt:Date.now(),transportType:Ge.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:c})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||p3,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=vo({level:typeof e?.logger=="string"&&e.logger?e.logger:eI.logger}),{logger:n,chunkLoggerController:s}=Dp({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=mt(n,this.name),this.heartbeat=new Ua,this.crypto=new Dl(this,this.logger,e?.keychain),this.history=new Fl(this,this.logger),this.expirer=new Ul(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new ka(c3(c3({},tI),e?.storageOptions)),this.relayer=new Ll({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new ql(this,this.logger),this.verify=new Bl(this,this.logger,this.storage),this.echoClient=new zl(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new kl(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(gI,i),t}get context(){return St(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(V2,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(V2)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},M3=Kl});var Kc,Fe,N3,C3,P3,t0,$l,R3,bA,vA,mA,Zs,yA,bt,Hl,di,wA,_A,xA,EA,SA,IA,MA,jc,zc,AA,RA,TA,T3,DA,NA,D3,nt,Mr,Gl,Jl,Wl,Yl,Xl,Zl,Ql,e0,kc,O3=Z(()=>{A3();Tu();Du();ra();Kc=Ue(_n()),Fe=Ue(ns());aa();N3="wc",C3=2,P3="client",t0=`${N3}@${C3}:${P3}:`,$l={name:P3,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},R3="WALLETCONNECT_DEEPLINK_CHOICE",bA="proposal",vA="Proposal expired",mA="session",Zs=Fe.SEVEN_DAYS,yA="engine",bt={wc_sessionPropose:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Fe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Fe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1119}}},Hl={min:Fe.FIVE_MINUTES,max:Fe.SEVEN_DAYS},di={idle:"IDLE",active:"ACTIVE"},wA="request",_A=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],xA="wc",EA="auth",SA="authKeys",IA="pairingTopics",MA="requests",jc=`${xA}@${1.5}:${EA}:`,zc=`${jc}:PUB_KEY`,AA=Object.defineProperty,RA=Object.defineProperties,TA=Object.getOwnPropertyDescriptors,T3=Object.getOwnPropertySymbols,DA=Object.prototype.hasOwnProperty,NA=Object.prototype.propertyIsEnumerable,D3=(r,e,t)=>e in r?AA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nt=(r,e)=>{for(var t in e||(e={}))DA.call(e,t)&&D3(r,t,e[t]);if(T3)for(var t of T3(e))NA.call(e,t)&&D3(r,t,e[t]);return r},Mr=(r,e)=>RA(r,TA(e)),Gl=class extends af{constructor(e){super(e),this.name=yA,this.events=new Kc.default,this.initialized=!1,this.requestQueue={state:di.idle,queue:[]},this.sessionRequestQueue={state:di.idle,queue:[]},this.requestQueueDelay=Fe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(bt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=Mr(nt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:c}=i,u=n,b,y=!1;try{u&&(y=this.client.core.pairing.pairings.get(u).active)}catch(F){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),F}if(!u||!y){let{topic:F,uri:k}=await this.client.core.pairing.create();u=F,b=k}if(!u){let{message:F}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(F)}let S=await this.client.core.crypto.generateKeyPair(),I=bt.wc_sessionPropose.req.ttl||Fe.FIVE_MINUTES,M=ft(I),T=nt({requiredNamespaces:s,optionalNamespaces:o,relays:c??[{protocol:Vl}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:M,pairingTopic:u},f&&{sessionProperties:f}),{reject:O,resolve:N,done:B}=Mi(I,vA);this.events.once(Le("session_connect"),async({error:F,session:k})=>{if(F)O(F);else if(k){k.self.publicKey=S;let V=Mr(nt({},k),{pairingTopic:T.pairingTopic,requiredNamespaces:T.requiredNamespaces,optionalNamespaces:T.optionalNamespaces,transportType:Ge.relay});await this.client.session.set(k.topic,V),await this.setExpiry(k.topic,k.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:k.peer.metadata}),this.cleanupDuplicatePairings(V),N(V)}});let z=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:T,throwOnFailedPublish:!0});return await this.setProposal(z,nt({id:z},T)),{uri:b,approval:B}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[ar.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(P){throw o.setError(nn.no_internet_connection),P}try{await this.isValidProposalId(t?.id)}catch(P){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(nn.proposal_not_found),P}try{await this.isValidApprove(t)}catch(P){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(nn.session_approve_namespace_validation_failure),P}let{id:f,relayProtocol:c,namespaces:u,sessionProperties:b,sessionConfig:y}=t,S=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:M,requiredNamespaces:T,optionalNamespaces:O}=S,N=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});N||(N=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:ar.session_approve_started,properties:{topic:I,trace:[ar.session_approve_started,ar.session_namespaces_validation_success]}}));let B=await this.client.core.crypto.generateKeyPair(),z=M.publicKey,F=await this.client.core.crypto.generateSharedKey(B,z),k=nt(nt({relay:{protocol:c??"irn"},namespaces:u,controller:{publicKey:B,metadata:this.client.metadata},expiry:ft(Zs)},b&&{sessionProperties:b}),y&&{sessionConfig:y}),V=Ge.relay;N.addTrace(ar.subscribing_session_topic);try{await this.client.core.relayer.subscribe(F,{transportType:V})}catch(P){throw N.setError(nn.subscribe_session_topic_failure),P}N.addTrace(ar.subscribe_session_topic_success);let L=Mr(nt({},k),{topic:F,requiredNamespaces:T,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:k.controller,peer:{publicKey:M.publicKey,metadata:M.metadata},controller:B,transportType:Ge.relay});await this.client.session.set(F,L),N.addTrace(ar.store_session);try{N.addTrace(ar.publishing_session_settle),await this.sendRequest({topic:F,method:"wc_sessionSettle",params:k,throwOnFailedPublish:!0}).catch(P=>{throw N?.setError(nn.session_settle_publish_failure),P}),N.addTrace(ar.session_settle_publish_success),N.addTrace(ar.publishing_session_approve),await this.sendResult({id:f,topic:I,result:{relay:{protocol:c??"irn"},responderPublicKey:B},throwOnFailedPublish:!0}).catch(P=>{throw N?.setError(nn.session_approve_publish_failure),P}),N.addTrace(ar.session_approve_publish_success)}catch(P){throw this.client.logger.error(P),this.client.session.delete(F,Be("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(F),P}return this.client.core.eventClient.deleteEvent({eventId:N.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:M.metadata}),await this.client.proposal.delete(f,Be("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(F,ft(Zs)),{topic:F,acknowledged:()=>Promise.resolve(this.client.session.get(F))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:bt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Be("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=Mi(),c=oi(),u=xr().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Le("session_update",c),({error:y})=>{y?f(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:u}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:b}),f(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}let{topic:i}=t,n=oi(),{done:s,resolve:o,reject:f}=Mi();return this.events.once(Le("session_extend",n),({error:c})=>{c?f(c):o()}),await this.setExpiry(i,ft(Zs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(c=>{f(c)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(M){throw this.client.logger.error("request() -> isValidRequest() failed"),M}let{chainId:i,request:n,topic:s,expiry:o=bt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===Ge.relay&&await this.confirmOnlineStateOrThrow();let c=oi(),u=xr().toString(),{done:b,resolve:y,reject:S}=Mi(o,"Request expired. Please try again.");this.events.once(Le("session_request",c),({error:M,result:T})=>{M?S(M):y(T)});let I=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return I?(await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Mr(nt({},n),{expiryTimestamp:ft(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(M=>S(M)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),await b()):await Promise.all([new Promise(async M=>{await this.sendRequest({clientRpcId:c,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Mr(nt({},n),{expiryTimestamp:ft(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(T=>S(T)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:c}),M()}),new Promise(async M=>{var T;if(!((T=f.sessionConfig)!=null&&T.disableDeepLink)){let O=await Zm(this.client.core.storage,R3);await Xm({id:c,topic:s,wcDeepLink:O})}M()}),b()]).then(M=>M[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===Ge.relay&&await this.confirmOnlineStateOrThrow();let f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Vt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):Pt(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=oi(),s=xr().toString(),{done:o,resolve:f,reject:c}=Mi();this.events.once(Le("session_ping",n),({error:u})=>{u?c(u):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=xr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Be("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gy(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?Ge.link_mode:Ge.relay;o===Ge.relay&&await this.confirmOnlineStateOrThrow();let{chains:f,statement:c="",uri:u,domain:b,nonce:y,type:S,exp:I,nbf:M,methods:T=[],expiry:O}=t,N=[...t.resources||[]],{topic:B,uri:z}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:B,uri:z}});let F=await this.client.core.crypto.generateKeyPair(),k=ks(F);if(await Promise.all([this.client.auth.authKeys.set(zc,{responseTopic:k,publicKey:F}),this.client.auth.pairingTopics.set(k,{topic:k,pairingTopic:B})]),await this.client.core.relayer.subscribe(k,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${B}`),T.length>0){let{namespace:m}=Go(f[0]),h=ty(m,"request",T);Zo(N)&&(h=ry(h,N.pop())),N.push(h)}let V=O&&O>bt.wc_sessionAuthenticate.req.ttl?O:bt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:f,statement:c,aud:u,domain:b,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:M,resources:N},requester:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:ft(V)},P={eip155:{chains:f,methods:[...new Set(["personal_sign",...T])],events:["chainChanged","accountsChanged"]}},J={requiredNamespaces:{},optionalNamespaces:P,relays:[{protocol:"irn"}],pairingTopic:B,proposer:{publicKey:F,metadata:this.client.metadata},expiryTimestamp:ft(bt.wc_sessionPropose.req.ttl)},{done:D,resolve:l,reject:w}=Mi(V,"Request expired"),p=async({error:m,session:h})=>{if(this.events.off(Le("session_request",d),a),m)w(m);else if(h){h.self.publicKey=F,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),B&&await this.client.core.pairing.updateMetadata({topic:B,metadata:h.peer.metadata});let x=this.client.session.get(h.topic);await this.deleteProposal(v),l({session:x})}},a=async m=>{var h,x,A;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),m.error){let U=Be("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return m.error.code===U.code?void 0:(this.events.off(Le("session_connect"),p),w(m.error.message))}await this.deleteProposal(v),this.events.off(Le("session_connect"),p);let{cacaos:g,responder:R}=m.result,K=[],E=[];for(let U of g){await Fd({cacao:U,projectId:this.client.core.projectId})||(this.client.logger.error(U,"Signature verification failed"),w(Be("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:j}=U,Y=Zo(j.resources),H=[hc(j.iss)],$=Xo(j.iss);if(Y){let te=Bd(Y),G=zd(Y);K.push(...te),H.push(...G)}for(let te of H)E.push(`${te}:${$}`)}let C=await this.client.core.crypto.generateSharedKey(F,R.publicKey),q;K.length>0&&(q={topic:C,acknowledged:!0,self:{publicKey:F,metadata:this.client.metadata},peer:R,controller:R.publicKey,expiry:ft(Zs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:B,namespaces:Gd([...new Set(K)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(C,{transportType:o}),await this.client.session.set(C,q),B&&await this.client.core.pairing.updateMetadata({topic:B,metadata:R.metadata}),q=this.client.session.get(C)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(x=R.metadata.redirect)!=null&&x.linkMode&&(A=R.metadata.redirect)!=null&&A.universal&&i&&(this.client.core.addLinkModeSupportedApp(R.metadata.redirect.universal),this.client.session.update(C,{transportType:Ge.link_mode})),l({auths:g,session:q})},d=oi(),v=oi();this.events.once(Le("session_connect"),p),this.events.once(Le("session_request",d),a);let _;try{if(s){let m=Er("wc_sessionAuthenticate",L,d);this.client.core.history.set(B,m);let h=await this.client.core.crypto.encode("",m,{type:zs,encoding:Bs});_=ea(i,B,h)}else await Promise.all([this.sendRequest({topic:B,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:B,method:"wc_sessionPropose",params:J,expiry:bt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:v})])}catch(m){throw this.events.off(Le("session_connect"),p),this.events.off(Le("session_request",d),a),m}return await this.setProposal(v,nt({id:v},J)),await this.setAuthRequest(d,{request:Mr(nt({},L),{verifyContext:{}}),pairingTopic:B,transportType:o}),{uri:_??z,response:D}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[sn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(Xs.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Xs.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let f=o.transportType||Ge.relay;f===Ge.relay&&await this.confirmOnlineStateOrThrow();let c=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),b=ks(c),y={type:wr,receiverPublicKey:c,senderPublicKey:u},S=[],I=[];for(let O of n){if(!await Fd({cacao:O,projectId:this.client.core.projectId})){s.setError(Xs.invalid_cacao);let k=Be("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:k,encodeOpts:y}),new Error(k.message)}s.addTrace(sn.cacaos_verified);let{p:N}=O,B=Zo(N.resources),z=[hc(N.iss)],F=Xo(N.iss);if(B){let k=Bd(B),V=zd(B);S.push(...k),z.push(...V)}for(let k of z)I.push(`${k}:${F}`)}let M=await this.client.core.crypto.generateSharedKey(u,c);s.addTrace(sn.create_authenticated_session_topic);let T;if(S?.length>0){T={topic:M,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:ft(Zs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Gd([...new Set(S)],[...new Set(I)]),transportType:f},s.addTrace(sn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(M,{transportType:f})}catch(O){throw s.setError(Xs.subscribe_authenticated_session_topic_failure),O}s.addTrace(sn.subscribe_authenticated_session_topic_success),await this.client.session.set(M,T),s.addTrace(sn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(sn.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(O){throw s.setError(Xs.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:T}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===Ge.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),c=ks(o),u={type:wr,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:c,error:n,encodeOpts:u,rpcOpts:bt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Be("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return Ud(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:c}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Be("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(R3).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,Be("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=di.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(nn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Be("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=di.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,ft(bt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=Ge.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||ft(bt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:c,throwOnFailedPublish:u,appLink:b}=t,y=Er(n,s,c),S,I=!!b;try{let O=I?Bs:si;S=await this.client.core.crypto.encode(i,y,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let M;if(_A.includes(n)){let O=_r(JSON.stringify(y)),N=_r(S);M=await this.client.core.verify.register({id:N,decryptedId:O})}let T=bt[n].req;if(T.attestation=M,o&&(T.ttl=o),f&&(T.id=f),this.client.core.history.set(i,y),I){let O=ea(b,i,S);await global.Linking.openURL(O,this.client.name)}else{let O=bt[n].req;o&&(O.ttl=o),f&&(O.id=f),u?(O.internal=Mr(nt({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(N=>this.client.logger.error(N))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:c}=t,u=$s(i,s),b,y=c&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?Bs:si;b=await this.client.core.crypto.encode(n,u,Mr(nt({},f||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=ea(c,n,b);await global.Linking.openURL(I,this.client.name)}else{let I=bt[S.request.method].res;o?(I.internal=Mr(nt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,I)):this.client.core.relayer.publish(n,b,I).catch(M=>this.client.logger.error(M))}await this.client.core.history.resolve(u)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:c}=t,u=jn(i,s),b,y=c&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?Bs:si;b=await this.client.core.crypto.encode(n,u,Mr(nt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=ea(c,n,b);await global.Linking.openURL(I,this.client.name)}else{let I=f||bt[S.request.method].res;this.client.core.relayer.publish(n,b,I)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;ni(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{ni(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===di.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=di.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=di.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,c=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:c}=n;try{let u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(nt({},n.params));let b=f.expiryTimestamp||ft(bt.wc_sessionPropose.req.ttl),y=nt({id:c,pairingTopic:i,expiryTimestamp:b},f);await this.setProposal(c,y);let S=await this.getVerifyContext({attestationId:s,hash:_r(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(ci.proposal_listener_not_found)),u?.addTrace(Ir.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:y,verifyContext:S})}catch(u){await this.sendError({id:c,topic:i,error:u,rpcOpts:bt.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(Vt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});let c=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});let u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});let b=await this.client.core.crypto.generateSharedKey(c,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});let y=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(Pt(i)){await this.client.proposal.delete(s,Be("USER_DISCONNECTED"));let o=Le("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Le("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:f,expiry:c,namespaces:u,sessionProperties:b,sessionConfig:y}=i.params,S=Mr(nt(nt({topic:t,relay:o,expiry:c,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},b&&{sessionProperties:b}),y&&{sessionConfig:y}),{transportType:Ge.relay}),I=Le("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Le("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;Vt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Le("session_approve",n),{})):Pt(i)&&(await this.client.session.delete(t,Be("USER_DISCONNECTED")),this.events.emit(Le("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,f=Ji.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:Be("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(nt({topic:t},n));try{Ji.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(c){throw Ji.delete(o),c}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Le("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Vt(i)?this.events.emit(Le("session_update",n),{}):Pt(i)&&this.events.emit(Le("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,ft(Zs)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Le("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Vt(i)?this.events.emit(Le("session_extend",n),{}):Pt(i)&&this.events.emit(Le("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Le("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Vt(i)?this.events.emit(Le("session_ping",n),{}):Pt(i)&&this.events.emit(Le("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ot.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Be("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:f,attestation:c,encryptedId:u,transportType:b}=t,{id:y,params:S}=f;try{await this.isValidRequest(nt({topic:o},S));let I=this.client.session.get(o),M=await this.getVerifyContext({attestationId:c,hash:_r(JSON.stringify(Er("wc_sessionRequest",S,y))),encryptedId:u,metadata:I.peer.metadata,transportType:b}),T={id:y,topic:o,params:S,verifyContext:M};await this.setPendingSessionRequest(T),b===Ge.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(T):(this.addSessionRequestToSessionRequestQueue(T),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Le("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Vt(i)?this.events.emit(Le("session_request",n),{result:i.result}):Pt(i)&&this.events.emit(Le("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,f=Ji.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(nt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),Ji.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Vt(i)?this.events.emit(Le("session_request",n),{result:i.result}):Pt(i)&&this.events.emit(Le("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:f,transportType:c}=t;try{let{requester:u,authPayload:b,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:_r(JSON.stringify(s)),encryptedId:f,metadata:u.metadata,transportType:c}),I={requester:u,pairingTopic:n,id:s.id,authPayload:b,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:c}),c===Ge.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(u){this.client.logger.error(u);let b=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,c),I={type:wr,receiverPublicKey:b,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:I,rpcOpts:bt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=di.idle,this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,f=Le("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Le("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===di.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=di.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Er("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Nt(t)){let{message:c}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(c)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(xt(i)||await this.isValidPairingTopic(i),!xy(f,!0)){let{message:c}=Q("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(c)}!xt(n)&&ta(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!xt(s)&&ta(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),xt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=_y(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Nt(t))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let f=this.client.proposal.get(i),c=pc(n,"approve()");if(c)throw new Error(c.message);let u=Xd(f.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!Qe(s,!0)){let{message:b}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}xt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Nt(t)){let{message:s}=Q("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Sy(n)){let{message:s}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Nt(t)){let{message:u}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(u)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Wd(i)){let{message:u}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}let f=yy(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);let c=pc(s,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(ni(o)){let{message:u}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async t=>{if(!Nt(t)){let{message:c}=Q("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(c)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=pc(n,"update()");if(o)throw new Error(o.message);let f=Xd(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!Nt(t)){let{message:n}=Q("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Nt(t)){let{message:c}=Q("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(c)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:f}=this.client.session.get(i);if(!Yd(f,s)){let{message:c}=Q("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(c)}if(!Iy(n)){let{message:c}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(c)}if(!Ry(f,s,n.method)){let{message:c}=Q("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(c)}if(o&&!Dy(o,Hl)){let{message:c}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Hl.min} and ${Hl.max}`);throw new Error(c)}},this.isValidRespond=async t=>{var i;if(!Nt(t)){let{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!My(s)){let{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Nt(t)){let{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Nt(t)){let{message:f}=Q("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!Yd(o,s)){let{message:f}=Q("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!Ay(n)){let{message:f}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!Ty(o,s,n.name)){let{message:f}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!Nt(t)){let{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Qe(n,!1))throw new Error("uri is required parameter");if(!Qe(s,!1))throw new Error("domain is required parameter");if(!Qe(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(c=>Go(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:f}=Go(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,c={verified:{verifyUrl:o.verifyUrl||Ys,validation:"UNKNOWN",origin:o.url||""}};try{if(f===Ge.link_mode){let b=this.getAppLinkIfEnabled(o,f);return c.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",c}let u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(c.verified.origin=u.origin,c.verified.isScam=u.isScam,c.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!Qe(n,!1)){let{message:s}=Q("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,c,u,b,y,S;return!t||i!==Ge.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((u=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:u.universal)!==""&&((b=t?.redirect)==null?void 0:b.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=Od(t,"topic")||"",n=decodeURIComponent(Od(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:Ge.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Yo()||kn()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ot.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(zc)?this.client.auth.authKeys.get(zc):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===Ge.link_mode?Bs:si});try{Hs(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:_r(i)})):Qi(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(Ht.expired,async e=>{let{topic:t,id:i}=uc(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(rn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(rn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Qe(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(ni(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Qe(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(ni(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=Q("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=Q("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Qe(e,!1)){let{message:t}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Ey(e)){let{message:t}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(ni(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},Jl=class extends hi{constructor(e,t){super(e,t,bA,t0),this.core=e,this.logger=t}},Wl=class extends hi{constructor(e,t){super(e,t,mA,t0),this.core=e,this.logger=t}},Yl=class extends hi{constructor(e,t){super(e,t,wA,t0,i=>i.id),this.core=e,this.logger=t}},Xl=class extends hi{constructor(e,t){super(e,t,SA,jc,()=>zc),this.core=e,this.logger=t}},Zl=class extends hi{constructor(e,t){super(e,t,IA,jc),this.core=e,this.logger=t}},Ql=class extends hi{constructor(e,t){super(e,t,MA,jc,i=>i.id),this.core=e,this.logger=t}},e0=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new Xl(this.core,this.logger),this.pairingTopics=new Zl(this.core,this.logger),this.requests=new Ql(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},kc=class r extends of{constructor(e){super(e),this.protocol=N3,this.version=C3,this.name=$l.name,this.events=new Kc.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||$l.name,this.metadata=e?.metadata||Us(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,go.default)(vo({level:e?.logger||$l.logger}));this.core=e?.core||new M3(e),this.logger=mt(t,this.name),this.session=new Wl(this.core,this.logger),this.proposal=new Jl(this.core,this.logger),this.pendingRequest=new Yl(this.core,this.logger),this.engine=new Gl(this),this.auth=new e0(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return St(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}});var L3,Ar,r0=Z(()=>{"use strict";L3=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],Ar="mvx"});var va=Z(()=>{"use strict"});function Vc(r){return r[Math.floor(Math.random()*r.length)]}var ma,q3,i0,Qs=Z(()=>{"use strict";ma=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);q3="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",i0=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;ti.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Di(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=s0(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function F3(r){return!!r}function o0(r){let e=r.namespaces[Ar];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function a0({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,f=r.guardian;if(f&&f!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=i0(t),i&&(r.guardianSignature=i0(i)),r}function U3(r){if(r)return{...r,url:Us().url}}async function B3(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var z3=Z(()=>{"use strict";ra();r0();va();Qs()});var fr,ya=Z(()=>{"use strict";O3();ra();z3();r0();va();fr=class{constructor(e,t,i,n,s,o,f,c){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.Message=s,this.Transaction=o,this.TransactionsConverter=f,this.options=c}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:U3(this.options?.metadata)}:{},t=await kc.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=n0(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await B3(500);let i=o0(t),s=t.namespaces[Ar].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Di(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:Be("USER_DISCONNECTED")});else{let t=Di(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:Be("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return a0({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];a0({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${Ar}:${this.chainId}`,topic:Di(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Di(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?F3(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=o0(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&Di(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=s0(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!Wi(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}}});var k3={};vt(k3,{initMobileProvider:()=>OA});var OA,K3=Z(()=>{"use strict";ya();Qs();OA=async(r,e,t,i,n,s,o,f)=>{if(!o||!r.initOptions.chainType)return;let c={onClientLogin:()=>{},onClientLogout:()=>e(r),onClientEvent:y=>{console.log("wc2 session event: ",y)}},u=Vc(f),b=new fr(c,t[r.initOptions.chainType].shortId,u,o,i,n,s);try{return await b.init(),b}catch{console.warn("Can't initialize the Dapp Provider!")}}});var V3=W((MO,j3)=>{j3.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var on=W(Jn=>{var f0,LA=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Jn.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};Jn.getSymbolTotalCodewords=function(e){return LA[e]};Jn.getBCHDigit=function(r){let e=0;for(;r!==0;)e++,r>>>=1;return e};Jn.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');f0=e};Jn.isKanjiModeEnabled=function(){return typeof f0<"u"};Jn.toSJIS=function(e){return f0(e)}});var $c=W(cr=>{cr.L={bit:1};cr.M={bit:0};cr.Q={bit:3};cr.H={bit:2};function qA(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return cr.L;case"m":case"medium":return cr.M;case"q":case"quartile":return cr.Q;case"h":case"high":return cr.H;default:throw new Error("Unknown EC Level: "+r)}}cr.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4};cr.from=function(e,t){if(cr.isValid(e))return e;try{return qA(e)}catch{return t}}});var G3=W((TO,H3)=>{function $3(){this.buffer=[],this.length=0}$3.prototype={get:function(r){let e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(let t=0;t>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};H3.exports=$3});var W3=W((DO,J3)=>{function wa(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}wa.prototype.set=function(r,e,t,i){let n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};wa.prototype.get=function(r,e){return this.data[r*this.size+e]};wa.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};wa.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};J3.exports=wa});var Y3=W(Hc=>{var FA=on().getSymbolSize;Hc.getRowColCoords=function(e){if(e===1)return[];let t=Math.floor(e/7)+2,i=FA(e),n=i===145?26:Math.ceil((i-13)/(2*t-2))*2,s=[i-7];for(let o=1;o{var UA=on().getSymbolSize,X3=7;Z3.getPositions=function(e){let t=UA(e);return[[0,0],[t-X3,0],[0,t-X3]]}});var e6=W(Ye=>{Ye.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var Wn={N1:3,N2:3,N3:40,N4:10};Ye.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7};Ye.from=function(e){return Ye.isValid(e)?parseInt(e,10):void 0};Ye.getPenaltyN1=function(e){let t=e.size,i=0,n=0,s=0,o=null,f=null;for(let c=0;c=5&&(i+=Wn.N1+(n-5)),o=b,n=1),b=e.get(u,c),b===f?s++:(s>=5&&(i+=Wn.N1+(s-5)),f=b,s=1)}n>=5&&(i+=Wn.N1+(n-5)),s>=5&&(i+=Wn.N1+(s-5))}return i};Ye.getPenaltyN2=function(e){let t=e.size,i=0;for(let n=0;n=10&&(n===1488||n===93)&&i++,s=s<<1&2047|e.get(f,o),f>=10&&(s===1488||s===93)&&i++}return i*Wn.N3};Ye.getPenaltyN4=function(e){let t=0,i=e.data.length;for(let s=0;s{var an=$c(),Gc=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Jc=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];c0.getBlocksCount=function(e,t){switch(t){case an.L:return Gc[(e-1)*4+0];case an.M:return Gc[(e-1)*4+1];case an.Q:return Gc[(e-1)*4+2];case an.H:return Gc[(e-1)*4+3];default:return}};c0.getTotalCodewordsCount=function(e,t){switch(t){case an.L:return Jc[(e-1)*4+0];case an.M:return Jc[(e-1)*4+1];case an.Q:return Jc[(e-1)*4+2];case an.H:return Jc[(e-1)*4+3];default:return}}});var t6=W(Yc=>{var _a=new Uint8Array(512),Wc=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)_a[t]=e,Wc[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)_a[t]=_a[t-255]})();Yc.log=function(e){if(e<1)throw new Error("log("+e+")");return Wc[e]};Yc.exp=function(e){return _a[e]};Yc.mul=function(e,t){return e===0||t===0?0:_a[Wc[e]+Wc[t]]}});var r6=W(xa=>{var h0=t6();xa.mul=function(e,t){let i=new Uint8Array(e.length+t.length-1);for(let n=0;n=0;){let n=i[0];for(let o=0;o{var i6=r6();function d0(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}d0.prototype.initialize=function(e){this.degree=e,this.genPoly=i6.generateECPolynomial(this.degree)};d0.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let i=i6.mod(t,this.genPoly),n=this.degree-i.length;if(n>0){let s=new Uint8Array(this.degree);return s.set(i,n),s}return i};n6.exports=d0});var l0=W(o6=>{o6.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}});var p0=W(Ni=>{var a6="[0-9]+",zA="[A-Z $%*+\\-./:]+",Ea="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Ea=Ea.replace(/u/g,"\\u");var kA="(?:(?![A-Z0-9 $%*+\\-./:]|"+Ea+`)(?:.|[\r -]))+`;Ni.KANJI=new RegExp(Ea,"g");Ni.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Ni.BYTE=new RegExp(kA,"g");Ni.NUMERIC=new RegExp(a6,"g");Ni.ALPHANUMERIC=new RegExp(zA,"g");var KA=new RegExp("^"+Ea+"$"),jA=new RegExp("^"+a6+"$"),VA=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Ni.testKanji=function(e){return KA.test(e)};Ni.testNumeric=function(e){return jA.test(e)};Ni.testAlphanumeric=function(e){return VA.test(e)}});var fn=W(ct=>{var $A=l0(),g0=p0();ct.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};ct.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};ct.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};ct.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};ct.MIXED={bit:-1};ct.getCharCountIndicator=function(e,t){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!$A.isValid(t))throw new Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]};ct.getBestModeForData=function(e){return g0.testNumeric(e)?ct.NUMERIC:g0.testAlphanumeric(e)?ct.ALPHANUMERIC:g0.testKanji(e)?ct.KANJI:ct.BYTE};ct.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")};ct.isValid=function(e){return e&&e.bit&&e.ccBits};function HA(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return ct.NUMERIC;case"alphanumeric":return ct.ALPHANUMERIC;case"kanji":return ct.KANJI;case"byte":return ct.BYTE;default:throw new Error("Unknown mode: "+r)}}ct.from=function(e,t){if(ct.isValid(e))return e;try{return HA(e)}catch{return t}}});var d6=W(Yn=>{var Xc=on(),GA=u0(),f6=$c(),cn=fn(),b0=l0(),u6=7973,c6=Xc.getBCHDigit(u6);function JA(r,e,t){for(let i=1;i<=40;i++)if(e<=Yn.getCapacity(i,t,r))return i}function h6(r,e){return cn.getCharCountIndicator(r,e)+4}function WA(r,e){let t=0;return r.forEach(function(i){let n=h6(i.mode,e);t+=n+i.getBitsLength()}),t}function YA(r,e){for(let t=1;t<=40;t++)if(WA(r,t)<=Yn.getCapacity(t,e,cn.MIXED))return t}Yn.from=function(e,t){return b0.isValid(e)?parseInt(e,10):t};Yn.getCapacity=function(e,t,i){if(!b0.isValid(e))throw new Error("Invalid QR Code version");typeof i>"u"&&(i=cn.BYTE);let n=Xc.getSymbolTotalCodewords(e),s=GA.getTotalCodewordsCount(e,t),o=(n-s)*8;if(i===cn.MIXED)return o;let f=o-h6(i,e);switch(i){case cn.NUMERIC:return Math.floor(f/10*3);case cn.ALPHANUMERIC:return Math.floor(f/11*2);case cn.KANJI:return Math.floor(f/13);case cn.BYTE:default:return Math.floor(f/8)}};Yn.getBestVersionForData=function(e,t){let i,n=f6.from(t,f6.M);if(Array.isArray(e)){if(e.length>1)return YA(e,n);if(e.length===0)return 1;i=e[0]}else i=e;return JA(i.mode,i.getLength(),n)};Yn.getEncodedBits=function(e){if(!b0.isValid(e)||e<7)throw new Error("Invalid QR Code version");let t=e<<12;for(;Xc.getBCHDigit(t)-c6>=0;)t^=u6<{var v0=on(),p6=1335,XA=21522,l6=v0.getBCHDigit(p6);g6.getEncodedBits=function(e,t){let i=e.bit<<3|t,n=i<<10;for(;v0.getBCHDigit(n)-l6>=0;)n^=p6<{var ZA=fn();function eo(r){this.mode=ZA.NUMERIC,this.data=r.toString()}eo.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};eo.prototype.getLength=function(){return this.data.length};eo.prototype.getBitsLength=function(){return eo.getBitsLength(this.data.length)};eo.prototype.write=function(e){let t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);let s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};v6.exports=eo});var w6=W((VO,y6)=>{var QA=fn(),m0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function to(r){this.mode=QA.ALPHANUMERIC,this.data=r}to.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};to.prototype.getLength=function(){return this.data.length};to.prototype.getBitsLength=function(){return to.getBitsLength(this.data.length)};to.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let i=m0.indexOf(this.data[t])*45;i+=m0.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(m0.indexOf(this.data[t]),6)};y6.exports=to});var x6=W(($O,_6)=>{var eR=fn();function ro(r){this.mode=eR.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}ro.getBitsLength=function(e){return e*8};ro.prototype.getLength=function(){return this.data.length};ro.prototype.getBitsLength=function(){return ro.getBitsLength(this.data.length)};ro.prototype.write=function(r){for(let e=0,t=this.data.length;e{var tR=fn(),rR=on();function io(r){this.mode=tR.KANJI,this.data=r}io.getBitsLength=function(e){return e*13};io.prototype.getLength=function(){return this.data.length};io.prototype.getBitsLength=function(){return io.getBitsLength(this.data.length)};io.prototype.write=function(r){let e;for(e=0;e=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` -Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};E6.exports=io});var I6=W((GO,y0)=>{"use strict";var Sa={single_source_shortest_paths:function(r,e,t){var i={},n={};n[e]=0;var s=Sa.PriorityQueue.make();s.push(e,0);for(var o,f,c,u,b,y,S,I,M;!s.empty();){o=s.pop(),f=o.value,u=o.cost,b=r[f]||{};for(c in b)b.hasOwnProperty(c)&&(y=b[c],S=u+y,I=n[c],M=typeof n[c]>"u",(M||I>S)&&(n[c]=S,s.push(c,S),i[c]=f))}if(typeof t<"u"&&typeof n[t]>"u"){var T=["Could not find a path from ",e," to ",t,"."].join("");throw new Error(T)}return i},extract_shortest_path_from_predecessor_list:function(r,e){for(var t=[],i=e,n;i;)t.push(i),n=r[i],i=r[i];return t.reverse(),t},find_path:function(r,e,t){var i=Sa.single_source_shortest_paths(r,e,t);return Sa.extract_shortest_path_from_predecessor_list(i,t)},PriorityQueue:{make:function(r){var e=Sa.PriorityQueue,t={},i;r=r||{};for(i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.queue=[],t.sorter=r.sorter||e.default_sorter,t},default_sorter:function(r,e){return r.cost-e.cost},push:function(r,e){var t={value:r,cost:e};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof y0<"u"&&(y0.exports=Sa)});var P6=W(no=>{var ke=fn(),R6=m6(),T6=w6(),D6=x6(),N6=S6(),Ia=p0(),Zc=on(),iR=I6();function M6(r){return unescape(encodeURIComponent(r)).length}function Ma(r,e,t){let i=[],n;for(;(n=r.exec(t))!==null;)i.push({data:n[0],index:n.index,mode:e,length:n[0].length});return i}function C6(r){let e=Ma(Ia.NUMERIC,ke.NUMERIC,r),t=Ma(Ia.ALPHANUMERIC,ke.ALPHANUMERIC,r),i,n;return Zc.isKanjiModeEnabled()?(i=Ma(Ia.BYTE,ke.BYTE,r),n=Ma(Ia.KANJI,ke.KANJI,r)):(i=Ma(Ia.BYTE_KANJI,ke.BYTE,r),n=[]),e.concat(t,i,n).sort(function(o,f){return o.index-f.index}).map(function(o){return{data:o.data,mode:o.mode,length:o.length}})}function w0(r,e){switch(e){case ke.NUMERIC:return R6.getBitsLength(r);case ke.ALPHANUMERIC:return T6.getBitsLength(r);case ke.KANJI:return N6.getBitsLength(r);case ke.BYTE:return D6.getBitsLength(r)}}function nR(r){return r.reduce(function(e,t){let i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function sR(r){let e=[];for(let t=0;t{var eu=on(),_0=$c(),aR=G3(),fR=W3(),cR=Y3(),uR=Q3(),S0=e6(),I0=u0(),hR=s6(),Qc=d6(),dR=b6(),lR=fn(),x0=P6();function pR(r,e){let t=r.size,i=uR.getPositions(e);for(let n=0;n=0&&f<=6&&(c===0||c===6)||c>=0&&c<=6&&(f===0||f===6)||f>=2&&f<=4&&c>=2&&c<=4?r.set(s+f,o+c,!0,!0):r.set(s+f,o+c,!1,!0))}}function gR(r){let e=r.size;for(let t=8;t>f&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function E0(r,e,t){let i=r.size,n=dR.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function mR(r,e){let t=r.size,i=-1,n=t-1,s=7,o=0;for(let f=t-1;f>0;f-=2)for(f===6&&f--;;){for(let c=0;c<2;c++)if(!r.isReserved(n,f-c)){let u=!1;o>>s&1)===1),r.set(n,f-c,u),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function yR(r,e,t){let i=new aR;t.forEach(function(c){i.put(c.mode.bit,4),i.put(c.getLength(),lR.getCharCountIndicator(c.mode,r)),c.write(i)});let n=eu.getSymbolTotalCodewords(r),s=I0.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);let f=(o-i.getLengthInBits())/8;for(let c=0;c=7&&vR(c,e),mR(c,o),isNaN(i)&&(i=S0.getBestMask(c,E0.bind(null,c,t))),S0.applyMask(i,c),E0(c,t,i),{modules:c,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}O6.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");let i=_0.M,n,s;return typeof t<"u"&&(i=_0.from(t.errorCorrectionLevel,_0.M),n=Qc.from(t.version),s=S0.from(t.maskPattern),t.toSJISFunc&&eu.setToSJISFunction(t.toSJISFunc)),_R(e,n,i,s)}});var M0=W(Xn=>{function q6(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let e=r.slice().replace("#","").split("");if(e.length<3||e.length===5||e.length>8)throw new Error("Invalid hex color: "+r);(e.length===3||e.length===4)&&(e=Array.prototype.concat.apply([],e.map(function(i){return[i,i]}))),e.length===6&&e.push("F","F");let t=parseInt(e.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+e.slice(0,6).join("")}}Xn.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=typeof e.margin>"u"||e.margin===null||e.margin<0?4:e.margin,i=e.width&&e.width>=21?e.width:void 0,n=e.scale||4;return{width:i,scale:i?4:n,margin:t,color:{dark:q6(e.color.dark||"#000000ff"),light:q6(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}};Xn.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale};Xn.getImageWidth=function(e,t){let i=Xn.getScale(e,t);return Math.floor((e+t.margin*2)*i)};Xn.qrToImageData=function(e,t,i){let n=t.modules.size,s=t.modules.data,o=Xn.getScale(n,i),f=Math.floor((n+i.margin*2)*o),c=i.margin*o,u=[i.color.light,i.color.dark];for(let b=0;b=c&&y>=c&&b{var A0=M0();function xR(r,e,t){r.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=t,e.width=t,e.style.height=t+"px",e.style.width=t+"px"}function ER(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}tu.render=function(e,t,i){let n=i,s=t;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),t||(s=ER()),n=A0.getOptions(n);let o=A0.getImageWidth(e.modules.size,n),f=s.getContext("2d"),c=f.createImageData(o,o);return A0.qrToImageData(c.data,e,n),xR(f,s,o),f.putImageData(c,0,0),s};tu.renderToDataURL=function(e,t,i){let n=i;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),n||(n={});let s=tu.render(e,t,n),o=n.type||"image/png",f=n.rendererOpts||{};return s.toDataURL(o,f.quality)}});var z6=W(B6=>{var SR=M0();function U6(r,e){let t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function R0(r,e,t){let i=r+e;return typeof t<"u"&&(i+=" "+t),i}function IR(r,e,t){let i="",n=0,s=!1,o=0;for(let f=0;f0&&c>0&&r[f-1]||(i+=s?R0("M",c+t,.5+u+t):R0("m",n,0),n=0,s=!1),c+1':"",u="',b='viewBox="0 0 '+f+" "+f+'"',S=''+c+u+` -`;return typeof i=="function"&&i(null,S),S}});var K6=W(Aa=>{var MR=V3(),T0=L6(),k6=F6(),AR=z6();function D0(r,e,t,i,n){let s=[].slice.call(arguments,1),o=s.length,f=typeof s[o-1]=="function";if(!f&&!MR())throw new Error("Callback required as last argument");if(f){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(c,u){try{let b=T0.create(t,i);c(r(b,e,i))}catch(b){u(b)}})}try{let c=T0.create(t,i);n(null,r(c,e,i))}catch(c){n(c)}}Aa.create=T0.create;Aa.toCanvas=D0.bind(null,k6.render);Aa.toDataURL=D0.bind(null,k6.renderToDataURL);Aa.toString=D0.bind(null,function(r,e,t){return AR.render(r,t)})});var j6,TR,DR,NR,CR,N0,PR,ru,OR,LR,qR,FR,UR,V6,$6=Z(()=>{"use strict";j6=Ue(K6(),1);ya();Qs();Qs();va();TR=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},DR=r=>{let e=`${q3}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},NR=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},CR=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},N0={},PR=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",N0[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:N0[r.topic].signal}),t},ru={},OR=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=PR(r,e);return i.appendChild(s),ru[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:ru[r.topic].signal}),i},LR=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},qR=r=>{if(!r)return;document.getElementById(r)?.remove()},FR=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),UR=async r=>r?await(0,j6.toString)(r,{type:"svg"}):void 0,V6=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=await UR(e),o;if(s&&(o=TR(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),FR()&&n.appendChild(DR(e))),n&&t instanceof fr){let f=t.pairings,c=async b=>{try{b&&(await t.logout({topic:b}),qR(b))}catch(y){let S=ma(y);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{ru[b].abort()}},u=async b=>{try{let{approval:y}=await t.connect({topic:b,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(b)?.after(LR()),await t.login({approval:y,token:i})}catch(y){let S=ma(y);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let y of Object.values(ru))y?.abort();for(let y of Object.values(N0))y?.abort()}};if(f&&f.length>0){let b=NR();n.appendChild(b);let y=CR();b.appendChild(y);for(let S of f){let I=OR(S,c,u);b.appendChild(I)}}}return n}});var H6={};vt(H6,{loginWithMobile:()=>BR});var BR,G6=Z(()=>{"use strict";Qs();$6();ya();va();BR=async(r,e,t,i,n,s,o,f,c,u,b,y,S,I,M)=>{if(!M)throw new Error("You haven't provided the QR code container DOM element id");let T=Vc(I);if(!T||!r.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!S)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!r.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let O,N={onClientLogin:async()=>{if(r.dappProvider instanceof fr){let z=await r.dappProvider.getAddress(),F=await r.dappProvider.getSignature();i.set("address",z),i.set("loginMethod","mobile"),i.set("expires",s()),await o(r),F&&i.set("signature",F),i.set("loginToken",e);let k=t.getToken(z,e,F);i.set("accessToken",k),f.run("onLoginSuccess"),O?.replaceChildren()}},onClientLogout:async()=>{r.dappProvider instanceof fr&&await n(r)},onClientEvent:z=>{console.log("wc2 session event: ",z)}},B=new fr(N,c[r.initOptions.chainType].shortId,T,S,u,b,y);try{if(B){r.dappProvider=B,f.run("onQrPending"),await B.init();let{uri:z,approval:F}=await B.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),k=e?`${z}&token=${e}`:z;return M&&k&&(O=await V6(M,k,B,e),f.run("onQrLoaded")),await B.login({approval:F,token:e}),B}}catch(z){let F=ma(z);console.warn(`Something went wrong trying to login the user: ${F}`),f.run("onLoginFailure",F)}}});ya();var J6=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:t,qrCodeContainer:i}){this.WalletConnectV2Provider=fr;this.initMobileProvider=async(e,t,i,n,s,o)=>{let{initMobileProvider:f}=await Promise.resolve().then(()=>(K3(),k3));return f(e,t,i,n,s,o,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses)};this.loginWithMobile=async(e,t,i,n,s,o,f,c,u,b,y,S)=>{let{loginWithMobile:I}=await Promise.resolve().then(()=>(G6(),H6));return I(e,t,i,n,s,o,f,c,u,b,y,S,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses,this.qrCodeContainer)};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=t,this.qrCodeContainer=i}};export{J6 as MobileSigningProvider}; + Approved: ${a.toString()}`)),Object.keys(e).forEach(l=>{if(!l.includes(":")||t)return;let p=Gr(e[l].accounts);p.includes(l)||(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${l} + Required: ${l} + Approved: ${p.toString()}`))}),o.forEach(l=>{t||(lr(s[l].methods,n[l].methods)?lr(s[l].events,n[l].events)||(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${l}`)):t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${l}`))}),t}function RE(i){let e={};return Object.keys(i).forEach(r=>{var t;r.includes(":")?e[r]=i[r]:(t=i[r].chains)==null||t.forEach(s=>{e[s]={methods:i[r].methods,events:i[r].events}})}),e}function Tp(i){return[...new Set(i.map(e=>e.includes(":")?e.split(":")[0]:e))]}function CE(i){let e={};return Object.keys(i).forEach(r=>{r.includes(":")?e[r]=i[r]:Gr(i[r].accounts)?.forEach(s=>{e[s]={accounts:i[r].accounts.filter(n=>n.includes(`${s}:`)),methods:i[r].methods,events:i[r].events}})}),e}function gg(i,e){return su(i,!1)&&i<=e.max&&i>=e.min}function cu(){let i=Fi();return new Promise(e=>{switch(i){case qe.browser:e(NE());break;case qe.reactNative:e(AE());break;case qe.node:e(OE());break;default:e(!0)}})}function NE(){return qr()&&navigator?.onLine}async function AE(){return fr()&&typeof window<"u"&&window!=null&&window.NetInfo?(await window?.NetInfo.fetch())?.isConnected:!0}function OE(){return!0}function mg(i){switch(Fi()){case qe.browser:PE(i);break;case qe.reactNative:LE(i);break;case qe.node:break}}function PE(i){!fr()&&qr()&&(window.addEventListener("online",()=>i(!0)),window.addEventListener("offline",()=>i(!1)))}function LE(i){fr()&&typeof window<"u"&&window!=null&&window.NetInfo&&window?.NetInfo.addEventListener(e=>i(e?.isConnected))}var Dt,Tt,Rp,qc,Cp,Li,Br,So,v1,x1,yp,S1,I1,wp,bp,D1,qe,T1,U1,q1,z1,V1,Ep,K1,j1,_p,$1,H1,G1,Hc,W1,Do,Bi,Wc,Vp,Ae,pt,Vr,zi,Kp,tt,Kr,rE,vp,Oi,Xc,oE,aE,cE,uE,xp,hE,lE,Sp,Ip,dE,EE,_E,Bc,zt,ji=P(()=>{Ud();Dt=pe(xr()),Tt=pe(Zn()),Rp=pe(Fd());kd();Ef();Kf();qc=pe(Xf()),Cp=pe(ip()),Li=pe(ni()),Br=pe(np()),So=pe(up());Fc();pp();Qn();mp();v1=":";x1=Object.defineProperty,yp=Object.getOwnPropertySymbols,S1=Object.prototype.hasOwnProperty,I1=Object.prototype.propertyIsEnumerable,wp=(i,e,r)=>e in i?x1(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,bp=(i,e)=>{for(var r in e||(e={}))S1.call(e,r)&&wp(i,r,e[r]);if(yp)for(var r of yp(e))I1.call(e,r)&&wp(i,r,e[r]);return i},D1="ReactNative",qe={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},T1="js";U1="https://rpc.walletconnect.org/v1";q1=Object.defineProperty,z1=Object.defineProperties,V1=Object.getOwnPropertyDescriptors,Ep=Object.getOwnPropertySymbols,K1=Object.prototype.hasOwnProperty,j1=Object.prototype.propertyIsEnumerable,_p=(i,e,r)=>e in i?q1(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,$1=(i,e)=>{for(var r in e||(e={}))K1.call(e,r)&&_p(i,r,e[r]);if(Ep)for(var r of Ep(e))j1.call(e,r)&&_p(i,r,e[r]);return i},H1=(i,e)=>z1(i,V1(e)),G1="did:pkh:",Hc=i=>i?.split(":"),W1=i=>{let e=i&&Hc(i);if(e)return i.includes(G1)?e[3]:e[1]},Do=i=>{let e=i&&Hc(i);if(e)return e[2]+":"+e[3]},Bi=i=>{let e=i&&Hc(i);if(e)return e.pop()};Wc=(i,e)=>{let r=`${i.domain} wants you to sign in with your Ethereum account:`,t=Bi(e);if(!i.aud&&!i.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=i.statement||void 0,n=`URI: ${i.aud||i.uri}`,o=`Version: ${i.version}`,a=`Chain ID: ${W1(e)}`,c=`Nonce: ${i.nonce}`,h=`Issued At: ${i.iat}`,d=i.exp?`Expiration Time: ${i.exp}`:void 0,l=i.nbf?`Not Before: ${i.nbf}`:void 0,p=i.requestId?`Request ID: ${i.requestId}`:void 0,f=i.resources?`Resources:${i.resources.map(w=>` +- ${w}`).join("")}`:void 0,g=qi(i.resources);if(g){let w=Pi(g);s=tE(s,w)}return[r,t,"",s,"",n,o,a,c,h,d,l,p,f].filter(w=>w!=null).join(` +`)};Vp="base10",Ae="base16",pt="base64pad",Vr="base64url",zi="utf8",Kp=0,tt=1,Kr=2,rE=0,vp=1,Oi=12,Xc=32;oE="irn";aE=Object.defineProperty,cE=Object.defineProperties,uE=Object.getOwnPropertyDescriptors,xp=Object.getOwnPropertySymbols,hE=Object.prototype.hasOwnProperty,lE=Object.prototype.propertyIsEnumerable,Sp=(i,e,r)=>e in i?aE(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Ip=(i,e)=>{for(var r in e||(e={}))hE.call(e,r)&&Sp(i,r,e[r]);if(xp)for(var r of xp(e))lE.call(e,r)&&Sp(i,r,e[r]);return i},dE=(i,e)=>cE(i,uE(e));EE={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},_E={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};Bc={},zt=class{static get(e){return Bc[e]}static set(e,r){Bc[e]=r}static delete(e){delete Bc[e]}}});var yg,wg,bg,Eg,No,$i,uu,Ao,Kt,Hi,Oo=P(()=>{yg="PARSE_ERROR",wg="INVALID_REQUEST",bg="METHOD_NOT_FOUND",Eg="INVALID_PARAMS",No="INTERNAL_ERROR",$i="SERVER_ERROR",uu=[-32700,-32600,-32601,-32602,-32603],Ao=[-32e3,-32099],Kt={[yg]:{code:-32700,message:"Parse error"},[wg]:{code:-32600,message:"Invalid Request"},[bg]:{code:-32601,message:"Method not found"},[Eg]:{code:-32602,message:"Invalid params"},[No]:{code:-32603,message:"Internal error"},[$i]:{code:-32e3,message:"Server error"}},Hi=$i});function UE(i){return i<=Ao[0]&&i>=Ao[1]}function Po(i){return uu.includes(i)}function _g(i){return typeof i=="number"}function Lo(i){return Object.keys(Kt).includes(i)?Kt[i]:Kt[Hi]}function Uo(i){let e=Object.values(Kt).find(r=>r.code===i);return e||Kt[Hi]}function ME(i){if(typeof i.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof i.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!_g(i.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${i.error.code}`};if(Po(i.error.code)){let e=Uo(i.error.code);if(e.message!==Kt[Hi].message&&i.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${i.error.code}`}}return{valid:!0}}function hu(i,e,r){return i.message.includes("getaddrinfo ENOTFOUND")||i.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):i}var lu=P(()=>{Oo()});var xg=oe(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.isBrowserCryptoAvailable=jt.getSubtleCrypto=jt.getBrowerCrypto=void 0;function du(){return window?.crypto||window?.msCrypto||{}}jt.getBrowerCrypto=du;function vg(){let i=du();return i.subtle||i.webkitSubtle}jt.getSubtleCrypto=vg;function FE(){return!!du()&&!!vg()}jt.isBrowserCryptoAvailable=FE});var Dg=oe($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.isBrowser=$t.isNode=$t.isReactNative=void 0;function Sg(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}$t.isReactNative=Sg;function Ig(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}$t.isNode=Ig;function kE(){return!Sg()&&!Ig()}$t.isBrowser=kE});var fu=oe(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});var Tg=(br(),ei(wr));Tg.__exportStar(xg(),Mo);Tg.__exportStar(Dg(),Mo)});var Pe={};Se(Pe,{isNodeJs:()=>Cg});var Rg,Cg,Ng=P(()=>{Rg=pe(fu());Me(Pe,pe(fu()));Cg=Rg.isNode});function gt(i=3){let e=Date.now()*Math.pow(10,i),r=Math.floor(Math.random()*Math.pow(10,i));return e+r}function it(i=6){return BigInt(gt(i))}function st(i,e,r){return{id:r||gt(),jsonrpc:"2.0",method:i,params:e}}function Wr(i,e){return{id:i,jsonrpc:"2.0",result:e}}function gr(i,e,r){return{id:i,jsonrpc:"2.0",error:Ag(e,r)}}function Ag(i,e){return typeof i>"u"?Lo(No):(typeof i=="string"&&(i=Object.assign(Object.assign({},Lo($i)),{message:i})),typeof e<"u"&&(i.data=e),Po(i.code)&&(i=Uo(i.code)),i)}var Og=P(()=>{lu();Oo()});function BE(i){return i.includes("*")?ko(i):!/\W/g.test(i)}function Fo(i){return i==="*"}function ko(i){return Fo(i)?!0:!(!i.includes("*")||i.split("*").length!==2||i.split("*").filter(e=>e.trim()==="").length!==1)}function qE(i){return!Fo(i)&&ko(i)&&!i.split("*")[0].trim()}function zE(i){return!Fo(i)&&ko(i)&&!i.split("*")[1].trim()}var Pg=P(()=>{});var Gi,pu,Bo,Wi,Lg=P(()=>{Gi=class{},pu=class extends Gi{constructor(e){super()}},Bo=class extends Gi{constructor(){super()}},Wi=class extends Bo{constructor(e){super()}}});var Ug=P(()=>{Lg()});function jE(i){let e=i.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Mg(i,e){let r=jE(i);return typeof r>"u"?!1:new RegExp(e).test(r)}function $E(i){return Mg(i,VE)}function qo(i){return Mg(i,KE)}function gu(i){return new RegExp("wss?://localhost(:d{2,5})?").test(i)}var VE,KE,Fg=P(()=>{VE="^https?:",KE="^wss?:"});function mu(i){return typeof i=="object"&&"id"in i&&"jsonrpc"in i&&i.jsonrpc==="2.0"}function Jr(i){return mu(i)&&"method"in i}function Ht(i){return mu(i)&&(Ve(i)||Le(i))}function Ve(i){return"result"in i}function Le(i){return"error"in i}function HE(i){return"error"in i&&i.valid===!1}var kg=P(()=>{});var Ke={};Se(Ke,{DEFAULT_ERROR:()=>Hi,IBaseJsonRpcProvider:()=>Bo,IEvents:()=>Gi,IJsonRpcConnection:()=>pu,IJsonRpcProvider:()=>Wi,INTERNAL_ERROR:()=>No,INVALID_PARAMS:()=>Eg,INVALID_REQUEST:()=>wg,METHOD_NOT_FOUND:()=>bg,PARSE_ERROR:()=>yg,RESERVED_ERROR_CODES:()=>uu,SERVER_ERROR:()=>$i,SERVER_ERROR_CODE_RANGE:()=>Ao,STANDARD_ERROR_MAP:()=>Kt,formatErrorMessage:()=>Ag,formatJsonRpcError:()=>gr,formatJsonRpcRequest:()=>st,formatJsonRpcResult:()=>Wr,getBigIntRpcId:()=>it,getError:()=>Lo,getErrorByCode:()=>Uo,isHttpUrl:()=>$E,isJsonRpcError:()=>Le,isJsonRpcPayload:()=>mu,isJsonRpcRequest:()=>Jr,isJsonRpcResponse:()=>Ht,isJsonRpcResult:()=>Ve,isJsonRpcValidationInvalid:()=>HE,isLocalhostUrl:()=>gu,isNodeJs:()=>Cg,isReservedErrorCode:()=>Po,isServerErrorCode:()=>UE,isValidDefaultRoute:()=>Fo,isValidErrorCode:()=>_g,isValidLeadingWildcardRoute:()=>qE,isValidRoute:()=>BE,isValidTrailingWildcardRoute:()=>zE,isValidWildcardRoute:()=>ko,isWsUrl:()=>qo,parseConnectionError:()=>hu,payloadId:()=>gt,validateJsonRpcError:()=>ME});var Ji=P(()=>{Oo();lu();Ng();Me(Ke,Pe);Og();Pg();Ug();Fg();kg()});var Bg,zo,qg=P(()=>{Bg=pe(Yt());Ji();zo=class extends Wi{constructor(e){super(e),this.events=new Bg.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(st(e.method,e.params||[],e.id||it().toString()),r)}async requestStrict(e,r){return new Promise(async(t,s)=>{if(!this.connection.connected)try{await this.open()}catch(n){s(n)}this.events.on(`${e.id}`,n=>{Le(n)?s(n.error):t(n.result)});try{await this.connection.send(e,r)}catch(n){s(n)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Ht(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}});var Vg=oe((w6,zg)=>{"use strict";zg.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var $g,GE,WE,Kg,jg,JE,Vo,Hg=P(()=>{$g=pe(Yt());Sr();Ji();GE=()=>typeof WebSocket<"u"?WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Vg(),WE=()=>typeof WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Kg=i=>i.split("?")[0],jg=10,JE=GE(),Vo=class{constructor(e){if(this.url=e,this.events=new $g.EventEmitter,this.registering=!1,!qo(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send($e(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!qo(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((t,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));t(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,t)=>{let s=new URLSearchParams(e).get("origin"),n=(0,Ke.isReactNative)()?{headers:{origin:s}}:{rejectUnauthorized:!gu(e)},o=new JE(e,[],n);WE()?o.onerror=a=>{let c=a;t(this.emitError(c.error))}:o.on("error",a=>{t(this.emitError(a))}),o.onopen=()=>{this.onOpen(o),r(o)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let r=typeof e.data=="string"?ut(e.data):e.data;this.events.emit("payload",r)}onError(e,r){let t=this.parseError(r),s=t.message||t.toString(),n=gr(e,s);this.events.emit("payload",n)}parseError(e,r=this.url){return hu(e,Kg(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>jg&&this.events.setMaxListeners(jg)}emitError(e){let r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Kg(this.url)}`));return this.events.emit("register_error",r),r}}});function Yi(i,e){if(i===e)return!0;if(i&&e&&typeof i=="object"&&typeof e=="object"){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let t=0;t{});function A_(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),t=0;t>>0,S=new Uint8Array(I);v!==x;){for(var T=g[v],L=0,y=I-1;(T!==0||L>>0,S[y]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");b=L,v++}for(var m=I-b;m!==I&&S[m]===0;)m++;for(var k=c.repeat(w);m>>0,I=new Uint8Array(x);g[w];){var S=r[g.charCodeAt(w)];if(S===255)return;for(var T=0,L=x-1;(S!==0||T>>0,I[L]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");v=T,w++}if(g[w]!==" "){for(var y=x-v;y!==x&&I[y]===0;)y++;for(var m=new Uint8Array(b+(x-y)),k=b;y!==x;)m[k++]=I[y++];return m}}}function f(g){var w=p(g);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:f}}function wv(i){return i.reduce((e,r)=>(e+=mv[r],e),"")}function bv(i){let e=[];for(let r of i){let t=yv[r.codePointAt(0)];if(t===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}function x0(i,e,r){e=e||[],r=r||0;for(var t=r;i>=Iv;)e[r++]=i&255|Yg,i/=128;for(;i&Sv;)e[r++]=i&255|Yg,i>>>=7;return e[r]=i|0,x0.bytes=r-t+1,e}function Su(i,t){var r=0,t=t||0,s=0,n=t,o,a=i.length;do{if(n>=a)throw Su.bytes=0,new RangeError("Could not decode varint");o=i[n++],r+=s<28?(o&Xg)<=Tv);return Su.bytes=n-t,r}function Hv(i=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(i):new Uint8Array(i)}function C0(i,e,r,t){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:r},decoder:{decode:t}}}function Wv(i,e="utf8"){let r=Gv[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(i,"utf8"):r.decoder.decode(`${r.prefix}${i}`)}var Ct,ie,g0,m0,y0,Vu,wt,YE,XE,QE,Wg,ZE,e_,t_,r_,i_,s_,n_,Ku,o_,w0,a_,Ue,c_,Je,u_,bu,de,h_,l_,Jg,mt,d_,f_,p_,g_,m_,Xi,Gt,nt,y_,w_,b_,je,E_,__,v_,b0,Yr,x_,S_,I_,D_,ot,yt,Ye,Wt,Jt,Xr,T_,R_,C_,N_,O_,P_,E0,L_,U_,Eu,_u,vu,_0,xu,Ko,es,M_,F_,Te,k_,B_,q_,z_,V_,K_,j_,$_,H_,G_,W_,J_,Y_,X_,Q_,Z_,ev,tv,rv,iv,sv,nv,ov,av,cv,uv,hv,lv,dv,fv,pv,gv,v0,mv,yv,Ev,_v,vv,Yg,xv,Sv,Iv,Dv,Tv,Xg,Rv,Cv,Nv,Av,Ov,Pv,Lv,Uv,Mv,Fv,kv,S0,Qg,Zg,Iu,Du,I0,Tu,D0,Bv,qv,zv,T0,Vv,R0,Kv,jv,$v,e0,t0,yu,Gv,Ru,Cu,Nu,Au,Ou,Jv,Yv,Xv,r0,Qv,Zv,i0,Qi,wu,Pu,ex,s0,tx,rx,n0,o0,Lu,ix,a0,sx,nx,c0,u0,bt,Uu,Mu,Fu,ku,Bu,ox,h0,ax,cx,l0,Zi,qu,ux,d0,hx,lx,f0,p0,zu,N0,A0=P(()=>{Ct=pe(Yt());qh();Jh();ya();wa();ie=pe(xr());Sr();Qn();Qn();ji();Fc();qg();Ji();Hg();Gg();g0=pe(Zn()),m0="wc",y0=2,Vu="core",wt=`${m0}@2:${Vu}:`,YE={name:Vu,logger:"error"},XE={database:":memory:"},QE="crypto",Wg="client_ed25519_seed",ZE=ie.ONE_DAY,e_="keychain",t_="0.3",r_="messages",i_="0.3",s_=ie.SIX_HOURS,n_="publisher",Ku="irn",o_="error",w0="wss://relay.walletconnect.org",a_="relayer",Ue={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},c_="_subscription",Je={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},u_=.1,bu="2.17.1",de={link_mode:"link_mode",relay:"relay"},h_="0.3",l_="WALLETCONNECT_CLIENT_ID",Jg="WALLETCONNECT_LINK_MODE_APPS",mt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},d_="subscription",f_="0.3",p_=ie.FIVE_SECONDS*1e3,g_="pairing",m_="0.3",Xi={wc_pairingDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:0},res:{ttl:ie.ONE_DAY,prompt:!1,tag:0}}},Gt={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},nt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},y_="history",w_="0.3",b_="expirer",je={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},E_="0.3",__="verify-api",v_="https://verify.walletconnect.com",b0="https://verify.walletconnect.org",Yr=b0,x_=`${Yr}/v3`,S_=[v_,b0],I_="echo",D_="https://echo.walletconnect.com",ot={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},yt={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Ye={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Wt={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Jt={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Xr={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},T_=.1,R_="event-client",C_=86400,N_="https://pulse.walletconnect.org/batch";O_=A_,P_=O_,E0=i=>{if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")},L_=i=>new TextEncoder().encode(i),U_=i=>new TextDecoder().decode(i),Eu=class{constructor(e,r,t){this.name=e,this.prefix=r,this.baseEncode=t}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},_u=class{constructor(e,r,t){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=t}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return _0(this,e)}},vu=class{constructor(e){this.decoders=e}or(e){return _0(this,e)}decode(e){let r=e[0],t=this.decoders[r];if(t)return t.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},_0=(i,e)=>new vu({...i.decoders||{[i.prefix]:i},...e.decoders||{[e.prefix]:e}}),xu=class{constructor(e,r,t,s){this.name=e,this.prefix=r,this.baseEncode=t,this.baseDecode=s,this.encoder=new Eu(e,r,t),this.decoder=new _u(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ko=({name:i,prefix:e,encode:r,decode:t})=>new xu(i,e,r,t),es=({prefix:i,name:e,alphabet:r})=>{let{encode:t,decode:s}=P_(r,e);return Ko({prefix:i,name:e,encode:t,decode:n=>E0(s(n))})},M_=(i,e,r,t)=>{let s={};for(let d=0;d=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},F_=(i,e,r)=>{let t=e[e.length-1]==="=",s=(1<r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<Ko({prefix:e,name:i,encode(s){return F_(s,t,r)},decode(s){return M_(s,t,r,i)}}),k_=Ko({prefix:"\0",name:"identity",encode:i=>U_(i),decode:i=>L_(i)}),B_=Object.freeze({__proto__:null,identity:k_}),q_=Te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),z_=Object.freeze({__proto__:null,base2:q_}),V_=Te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),K_=Object.freeze({__proto__:null,base8:V_}),j_=es({prefix:"9",name:"base10",alphabet:"0123456789"}),$_=Object.freeze({__proto__:null,base10:j_}),H_=Te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),G_=Te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),W_=Object.freeze({__proto__:null,base16:H_,base16upper:G_}),J_=Te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Y_=Te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),X_=Te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q_=Te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Z_=Te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ev=Te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tv=Te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rv=Te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),iv=Te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),sv=Object.freeze({__proto__:null,base32:J_,base32upper:Y_,base32pad:X_,base32padupper:Q_,base32hex:Z_,base32hexupper:ev,base32hexpad:tv,base32hexpadupper:rv,base32z:iv}),nv=es({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ov=es({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),av=Object.freeze({__proto__:null,base36:nv,base36upper:ov}),cv=es({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uv=es({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),hv=Object.freeze({__proto__:null,base58btc:cv,base58flickr:uv}),lv=Te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),dv=Te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fv=Te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),pv=Te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),gv=Object.freeze({__proto__:null,base64:lv,base64pad:dv,base64url:fv,base64urlpad:pv}),v0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),mv=v0.reduce((i,e,r)=>(i[r]=e,i),[]),yv=v0.reduce((i,e,r)=>(i[e.codePointAt(0)]=r,i),[]);Ev=Ko({prefix:"\u{1F680}",name:"base256emoji",encode:wv,decode:bv}),_v=Object.freeze({__proto__:null,base256emoji:Ev}),vv=x0,Yg=128,xv=127,Sv=~xv,Iv=Math.pow(2,31);Dv=Su,Tv=128,Xg=127;Rv=Math.pow(2,7),Cv=Math.pow(2,14),Nv=Math.pow(2,21),Av=Math.pow(2,28),Ov=Math.pow(2,35),Pv=Math.pow(2,42),Lv=Math.pow(2,49),Uv=Math.pow(2,56),Mv=Math.pow(2,63),Fv=function(i){return i(S0.encode(i,e,r),e),Zg=i=>S0.encodingLength(i),Iu=(i,e)=>{let r=e.byteLength,t=Zg(i),s=t+Zg(r),n=new Uint8Array(s+r);return Qg(i,n,0),Qg(r,n,t),n.set(e,s),new Du(i,r,e,n)},Du=class{constructor(e,r,t,s){this.code=e,this.size=r,this.digest=t,this.bytes=s}},I0=({name:i,code:e,encode:r})=>new Tu(i,e,r),Tu=class{constructor(e,r,t){this.name=e,this.code=r,this.encode=t}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Iu(this.code,r):r.then(t=>Iu(this.code,t))}else throw Error("Unknown type, must be binary type")}},D0=i=>async e=>new Uint8Array(await crypto.subtle.digest(i,e)),Bv=I0({name:"sha2-256",code:18,encode:D0("SHA-256")}),qv=I0({name:"sha2-512",code:19,encode:D0("SHA-512")}),zv=Object.freeze({__proto__:null,sha256:Bv,sha512:qv}),T0=0,Vv="identity",R0=E0,Kv=i=>Iu(T0,R0(i)),jv={code:T0,name:Vv,encode:R0,digest:Kv},$v=Object.freeze({__proto__:null,identity:jv});new TextEncoder,new TextDecoder;e0={...B_,...z_,...K_,...$_,...W_,...sv,...av,...hv,...gv,..._v};({...zv,...$v});t0=C0("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),yu=C0("ascii","a",i=>{let e="a";for(let r=0;r{i=i.substring(1);let e=Hv(i.length);for(let r=0;r{if(!this.initialized){let t=await this.getKeyChain();typeof t<"u"&&(this.keychain=t),this.initialized=!0}},this.has=t=>(this.isInitialized(),this.keychain.has(t)),this.set=async(t,s)=>{this.isInitialized(),this.keychain.set(t,s),await this.persist()},this.get=t=>{this.isInitialized();let s=this.keychain.get(t);if(typeof s>"u"){let{message:n}=B("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return s},this.del=async t=>{this.isInitialized(),this.keychain.delete(t),await this.persist()},this.core=e,this.logger=Ie(r,this.name)}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Vc(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Kc(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Cu=class{constructor(e,r,t){this.core=e,this.logger=r,this.name=QE,this.randomSessionIdentifier=To(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();let s=await this.getClientSeed(),n=pc(s);return Xn(n.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let s=jp();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();let n=await this.getClientSeed(),o=pc(n),a=this.randomSessionIdentifier;return await Td(a,s,ZE,o)},this.generateSharedKey=(s,n,o)=>{this.isInitialized();let a=this.getPrivateKey(s),c=$p(a,n);return this.setSymKey(c,o)},this.setSymKey=async(s,n)=>{this.isInitialized();let o=n||jr(s);return await this.keychain.set(o,s),o},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s)},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s)},this.encode=async(s,n,o)=>{this.isInitialized();let a=Qc(o),c=$e(n);if(eu(a))return Wp(c,o?.encoding);if(Zc(a)){let p=a.senderPublicKey,f=a.receiverPublicKey;s=await this.generateSharedKey(p,f)}let h=this.getSymKey(s),{type:d,senderPublicKey:l}=a;return Gp({type:d,symKey:h,message:c,senderPublicKey:l,encoding:o?.encoding})},this.decode=async(s,n,o)=>{this.isInitialized();let a=Qp(n,o);if(eu(a)){let c=Yp(n,o?.encoding);return ut(c)}if(Zc(a)){let c=a.receiverPublicKey,h=a.senderPublicKey;s=await this.generateSharedKey(c,h)}try{let c=this.getSymKey(s),h=Jp({symKey:c,encoded:n,encoding:o?.encoding});return ut(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(s,n=pt)=>{let o=$r({encoded:s,encoding:n});return qt(o.type)},this.getPayloadSenderPublicKey=(s,n=pt)=>{let o=$r({encoded:s,encoding:n});return o.senderPublicKey?we(o.senderPublicKey,Ae):void 0},this.core=e,this.logger=Ie(r,this.name),this.keychain=t||new Ru(this.core,this.logger)}get context(){return Re(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Wg)}catch{e=To(),await this.keychain.set(Wg,e)}return Wv(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Nu=class extends Dn{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=r_,this.version=i_,this.initialized=!1,this.storagePrefix=wt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let t=await this.getRelayerMessages();typeof t<"u"&&(this.messages=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}finally{this.initialized=!0}}},this.set=async(t,s)=>{this.isInitialized();let n=rt(s),o=this.messages.get(t);return typeof o>"u"&&(o={}),typeof o[n]<"u"||(o[n]=s,this.messages.set(t,o),await this.persist()),n},this.get=t=>{this.isInitialized();let s=this.messages.get(t);return typeof s>"u"&&(s={}),s},this.has=(t,s)=>{this.isInitialized();let n=this.get(t),o=rt(s);return typeof n[o]<"u"},this.del=async t=>{this.isInitialized(),this.messages.delete(t),await this.persist()},this.logger=Ie(e,this.name),this.core=r}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Vc(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Kc(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Au=class extends Tn{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new Ct.EventEmitter,this.name=n_,this.queue=new Map,this.publishTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.failedPublishTimeout=(0,ie.toMiliseconds)(ie.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(t,s,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:t,message:s,opts:n}});let a=n?.ttl||s_,c=Ro(n),h=n?.prompt||!1,d=n?.tag||0,l=n?.id||it().toString(),p={topic:t,message:s,opts:{ttl:a,relay:c,prompt:h,tag:d,id:l,attestation:n?.attestation}},f=`Failed to publish payload, please try again. id:${l} tag:${d}`,g=Date.now(),w,b=1;try{for(;w===void 0;){if(Date.now()-g>this.publishTimeout)throw new Error(f);this.logger.trace({id:l,attempts:b},`publisher.publish - attempt ${b}`),w=await await pr(this.rpcPublish(t,s,a,c,h,d,l,n?.attestation).catch(v=>this.logger.warn(v)),this.publishTimeout,f),b++,w||await new Promise(v=>setTimeout(v,this.failedPublishTimeout))}this.relayer.events.emit(Ue.publish,p),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:l,topic:t,message:s,opts:n}})}catch(v){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(v),(o=n?.internal)!=null&&o.throwOnFailedPublish)throw v;this.queue.set(l,p)}},this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.relayer=e,this.logger=Ie(r,this.name),this.registerEventListeners()}get context(){return Re(this.logger)}rpcPublish(e,r,t,s,n,o,a,c){var h,d,l,p;let f={method:Hr(s.protocol).publish,params:{topic:e,message:r,ttl:t,prompt:n,tag:o,attestation:c},id:a};return De((h=f.params)==null?void 0:h.prompt)&&((d=f.params)==null||delete d.prompt),De((l=f.params)==null?void 0:l.tag)&&((p=f.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f}),this.relayer.request(f)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:r,message:t,opts:s}=e;await this.publish(r,t,s)})}registerEventListeners(){this.relayer.core.heartbeat.on(Xt.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ue.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ue.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Ou=class{constructor(){this.map=new Map,this.set=(e,r)=>{let t=this.get(e);this.exists(e,r)||this.map.set(e,[...t,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let t=this.get(e);if(!this.exists(e,r))return;let s=t.filter(n=>n!==r);if(!s.length){this.map.delete(e);return}this.map.set(e,s)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},Jv=Object.defineProperty,Yv=Object.defineProperties,Xv=Object.getOwnPropertyDescriptors,r0=Object.getOwnPropertySymbols,Qv=Object.prototype.hasOwnProperty,Zv=Object.prototype.propertyIsEnumerable,i0=(i,e,r)=>e in i?Jv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Qi=(i,e)=>{for(var r in e||(e={}))Qv.call(e,r)&&i0(i,r,e[r]);if(r0)for(var r of r0(e))Zv.call(e,r)&&i0(i,r,e[r]);return i},wu=(i,e)=>Yv(i,Xv(e)),Pu=class extends Nn{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Ou,this.events=new Ct.EventEmitter,this.name=d_,this.version=f_,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=wt,this.subscribeTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(t,s)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:s}});try{let n=Ro(s),o={topic:t,relay:n,transportType:s?.transportType};this.pending.set(t,o);let a=await this.rpcSubscribe(t,n,s);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:s}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}},this.unsubscribe=async(t,s)=>{await this.restartToComplete(),this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(t,s.id,s):await this.unsubscribeByTopic(t,s)},this.isSubscribed=async t=>{if(this.topics.includes(t))return!0;let s=`${this.pendingSubscriptionWatchLabel}_${t}`;return await new Promise((n,o)=>{let a=new ie.Watch;a.start(s);let c=setInterval(()=>{!this.pending.has(t)&&this.topics.includes(t)&&(clearInterval(c),a.stop(s),n(!0)),a.elapsed(s)>=p_&&(clearInterval(c),a.stop(s),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=Ie(r,this.name),this.clientId=""}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let t=!1;try{t=this.getSubscription(e).topic===r}catch{}return t}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){let t=this.topicMap.get(e);await Promise.all(t.map(async s=>await this.unsubscribeById(e,s,r)))}async unsubscribeById(e,r,t){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:t}});try{let s=Ro(t);await this.rpcUnsubscribe(e,r,s);let n=ce("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:t}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,r,t){var s;t?.transportType===de.relay&&await this.restartToComplete();let n={method:Hr(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let o=(s=t?.internal)==null?void 0:s.throwOnFailedPublish;try{let a=rt(e+this.clientId);if(t?.transportType===de.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(h=>this.logger.warn(h))},(0,ie.toMiliseconds)(ie.ONE_SECOND)),a;let c=await pr(this.relayer.request(n).catch(h=>this.logger.warn(h)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ue.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;let r=e[0].relay,t={method:Hr(r.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await pr(this.relayer.request(t).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ue.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let r=e[0].relay,t={method:Hr(r.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});let s;try{s=await await pr(this.relayer.request(t).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ue.connection_stalled)}return s}rpcUnsubscribe(e,r,t){let s={method:Hr(t.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,r){this.setSubscription(e,wu(Qi({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Qi({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,t){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,t),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,Qi({},r)),this.topicMap.set(r.topic,e),this.events.emit(mt.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let r=this.subscriptions.get(e);if(!r){let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});let t=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(t.topic,e),this.events.emit(mt.deleted,wu(Qi({},t),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(mt.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r"u"||!e.length)return;if(this.subscriptions.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let r=await this.rpcBatchSubscribe(e);Vt(r)&&this.onBatchSubscribe(r.map((t,s)=>wu(Qi({},e[s]),{id:t})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(r.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(r=>{e.push(r)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Xt.pulse,async()=>{await this.checkPending()}),this.events.on(mt.created,async e=>{let r=mt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(mt.deleted,async e=>{let r=mt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}},ex=Object.defineProperty,s0=Object.getOwnPropertySymbols,tx=Object.prototype.hasOwnProperty,rx=Object.prototype.propertyIsEnumerable,n0=(i,e,r)=>e in i?ex(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,o0=(i,e)=>{for(var r in e||(e={}))tx.call(e,r)&&n0(i,r,e[r]);if(s0)for(var r of s0(e))rx.call(e,r)&&n0(i,r,e[r]);return i},Lu=class extends Rn{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ct.EventEmitter,this.name=a_,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ie.toMiliseconds)(ie.THIRTY_SECONDS+ie.ONE_SECOND),this.request=async r=>{var t,s;this.logger.debug("Publishing Request Payload");let n=r.id||it().toString();await this.toEstablishConnection();try{let o=this.provider.request(r);this.requestsInFlight.set(n,{promise:o,request:r}),this.logger.trace({id:n,method:r.method,topic:(t=r.params)==null?void 0:t.topic},"relayer.request - attempt to publish...");let a=await new Promise(async(c,h)=>{let d=()=>{h(new Error(`relayer.request - publish interrupted, id: ${n}`))};this.provider.on(Je.disconnect,d);let l=await o;this.provider.off(Je.disconnect,d),c(l)});return this.logger.trace({id:n,method:r.method,topic:(s=r.params)==null?void 0:s.topic},"relayer.request - published"),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}finally{this.requestsInFlight.delete(n)}},this.resetPingTimeout=()=>{if(Mi())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,t,s;(s=(t=(r=this.provider)==null?void 0:r.connection)==null?void 0:t.socket)==null||s.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r)}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ue.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Ue.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Je.payload,this.onPayloadHandler),this.provider.on(Je.connect,this.onConnectHandler),this.provider.on(Je.disconnect,this.onDisconnectHandler),this.provider.on(Je.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ie(e.logger,this.name):Pt(si({level:e.logger||o_})),this.messages=new Nu(this.logger,e.core),this.subscriber=new Pu(this,this.logger),this.publisher=new Au(this,this.logger),this.relayUrl=e?.relayUrl||w0,this.projectId=e.projectId,this.bundleId=Ap(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return Re(this.logger)}get connected(){var e,r,t;return((t=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:t.readyState)===1}get connecting(){var e,r,t;return((t=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:t.readyState)===0}async publish(e,r,t){this.isInitialized(),await this.publisher.publish(e,r,t),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:de.relay})}async subscribe(e,r){var t,s,n;this.isInitialized(),r?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((t=r?.internal)==null?void 0:t.throwOnFailedPublish)>"u"?!0:(s=r?.internal)==null?void 0:s.throwOnFailedPublish,a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c,h=d=>{d.topic===e&&(this.subscriber.off(mt.created,h),c())};return await Promise.all([new Promise(d=>{c=d,this.subscriber.on(mt.created,h)}),new Promise(async(d,l)=>{a=await this.subscriber.subscribe(e,o0({internal:{throwOnFailedPublish:o}},r)).catch(p=>{o&&l(p)})||a,d()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await pr(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(r,t)=>{let s=()=>{this.provider.off(Je.disconnect,s),t(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Je.disconnect,s),await pr(this.provider.connect(),(0,ie.toMiliseconds)(ie.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(n=>{t(n)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(n=>{this.logger.error(n),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){this.logger.error(r);let t=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(t.message))throw r}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await cu())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let r=e.sort((t,s)=>t.publishedAt-s.publishedAt);this.logger.trace(`Batch of ${r.length} message events sorted`);for(let t of r)try{await this.onMessageEvent(t)}catch(s){this.logger.warn(s)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){let{topic:t}=e;if(!r.sessionExists){let s=ve(ie.FIVE_MINUTES),n={topic:t,expiry:s,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(t,n)}this.events.emit(Ue.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,r,t,s,n;if(Mi())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((n=(s=(t=this.provider)==null?void 0:t.connection)==null?void 0:s.socket)==null||n.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(r=>e.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new zo(new Vo(Op({sdkVersion:bu,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:r,message:t}=e;await this.messages.set(r,t)}async shouldIgnoreMessageEvent(e){let{topic:r,message:t}=e;if(!t||t.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${t}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;let s=this.messages.has(r,t);return s&&this.logger.debug(`Ignoring duplicate message: ${t}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Jr(e)){if(!e.method.endsWith(c_))return;let r=e.params,{topic:t,message:s,publishedAt:n,attestation:o}=r.data,a={topic:t,message:s,publishedAt:n,transportType:de.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(o0({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Ht(e)&&this.events.emit(Ue.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ue.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let r=Wr(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Je.payload,this.onPayloadHandler),this.provider.off(Je.connect,this.onConnectHandler),this.provider.off(Je.disconnect,this.onDisconnectHandler),this.provider.off(Je.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await cu();mg(async r=>{e!==r&&(e=r,r?await this.restartTransport().catch(t=>this.logger.error(t)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ue.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ie.toMiliseconds)(u_))))}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},ix=Object.defineProperty,a0=Object.getOwnPropertySymbols,sx=Object.prototype.hasOwnProperty,nx=Object.prototype.propertyIsEnumerable,c0=(i,e,r)=>e in i?ix(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,u0=(i,e)=>{for(var r in e||(e={}))sx.call(e,r)&&c0(i,r,e[r]);if(a0)for(var r of a0(e))nx.call(e,r)&&c0(i,r,e[r]);return i},bt=class extends Cn{constructor(e,r,t,s=wt,n=void 0){super(e,r,t,s),this.core=e,this.logger=r,this.name=t,this.map=new Map,this.version=h_,this.cached=[],this.initialized=!1,this.storagePrefix=wt,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!De(o)?this.map.set(this.getKey(o),o):rg(o)?this.map.set(o.id,o):ig(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>Yi(a[c],o[c]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let c=u0(u0({},this.getData(o)),a);this.map.set(o,c),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Ie(r,this.name),this.storagePrefix=s,this.getKey=n}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){let{message:s}=B("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Uu=class{constructor(e,r){this.core=e,this.logger=r,this.name=g_,this.version=m_,this.events=new Ct.default,this.initialized=!1,this.storagePrefix=wt,this.ignoredPayloadTypes=[tt],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:t})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...t])]},this.create=async t=>{this.isInitialized();let s=To(),n=await this.core.crypto.setSymKey(s),o=ve(ie.FIVE_MINUTES),a={protocol:Ku},c={topic:n,expiry:o,relay:a,active:!1,methods:t?.methods},h=ru({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:t?.methods});return this.events.emit(Gt.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:t?.transportType}),{topic:n,uri:h}},this.pair=async t=>{this.isInitialized();let s=this.core.eventClient.createEvent({properties:{topic:t?.uri,trace:[ot.pairing_started]}});this.isValidPair(t,s);let{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:h}=tu(t.uri);s.props.properties.topic=n,s.addTrace(ot.pairing_uri_validation_success),s.addTrace(ot.pairing_uri_not_expired);let d;if(this.pairings.keys.includes(n)){if(d=this.pairings.get(n),s.addTrace(ot.existing_pairing),d.active)throw s.setError(yt.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(ot.pairing_not_expired)}let l=c||ve(ie.FIVE_MINUTES),p={topic:n,relay:a,expiry:l,active:!1,methods:h};this.core.expirer.set(n,l),await this.pairings.set(n,p),s.addTrace(ot.store_new_pairing),t.activatePairing&&await this.activate({topic:n}),this.events.emit(Gt.create,p),s.addTrace(ot.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(ot.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{s.setError(yt.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(f){throw s.setError(yt.subscribe_pairing_topic_failure),f}return s.addTrace(ot.subscribe_pairing_topic_success),p},this.activate=async({topic:t})=>{this.isInitialized();let s=ve(ie.THIRTY_DAYS);this.core.expirer.set(t,s),await this.pairings.update(t,{active:!0,expiry:s})},this.ping=async t=>{this.isInitialized(),await this.isValidPing(t);let{topic:s}=t;if(this.pairings.keys.includes(s)){let n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Rt();this.events.once(se("pairing_ping",n),({error:h})=>{h?c(h):a()}),await o()}},this.updateExpiry=async({topic:t,expiry:s})=>{this.isInitialized(),await this.pairings.update(t,{expiry:s})},this.updateMetadata=async({topic:t,metadata:s})=>{this.isInitialized(),await this.pairings.update(t,{peerMetadata:s})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async t=>{this.isInitialized(),await this.isValidDisconnect(t);let{topic:s}=t;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",ce("USER_DISCONNECTED")),await this.deletePairing(s))},this.formatUriFromPairing=t=>{this.isInitialized();let{topic:s,relay:n,expiry:o,methods:a}=t,c=this.core.crypto.keychain.get(s);return ru({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:c,relay:n,expiryTimestamp:o,methods:a})},this.sendRequest=async(t,s,n)=>{let o=st(s,n),a=await this.core.crypto.encode(t,o),c=Xi[s].req;return this.core.history.set(t,o),this.core.relayer.publish(t,a,c),o.id},this.sendResult=async(t,s,n)=>{let o=Wr(t,n),a=await this.core.crypto.encode(s,o),c=await this.core.history.get(s,t),h=Xi[c.request.method].res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o)},this.sendError=async(t,s,n)=>{let o=gr(t,n),a=await this.core.crypto.encode(s,o),c=await this.core.history.get(s,t),h=Xi[c.request.method]?Xi[c.request.method].res:Xi.unregistered_method.res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o)},this.deletePairing=async(t,s)=>{await this.core.relayer.unsubscribe(t),await Promise.all([this.pairings.delete(t,ce("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(t),s?Promise.resolve():this.core.expirer.del(t)])},this.cleanup=async()=>{let t=this.pairings.getAll().filter(s=>ft(s.expiry));await Promise.all(t.map(s=>this.deletePairing(s.topic)))},this.onRelayEventRequest=t=>{let{topic:s,payload:n}=t;switch(n.method){case"wc_pairingPing":return this.onPairingPingRequest(s,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,n);default:return this.onUnknownRpcMethodRequest(s,n)}},this.onRelayEventResponse=async t=>{let{topic:s,payload:n}=t,o=(await this.core.history.get(s,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,n);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(t,s)=>{let{id:n}=s;try{this.isValidPing({topic:t}),await this.sendResult(n,t,!0),this.events.emit(Gt.ping,{id:n,topic:t})}catch(o){await this.sendError(n,t,o),this.logger.error(o)}},this.onPairingPingResponse=(t,s)=>{let{id:n}=s;setTimeout(()=>{Ve(s)?this.events.emit(se("pairing_ping",n),{}):Le(s)&&this.events.emit(se("pairing_ping",n),{error:s.error})},500)},this.onPairingDeleteRequest=async(t,s)=>{let{id:n}=s;try{this.isValidDisconnect({topic:t}),await this.deletePairing(t),this.events.emit(Gt.delete,{id:n,topic:t})}catch(o){await this.sendError(n,t,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(t,s)=>{let{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;let a=ce("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,t,a),this.logger.error(a)}catch(a){await this.sendError(n,t,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=t=>{this.registeredMethods.includes(t)||this.logger.error(ce("WC_METHOD_UNSUPPORTED",t))},this.isValidPair=(t,s)=>{var n;if(!Oe(t)){let{message:a}=B("MISSING_OR_INVALID",`pair() params: ${t}`);throw s.setError(yt.malformed_pairing_uri),new Error(a)}if(!tg(t.uri)){let{message:a}=B("MISSING_OR_INVALID",`pair() uri: ${t.uri}`);throw s.setError(yt.malformed_pairing_uri),new Error(a)}let o=tu(t?.uri);if(!((n=o?.relay)!=null&&n.protocol)){let{message:a}=B("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(yt.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=B("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(yt.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0,ie.toMiliseconds)(o?.expiryTimestamp){if(!Oe(t)){let{message:n}=B("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:s}=t;await this.isValidPairingTopic(s)},this.isValidDisconnect=async t=>{if(!Oe(t)){let{message:n}=B("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:s}=t;await this.isValidPairingTopic(s)},this.isValidPairingTopic=async t=>{if(!me(t,!1)){let{message:s}=B("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(s)}if(!this.pairings.keys.includes(t)){let{message:s}=B("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(s)}if(ft(this.pairings.get(t).expiry)){await this.deletePairing(t);let{message:s}=B("EXPIRED",`pairing topic: ${t}`);throw new Error(s)}},this.core=e,this.logger=Ie(r,this.name),this.pairings=new bt(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Re(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ue.message,async e=>{let{topic:r,message:t,transportType:s}=e;if(!this.pairings.keys.includes(r)||s===de.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(t)))return;let n=await this.core.crypto.decode(r,t);try{Jr(n)?(this.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Ht(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:r,payload:n}),this.core.history.delete(r,n.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(je.expired,async e=>{let{topic:r}=Io(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Gt.expire,{topic:r}))})}},Mu=class extends In{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new Ct.EventEmitter,this.name=y_,this.version=w_,this.cached=[],this.initialized=!1,this.storagePrefix=wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(t=>this.records.set(t.id,t)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(t,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:t,request:s,chainId:n}),this.records.has(s.id))return;let o={id:s.id,topic:t,request:{method:s.method,params:s.params||null},chainId:n,expiry:ve(ie.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(nt.created,o)},this.resolve=async t=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:t}),!this.records.has(t.id))return;let s=await this.getRecord(t.id);typeof s.response>"u"&&(s.response=Le(t)?{error:t.error}:{result:t.result},this.records.set(s.id,s),this.persist(),this.events.emit(nt.updated,s))},this.get=async(t,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:t,id:s}),await this.getRecord(s)),this.delete=(t,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===t){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(nt.deleted,n)}}),this.persist()},this.exists=async(t,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===t:!1),this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.logger=Ie(r,this.name)}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;let t={topic:r.topic,request:st(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(t)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let r=this.records.get(e);if(!r){let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(nt.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(nt.created,e=>{let r=nt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(nt.updated,e=>{let r=nt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(nt.deleted,e=>{let r=nt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(Xt.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{(0,ie.toMiliseconds)(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(nt.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Fu=class extends An{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new Ct.EventEmitter,this.name=b_,this.version=E_,this.cached=[],this.initialized=!1,this.storagePrefix=wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(t=>this.expirations.set(t.target,t)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=t=>{try{let s=this.formatTarget(t);return typeof this.getExpiration(s)<"u"}catch{return!1}},this.set=(t,s)=>{this.isInitialized();let n=this.formatTarget(t),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(je.created,{target:n,expiration:o})},this.get=t=>{this.isInitialized();let s=this.formatTarget(t);return this.getExpiration(s)},this.del=t=>{if(this.isInitialized(),this.has(t)){let s=this.formatTarget(t),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(je.deleted,{target:s,expiration:n})}},this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.logger=Ie(r,this.name)}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Lp(e);if(typeof e=="number")return Up(e);let{message:r}=B("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(je.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let r=this.expirations.get(e);if(!r){let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return r}checkExpiry(e,r){let{expiry:t}=r;(0,ie.toMiliseconds)(t)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(je.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Xt.pulse,()=>this.checkExpirations()),this.events.on(je.created,e=>{let r=je.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(je.expired,e=>{let r=je.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(je.deleted,e=>{let r=je.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},ku=class extends On{constructor(e,r,t){super(e,r,t),this.core=e,this.logger=r,this.store=t,this.name=__,this.verifyUrlV3=x_,this.storagePrefix=wt,this.version=y0,this.init=async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ie.toMiliseconds)((s=this.publicKey)==null?void 0:s.expiresAt){if(!qr()||this.isDevEnv)return;let n=window.location.origin,{id:o,decryptedId:a}=s,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{let h=(0,g0.getDocument)(),d=this.startAbortTimer(ie.ONE_SECOND*5),l=await new Promise((p,f)=>{let g=()=>{window.removeEventListener("message",b),h.body.removeChild(w),f("attestation aborted")};this.abortController.signal.addEventListener("abort",g);let w=h.createElement("iframe");w.src=c,w.style.display="none",w.addEventListener("error",g,{signal:this.abortController.signal});let b=v=>{if(v.data&&typeof v.data=="string")try{let x=JSON.parse(v.data);if(x.type==="verify_attestation"){if(Lr(x.attestation).payload.id!==o)return;clearInterval(d),h.body.removeChild(w),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",b),p(x.attestation===null?"":x.attestation)}}catch(x){this.logger.warn(x)}};h.body.appendChild(w),window.addEventListener("message",b,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",l),l}catch(h){this.logger.warn(h)}return""},this.resolve=async s=>{if(this.isDevEnv)return"";let{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(Lr(n).payload.id!==a)return;let h=await this.isValidJwtAttestation(n);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;let c=this.getVerifyUrl(s?.verifyUrl);return this.fetchAttestation(o,c)},this.fetchAttestation=async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);let o=this.startAbortTimer(ie.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=s=>{let n=s||Yr;return S_.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${Yr}`),n=Yr),n},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let s=this.startAbortTimer(ie.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s)}},this.persistPublicKey=async s=>{this.logger.debug("persisting public key to local storage",s),await this.store.setItem(this.storeKey,s),this.publicKey=s},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async s=>{let n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});let s=await this.fetchPromise;return this.fetchPromise=void 0,s},this.validateAttestation=(s,n)=>{let o=Zp(s,n.publicKey),a={hasExpired:(0,ie.toMiliseconds)(o.exp)this.abortController.abort(),(0,ie.toMiliseconds)(e))}},Bu=class extends Pn{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=I_,this.registerDeviceToken=async t=>{let{clientId:s,token:n,notificationType:o,enableEncrypted:a=!1}=t,c=`${D_}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})})},this.logger=Ie(r,this.context)}},ox=Object.defineProperty,h0=Object.getOwnPropertySymbols,ax=Object.prototype.hasOwnProperty,cx=Object.prototype.propertyIsEnumerable,l0=(i,e,r)=>e in i?ox(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Zi=(i,e)=>{for(var r in e||(e={}))ax.call(e,r)&&l0(i,r,e[r]);if(h0)for(var r of h0(e))cx.call(e,r)&&l0(i,r,e[r]);return i},qu=class extends Ln{constructor(e,r,t=!0){super(e,r,t),this.core=e,this.logger=r,this.context=R_,this.storagePrefix=wt,this.storageVersion=T_,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!ki())try{let s={eventId:$c(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:zc(this.core.relayer.protocol,this.core.relayer.version,bu)}}};await this.sendEvent([s])}catch(s){this.logger.warn(s)}},this.createEvent=s=>{let{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=s,h=$c(),d=this.core.projectId||"",l=Date.now(),p=Zi({eventId:h,timestamp:l,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:d,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,p),this.shouldPersist=!0),p},this.getEvent=s=>{let{eventId:n,topic:o}=s;if(n)return this.events.get(n);let a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Zi(Zi({},a),this.setMethods(a.eventId))},this.deleteEvent=s=>{let{eventId:n}=s;this.events.delete(n),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Xt.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{(0,ie.fromMiliseconds)(Date.now())-(0,ie.fromMiliseconds)(s.timestamp)>C_&&(this.events.delete(s.eventId),this.shouldPersist=!0)})})},this.setMethods=s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)}),this.addTrace=(s,n)=>{let o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=!0)},this.setError=(s,n)=>{let o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,Zi(Zi({},n),this.setMethods(n.eventId)))})}catch(s){this.logger.warn(s)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let s=[];for(let[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(let n of s)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}},this.sendEvent=async s=>{let n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${N_}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${bu}${n}`,{method:"POST",body:JSON.stringify(s)})},this.getAppDomain=()=>zr().url,this.logger=Ie(r,this.context),this.telemetryEnabled=t,t?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},ux=Object.defineProperty,d0=Object.getOwnPropertySymbols,hx=Object.prototype.hasOwnProperty,lx=Object.prototype.propertyIsEnumerable,f0=(i,e,r)=>e in i?ux(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,p0=(i,e)=>{for(var r in e||(e={}))hx.call(e,r)&&f0(i,r,e[r]);if(d0)for(var r of d0(e))lx.call(e,r)&&f0(i,r,e[r]);return i},zu=class i extends Sn{constructor(e){var r;super(e),this.protocol=m0,this.version=y0,this.name=Vu,this.events=new Ct.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;let h={topic:o,message:a,publishedAt:Date.now(),transportType:de.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:c})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||w0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let t=si({level:typeof e?.logger=="string"&&e.logger?e.logger:YE.logger}),{logger:s,chunkLoggerController:n}=Zh({opts:t,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=n,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ie(s,this.name),this.heartbeat=new gn,this.crypto=new Cu(this,this.logger,e?.keychain),this.history=new Mu(this,this.logger),this.expirer=new Fu(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new wn(p0(p0({},XE),e?.storageOptions)),this.relayer=new Lu({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Uu(this,this.logger),this.verify=new ku(this,this.logger,this.storage),this.echoClient=new Bu(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new qu(this,this.logger,e?.telemetryEnabled)}static async init(e){let r=new i(e);await r.initialize();let t=await r.crypto.getClientId();return await r.storage.setItem(l_,t),r}get context(){return Re(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Jg,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Jg)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},N0=zu});var Ho,ae,U0,M0,F0,eh,ju,O0,dx,fx,px,Qr,gx,xe,$u,Et,mx,yx,wx,bx,Ex,_x,vx,Go,jo,xx,Sx,Ix,P0,Dx,Tx,L0,Ee,at,Hu,Gu,Wu,Ju,Yu,Xu,Qu,Zu,$o,k0=P(()=>{A0();ya();wa();ji();Ho=pe(Yt()),ae=pe(xr());Ji();U0="wc",M0=2,F0="client",eh=`${U0}@${M0}:${F0}:`,ju={name:F0,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},O0="WALLETCONNECT_DEEPLINK_CHOICE",dx="proposal",fx="Proposal expired",px="session",Qr=ae.SEVEN_DAYS,gx="engine",xe={wc_sessionPropose:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1114},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:ae.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:ae.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1119}}},$u={min:ae.FIVE_MINUTES,max:ae.SEVEN_DAYS},Et={idle:"IDLE",active:"ACTIVE"},mx="request",yx=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],wx="wc",bx="auth",Ex="authKeys",_x="pairingTopics",vx="requests",Go=`${wx}@${1.5}:${bx}:`,jo=`${Go}:PUB_KEY`,xx=Object.defineProperty,Sx=Object.defineProperties,Ix=Object.getOwnPropertyDescriptors,P0=Object.getOwnPropertySymbols,Dx=Object.prototype.hasOwnProperty,Tx=Object.prototype.propertyIsEnumerable,L0=(i,e,r)=>e in i?xx(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Ee=(i,e)=>{for(var r in e||(e={}))Dx.call(e,r)&&L0(i,r,e[r]);if(P0)for(var r of P0(e))Tx.call(e,r)&&L0(i,r,e[r]);return i},at=(i,e)=>Sx(i,Ix(e)),Hu=class extends Mn{constructor(e){super(e),this.name=gx,this.events=new Ho.default,this.initialized=!1,this.requestQueue={state:Et.idle,queue:[]},this.sessionRequestQueue={state:Et.idle,queue:[]},this.requestQueueDelay=ae.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(xe)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,ae.toMiliseconds)(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let t=at(Ee({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(t);let{pairingTopic:s,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,relays:c}=t,h=s,d,l=!1;try{h&&(l=this.client.core.pairing.pairings.get(h).active)}catch(S){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),S}if(!h||!l){let{topic:S,uri:T}=await this.client.core.pairing.create();h=S,d=T}if(!h){let{message:S}=B("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(S)}let p=await this.client.core.crypto.generateKeyPair(),f=xe.wc_sessionPropose.req.ttl||ae.FIVE_MINUTES,g=ve(f),w=Ee({requiredNamespaces:n,optionalNamespaces:o,relays:c??[{protocol:Ku}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:h},a&&{sessionProperties:a}),{reject:b,resolve:v,done:x}=Rt(f,fx);this.events.once(se("session_connect"),async({error:S,session:T})=>{if(S)b(S);else if(T){T.self.publicKey=p;let L=at(Ee({},T),{pairingTopic:w.pairingTopic,requiredNamespaces:w.requiredNamespaces,optionalNamespaces:w.optionalNamespaces,transportType:de.relay});await this.client.session.set(T.topic,L),await this.setExpiry(T.topic,T.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:T.peer.metadata}),this.cleanupDuplicatePairings(L),v(L)}});let I=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0});return await this.setProposal(I,Ee({id:I},w)),{uri:d,approval:x}},this.pair=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(t){throw this.client.logger.error("pair() failed"),t}},this.approve=async r=>{var t,s,n;let o=this.client.core.eventClient.createEvent({properties:{topic:(t=r?.id)==null?void 0:t.toString(),trace:[Ye.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(m){throw o.setError(Wt.no_internet_connection),m}try{await this.isValidProposalId(r?.id)}catch(m){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(Wt.proposal_not_found),m}try{await this.isValidApprove(r)}catch(m){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Wt.session_approve_namespace_validation_failure),m}let{id:a,relayProtocol:c,namespaces:h,sessionProperties:d,sessionConfig:l}=r,p=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:f,proposer:g,requiredNamespaces:w,optionalNamespaces:b}=p,v=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:f});v||(v=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Ye.session_approve_started,properties:{topic:f,trace:[Ye.session_approve_started,Ye.session_namespaces_validation_success]}}));let x=await this.client.core.crypto.generateKeyPair(),I=g.publicKey,S=await this.client.core.crypto.generateSharedKey(x,I),T=Ee(Ee({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:x,metadata:this.client.metadata},expiry:ve(Qr)},d&&{sessionProperties:d}),l&&{sessionConfig:l}),L=de.relay;v.addTrace(Ye.subscribing_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:L})}catch(m){throw v.setError(Wt.subscribe_session_topic_failure),m}v.addTrace(Ye.subscribe_session_topic_success);let y=at(Ee({},T),{topic:S,requiredNamespaces:w,optionalNamespaces:b,pairingTopic:f,acknowledged:!1,self:T.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:x,transportType:de.relay});await this.client.session.set(S,y),v.addTrace(Ye.store_session);try{v.addTrace(Ye.publishing_session_settle),await this.sendRequest({topic:S,method:"wc_sessionSettle",params:T,throwOnFailedPublish:!0}).catch(m=>{throw v?.setError(Wt.session_settle_publish_failure),m}),v.addTrace(Ye.session_settle_publish_success),v.addTrace(Ye.publishing_session_approve),await this.sendResult({id:a,topic:f,result:{relay:{protocol:c??"irn"},responderPublicKey:x},throwOnFailedPublish:!0}).catch(m=>{throw v?.setError(Wt.session_approve_publish_failure),m}),v.addTrace(Ye.session_approve_publish_success)}catch(m){throw this.client.logger.error(m),this.client.session.delete(S,ce("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(S),m}return this.client.core.eventClient.deleteEvent({eventId:v.eventId}),await this.client.core.pairing.updateMetadata({topic:f,metadata:g.metadata}),await this.client.proposal.delete(a,ce("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(S,ve(Qr)),{topic:S,acknowledged:()=>Promise.resolve(this.client.session.get(S))}},this.reject=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:t,reason:s}=r,n;try{n=this.client.proposal.get(t).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),o}n&&(await this.sendError({id:t,topic:n,error:s,rpcOpts:xe.wc_sessionPropose.reject}),await this.client.proposal.delete(t,ce("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(l){throw this.client.logger.error("update() -> isValidUpdate() failed"),l}let{topic:t,namespaces:s}=r,{done:n,resolve:o,reject:a}=Rt(),c=gt(),h=it().toString(),d=this.client.session.get(t).namespaces;return this.events.once(se("session_update",c),({error:l})=>{l?a(l):o()}),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:h}).catch(l=>{this.client.logger.error(l),this.client.session.update(t,{namespaces:d}),a(l)}),{acknowledged:n}},this.extend=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}let{topic:t}=r,s=gt(),{done:n,resolve:o,reject:a}=Rt();return this.events.once(se("session_extend",s),({error:c})=>{c?a(c):o()}),await this.setExpiry(t,ve(Qr)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(g){throw this.client.logger.error("request() -> isValidRequest() failed"),g}let{chainId:t,request:s,topic:n,expiry:o=xe.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(n);a?.transportType===de.relay&&await this.confirmOnlineStateOrThrow();let c=gt(),h=it().toString(),{done:d,resolve:l,reject:p}=Rt(o,"Request expired. Please try again.");this.events.once(se("session_request",c),({error:g,result:w})=>{g?p(g):l(w)});let f=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return f?(await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:at(Ee({},s),{expiryTimestamp:ve(o)}),chainId:t},expiry:o,throwOnFailedPublish:!0,appLink:f}).catch(g=>p(g)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:t,id:c}),await d()):await Promise.all([new Promise(async g=>{await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:at(Ee({},s),{expiryTimestamp:ve(o)}),chainId:t},expiry:o,throwOnFailedPublish:!0}).catch(w=>p(w)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:t,id:c}),g()}),new Promise(async g=>{var w;if(!((w=a.sessionConfig)!=null&&w.disableDeepLink)){let b=await Fp(this.client.core.storage,O0);await Mp({id:c,topic:n,wcDeepLink:b})}g()}),d()]).then(g=>g[2])},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);let{topic:t,response:s}=r,{id:n}=s,o=this.client.session.get(t);o.transportType===de.relay&&await this.confirmOnlineStateOrThrow();let a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Ve(s)?await this.sendResult({id:n,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:a}):Le(s)&&await this.sendError({id:n,topic:t,error:s.error,appLink:a}),this.cleanupAfterResponse(r)},this.ping=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}let{topic:t}=r;if(this.client.session.keys.includes(t)){let s=gt(),n=it().toString(),{done:o,resolve:a,reject:c}=Rt();this.events.once(se("session_ping",s),({error:h})=>{h?c(h):a()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);let{topic:t,event:s,chainId:n}=r,o=it().toString();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:n},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);let{topic:t}=r;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:ce("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(t))await this.client.core.pairing.disconnect({topic:t});else{let{message:s}=B("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(s)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(t=>eg(t,r))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(r,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(r);let n=t&&this.client.core.linkModeSupportedApps.includes(t)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),o=n?de.link_mode:de.relay;o===de.relay&&await this.confirmOnlineStateOrThrow();let{chains:a,statement:c="",uri:h,domain:d,nonce:l,type:p,exp:f,nbf:g,methods:w=[],expiry:b}=r,v=[...r.resources||[]],{topic:x,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:x,uri:I}});let S=await this.client.core.crypto.generateKeyPair(),T=jr(S);if(await Promise.all([this.client.auth.authKeys.set(jo,{responseTopic:T,publicKey:S}),this.client.auth.pairingTopics.set(T,{topic:T,pairingTopic:x})]),await this.client.core.relayer.subscribe(T,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${x}`),w.length>0){let{namespace:j}=Ui(a[0]),re=qp(j,"request",w);qi(v)&&(re=zp(re,v.pop())),v.push(re)}let L=b&&b>xe.wc_sessionAuthenticate.req.ttl?b:xe.wc_sessionAuthenticate.req.ttl,y={authPayload:{type:p??"caip122",chains:a,statement:c,aud:h,domain:d,version:"1",nonce:l,iat:new Date().toISOString(),exp:f,nbf:g,resources:v},requester:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:ve(L)},m={eip155:{chains:a,methods:[...new Set(["personal_sign",...w])],events:["chainChanged","accountsChanged"]}},k={requiredNamespaces:{},optionalNamespaces:m,relays:[{protocol:"irn"}],pairingTopic:x,proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:ve(xe.wc_sessionPropose.req.ttl)},{done:$,resolve:O,reject:C}=Rt(L,"Request expired"),R=async({error:j,session:re})=>{if(this.events.off(se("session_request",G),N),j)C(j);else if(re){re.self.publicKey=S,await this.client.session.set(re.topic,re),await this.setExpiry(re.topic,re.expiry),x&&await this.client.core.pairing.updateMetadata({topic:x,metadata:re.peer.metadata});let Y=this.client.session.get(re.topic);await this.deleteProposal(H),O({session:Y})}},N=async j=>{var re,Y,Z;if(await this.deletePendingAuthRequest(G,{message:"fulfilled",code:0}),j.error){let D=ce("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return j.error.code===D.code?void 0:(this.events.off(se("session_connect"),R),C(j.error.message))}await this.deleteProposal(H),this.events.off(se("session_connect"),R);let{cacaos:V,responder:J}=j.result,X=[],u=[];for(let D of V){await Gc({cacao:D,projectId:this.client.core.projectId})||(this.client.logger.error(D,"Signature verification failed"),C(ce("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:A}=D,U=qi(A.resources),F=[Do(A.iss)],M=Bi(A.iss);if(U){let Q=Jc(U),z=Yc(U);X.push(...Q),F.push(...z)}for(let Q of F)u.push(`${Q}:${M}`)}let E=await this.client.core.crypto.generateSharedKey(S,J.publicKey),_;X.length>0&&(_={topic:E,acknowledged:!0,self:{publicKey:S,metadata:this.client.metadata},peer:J,controller:J.publicKey,expiry:ve(Qr),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:x,namespaces:iu([...new Set(X)],[...new Set(u)]),transportType:o},await this.client.core.relayer.subscribe(E,{transportType:o}),await this.client.session.set(E,_),x&&await this.client.core.pairing.updateMetadata({topic:x,metadata:J.metadata}),_=this.client.session.get(E)),(re=this.client.metadata.redirect)!=null&&re.linkMode&&(Y=J.metadata.redirect)!=null&&Y.linkMode&&(Z=J.metadata.redirect)!=null&&Z.universal&&t&&(this.client.core.addLinkModeSupportedApp(J.metadata.redirect.universal),this.client.session.update(E,{transportType:de.link_mode})),O({auths:V,session:_})},G=gt(),H=gt();this.events.once(se("session_connect"),R),this.events.once(se("session_request",G),N);let q;try{if(n){let j=st("wc_sessionAuthenticate",y,G);this.client.core.history.set(x,j);let re=await this.client.core.crypto.encode("",j,{type:Kr,encoding:Vr});q=Vi(t,x,re)}else await Promise.all([this.sendRequest({topic:x,method:"wc_sessionAuthenticate",params:y,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:G}),this.sendRequest({topic:x,method:"wc_sessionPropose",params:k,expiry:xe.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:H})])}catch(j){throw this.events.off(se("session_connect"),R),this.events.off(se("session_request",G),N),j}return await this.setProposal(H,Ee({id:H},k)),await this.setAuthRequest(G,{request:at(Ee({},y),{verifyContext:{}}),pairingTopic:x,transportType:o}),{uri:q??I,response:$}},this.approveSessionAuthenticate=async r=>{let{id:t,auths:s}=r,n=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[Jt.authenticated_session_approve_started]}});try{this.isInitialized()}catch(b){throw n.setError(Xr.no_internet_connection),b}let o=this.getPendingAuthRequest(t);if(!o)throw n.setError(Xr.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);let a=o.transportType||de.relay;a===de.relay&&await this.confirmOnlineStateOrThrow();let c=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=jr(c),l={type:tt,receiverPublicKey:c,senderPublicKey:h},p=[],f=[];for(let b of s){if(!await Gc({cacao:b,projectId:this.client.core.projectId})){n.setError(Xr.invalid_cacao);let T=ce("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:d,error:T,encodeOpts:l}),new Error(T.message)}n.addTrace(Jt.cacaos_verified);let{p:v}=b,x=qi(v.resources),I=[Do(v.iss)],S=Bi(v.iss);if(x){let T=Jc(x),L=Yc(x);p.push(...T),I.push(...L)}for(let T of I)f.push(`${T}:${S}`)}let g=await this.client.core.crypto.generateSharedKey(h,c);n.addTrace(Jt.create_authenticated_session_topic);let w;if(p?.length>0){w={topic:g,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:ve(Qr),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:iu([...new Set(p)],[...new Set(f)]),transportType:a},n.addTrace(Jt.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(b){throw n.setError(Xr.subscribe_authenticated_session_topic_failure),b}n.addTrace(Jt.subscribe_authenticated_session_topic_success),await this.client.session.set(g,w),n.addTrace(Jt.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Jt.publishing_authenticated_session_approve);try{await this.sendResult({topic:d,id:t,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(b){throw n.setError(Xr.authenticated_session_approve_publish_failure),b}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:w}},this.rejectSessionAuthenticate=async r=>{this.isInitialized();let{id:t,reason:s}=r,n=this.getPendingAuthRequest(t);if(!n)throw new Error(`Could not find pending auth request with id ${t}`);n.transportType===de.relay&&await this.confirmOnlineStateOrThrow();let o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=jr(o),h={type:tt,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:t,topic:c,error:s,encodeOpts:h,rpcOpts:xe.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,ce("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();let{request:t,iss:s}=r;return Wc(t,s)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)},this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{let t=this.client.core.pairing.pairings.get(r.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&n.topic&&n.topic!==t.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(t){this.client.logger.error(t)}},this.deleteSession=async r=>{var t;let{topic:s,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,ce("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),n||this.client.core.expirer.del(s),this.client.core.storage.removeItem(O0).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===s&&this.deletePendingSessionRequest(h.id,ce("USER_DISCONNECTED"))}),s===((t=this.sessionRequestQueue.queue[0])==null?void 0:t.topic)&&(this.sessionRequestQueue.state=Et.idle),o&&this.client.events.emit("session_delete",{id:a,topic:s})},this.deleteProposal=async(r,t)=>{if(t)try{let s=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:s.pairingTopic})?.setError(Wt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,ce("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")},this.deletePendingSessionRequest=async(r,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,t),s?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==r),s&&(this.sessionRequestQueue.state=Et.idle,this.client.events.emit("session_request_expire",{id:r}))},this.deletePendingAuthRequest=async(r,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(r,t),s?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,t)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,t),await this.client.session.update(r,{expiry:t}))},this.setProposal=async(r,t)=>{this.client.core.expirer.set(r,ve(xe.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,t)},this.setAuthRequest=async(r,t)=>{let{request:s,pairingTopic:n,transportType:o=de.relay}=t;this.client.core.expirer.set(r,s.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:r,pairingTopic:n,verifyContext:s.verifyContext,transportType:o})},this.setPendingSessionRequest=async r=>{let{id:t,topic:s,params:n,verifyContext:o}=r,a=n.request.expiryTimestamp||ve(xe.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,a),await this.client.pendingRequest.set(t,{id:t,topic:s,params:n,verifyContext:o})},this.sendRequest=async r=>{let{topic:t,method:s,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:h,appLink:d}=r,l=st(s,n,c),p,f=!!d;try{let b=f?Vr:pt;p=await this.client.core.crypto.encode(t,l,{encoding:b})}catch(b){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),b}let g;if(yx.includes(s)){let b=rt(JSON.stringify(l)),v=rt(p);g=await this.client.core.verify.register({id:v,decryptedId:b})}let w=xe[s].req;if(w.attestation=g,o&&(w.ttl=o),a&&(w.id=a),this.client.core.history.set(t,l),f){let b=Vi(d,t,p);await window.Linking.openURL(b,this.client.name)}else{let b=xe[s].req;o&&(b.ttl=o),a&&(b.id=a),h?(b.internal=at(Ee({},b.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,p,b)):this.client.core.relayer.publish(t,p,b).catch(v=>this.client.logger.error(v))}return l.id},this.sendResult=async r=>{let{id:t,topic:s,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,h=Wr(t,n),d,l=c&&typeof window?.Linking<"u";try{let f=l?Vr:pt;d=await this.client.core.crypto.encode(s,h,at(Ee({},a||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),f}let p;try{p=await this.client.core.history.get(s,t)}catch(f){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${t}) failed`),f}if(l){let f=Vi(c,s,d);await window.Linking.openURL(f,this.client.name)}else{let f=xe[p.request.method].res;o?(f.internal=at(Ee({},f.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,d,f)):this.client.core.relayer.publish(s,d,f).catch(g=>this.client.logger.error(g))}await this.client.core.history.resolve(h)},this.sendError=async r=>{let{id:t,topic:s,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=r,h=gr(t,n),d,l=c&&typeof window?.Linking<"u";try{let f=l?Vr:pt;d=await this.client.core.crypto.encode(s,h,at(Ee({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),f}let p;try{p=await this.client.core.history.get(s,t)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${s}, ${t}) failed`),f}if(l){let f=Vi(c,s,d);await window.Linking.openURL(f,this.client.name)}else{let f=a||xe[p.request.method].res;this.client.core.relayer.publish(s,d,f)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{let r=[],t=[];this.client.session.getAll().forEach(s=>{let n=!1;ft(s.expiry)&&(n=!0),this.client.core.crypto.keychain.has(s.topic)||(n=!0),n&&r.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{ft(s.expiryTimestamp)&&t.push(s.id)}),await Promise.all([...r.map(s=>this.deleteSession({topic:s})),...t.map(s=>this.deleteProposal(s))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Et.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Et.active;let r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(t){this.client.logger.warn(t)}}this.requestQueue.state=Et.idle},this.processRequest=async r=>{let{topic:t,payload:s,attestation:n,transportType:o,encryptedId:a}=r,c=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}},this.onRelayEventResponse=async r=>{let{topic:t,payload:s,transportType:n}=r,o=(await this.client.core.history.get(t,s.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,n);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=r=>{let{topic:t}=r,{message:s}=B("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)},this.shouldIgnorePairingRequest=r=>{let{topic:t,requestMethod:s}=r,n=this.expectedPairingMethodMap.get(t);return!n||n.includes(s)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async r=>{let{topic:t,payload:s,attestation:n,encryptedId:o}=r,{params:a,id:c}=s;try{let h=this.client.core.eventClient.getEvent({topic:t});this.isValidConnect(Ee({},s.params));let d=a.expiryTimestamp||ve(xe.wc_sessionPropose.req.ttl),l=Ee({id:c,pairingTopic:t,expiryTimestamp:d},a);await this.setProposal(c,l);let p=await this.getVerifyContext({attestationId:n,hash:rt(JSON.stringify(s)),encryptedId:o,metadata:l.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(yt.proposal_listener_not_found)),h?.addTrace(ot.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:p})}catch(h){await this.sendError({id:c,topic:t,error:h,rpcOpts:xe.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(r,t,s)=>{let{id:n}=t;if(Ve(t)){let{result:o}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});let c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});let h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});let d=await this.client.core.crypto.generateSharedKey(c,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:d});let l=await this.client.core.relayer.subscribe(d,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else if(Le(t)){await this.client.proposal.delete(n,ce("USER_DISCONNECTED"));let o=se("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(se("session_connect"),{error:t.error})}},this.onSessionSettleRequest=async(r,t)=>{let{id:s,params:n}=t;try{this.isValidSessionSettleRequest(n);let{relay:o,controller:a,expiry:c,namespaces:h,sessionProperties:d,sessionConfig:l}=t.params,p=at(Ee(Ee({topic:r,relay:o,expiry:c,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},d&&{sessionProperties:d}),l&&{sessionConfig:l}),{transportType:de.relay}),f=se("session_connect");if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners 997`);this.events.emit(se("session_connect"),{session:p}),await this.sendResult({id:t.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,t)=>{let{id:s}=t;Ve(t)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(se("session_approve",s),{})):Le(t)&&(await this.client.session.delete(r,ce("USER_DISCONNECTED")),this.events.emit(se("session_approve",s),{error:t.error}))},this.onSessionUpdateRequest=async(r,t)=>{let{params:s,id:n}=t;try{let o=`${r}_session_update`,a=zt.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:r,error:ce("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Ee({topic:r},s));try{zt.set(o,n),await this.client.session.update(r,{namespaces:s.namespaces}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw zt.delete(o),c}this.client.events.emit("session_update",{id:n,topic:r,params:s})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(r,t)=>parseInt(t.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,t)=>{let{id:s}=t,n=se("session_update",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);Ve(t)?this.events.emit(se("session_update",s),{}):Le(t)&&this.events.emit(se("session_update",s),{error:t.error})},this.onSessionExtendRequest=async(r,t)=>{let{id:s}=t;try{this.isValidExtend({topic:r}),await this.setExpiry(r,ve(Qr)),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}},this.onSessionExtendResponse=(r,t)=>{let{id:s}=t,n=se("session_extend",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);Ve(t)?this.events.emit(se("session_extend",s),{}):Le(t)&&this.events.emit(se("session_extend",s),{error:t.error})},this.onSessionPingRequest=async(r,t)=>{let{id:s}=t;try{this.isValidPing({topic:r}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}},this.onSessionPingResponse=(r,t)=>{let{id:s}=t,n=se("session_ping",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);setTimeout(()=>{Ve(t)?this.events.emit(se("session_ping",s),{}):Le(t)&&this.events.emit(se("session_ping",s),{error:t.error})},500)},this.onSessionDeleteRequest=async(r,t)=>{let{id:s}=t;try{this.isValidDisconnect({topic:r,reason:t.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(Ue.publish,async()=>{n(await this.deleteSession({topic:r,id:s}))})}),this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:ce("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}},this.onSessionRequest=async r=>{var t,s,n;let{topic:o,payload:a,attestation:c,encryptedId:h,transportType:d}=r,{id:l,params:p}=a;try{await this.isValidRequest(Ee({topic:o},p));let f=this.client.session.get(o),g=await this.getVerifyContext({attestationId:c,hash:rt(JSON.stringify(st("wc_sessionRequest",p,l))),encryptedId:h,metadata:f.peer.metadata,transportType:d}),w={id:l,topic:o,params:p,verifyContext:g};await this.setPendingSessionRequest(w),d===de.link_mode&&(t=f.peer.metadata.redirect)!=null&&t.universal&&this.client.core.addLinkModeSupportedApp((s=f.peer.metadata.redirect)==null?void 0:s.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(w):(this.addSessionRequestToSessionRequestQueue(w),this.processSessionRequestQueue())}catch(f){await this.sendError({id:l,topic:o,error:f}),this.client.logger.error(f)}},this.onSessionRequestResponse=(r,t)=>{let{id:s}=t,n=se("session_request",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);Ve(t)?this.events.emit(se("session_request",s),{result:t.result}):Le(t)&&this.events.emit(se("session_request",s),{error:t.error})},this.onSessionEventRequest=async(r,t)=>{let{id:s,params:n}=t;try{let o=`${r}_session_event_${n.event.name}`,a=zt.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(Ee({topic:r},n)),this.client.events.emit("session_event",{id:s,topic:r,params:n}),zt.set(o,s)}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(r,t)=>{let{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:t}),Ve(t)?this.events.emit(se("session_request",s),{result:t.result}):Le(t)&&this.events.emit(se("session_request",s),{error:t.error})},this.onSessionAuthenticateRequest=async r=>{var t;let{topic:s,payload:n,attestation:o,encryptedId:a,transportType:c}=r;try{let{requester:h,authPayload:d,expiryTimestamp:l}=n.params,p=await this.getVerifyContext({attestationId:o,hash:rt(JSON.stringify(n)),encryptedId:a,metadata:h.metadata,transportType:c}),f={requester:h,pairingTopic:s,id:n.id,authPayload:d,verifyContext:p,expiryTimestamp:l};await this.setAuthRequest(n.id,{request:f,pairingTopic:s,transportType:c}),c===de.link_mode&&(t=h.metadata.redirect)!=null&&t.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:n.params,id:n.id,verifyContext:p})}catch(h){this.client.logger.error(h);let d=n.params.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),p=this.getAppLinkIfEnabled(n.params.requester.metadata,c),f={type:tt,receiverPublicKey:d,senderPublicKey:l};await this.sendError({id:n.id,topic:s,error:h,encodeOpts:f,rpcOpts:xe.wc_sessionAuthenticate.autoReject,appLink:p})}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Et.idle,this.processSessionRequestQueue()},(0,ae.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:r,error:t})=>{let s=this.client.core.history.pending;s.length>0&&s.filter(n=>n.topic===r&&n.request.method==="wc_sessionRequest").forEach(n=>{let o=n.request.id,a=se("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(se("session_request",n.request.id),{error:t})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Et.active){this.client.logger.info("session request queue is already active.");return}let r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Et.active,this.emitSessionRequest(r)}catch(t){this.client.logger.error(t)}},this.emitSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onPairingCreated=r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;let t=this.client.proposal.getAll().find(s=>s.pairingTopic===r.topic);t&&this.onSessionProposeRequest({topic:r.topic,payload:st("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})},this.isValidConnect=async r=>{if(!Oe(r)){let{message:c}=B("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}let{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:n,sessionProperties:o,relays:a}=r;if(De(t)||await this.isValidPairingTopic(t),!ag(a,!0)){let{message:c}=B("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!De(s)&&Ki(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!De(n)&&Ki(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),De(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,t)=>{let s=og(r,"connect()",t);if(s)throw new Error(s.message)},this.isValidApprove=async r=>{if(!Oe(r))throw new Error(B("MISSING_OR_INVALID",`approve() params: ${r}`).message);let{id:t,namespaces:s,relayProtocol:n,sessionProperties:o}=r;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);let a=this.client.proposal.get(t),c=Co(s,"approve()");if(c)throw new Error(c.message);let h=au(a.requiredNamespaces,s,"approve()");if(h)throw new Error(h.message);if(!me(n,!0)){let{message:d}=B("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(d)}De(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!Oe(r)){let{message:n}=B("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(n)}let{id:t,reason:s}=r;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!ug(s)){let{message:n}=B("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(n)}},this.isValidSessionSettleRequest=r=>{if(!Oe(r)){let{message:h}=B("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}let{relay:t,controller:s,namespaces:n,expiry:o}=r;if(!nu(t)){let{message:h}=B("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}let a=sg(s,"onSessionSettleRequest()");if(a)throw new Error(a.message);let c=Co(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(ft(o)){let{message:h}=B("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!Oe(r)){let{message:c}=B("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}let{topic:t,namespaces:s}=r;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let n=this.client.session.get(t),o=Co(s,"update()");if(o)throw new Error(o.message);let a=au(n.requiredNamespaces,s,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!Oe(r)){let{message:s}=B("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(s)}let{topic:t}=r;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)},this.isValidRequest=async r=>{if(!Oe(r)){let{message:c}=B("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}let{topic:t,request:s,chainId:n,expiry:o}=r;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let{namespaces:a}=this.client.session.get(t);if(!ou(a,n)){let{message:c}=B("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!hg(s)){let{message:c}=B("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(c)}if(!fg(a,n,s.method)){let{message:c}=B("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(c)}if(o&&!gg(o,$u)){let{message:c}=B("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${$u.min} and ${$u.max}`);throw new Error(c)}},this.isValidRespond=async r=>{var t;if(!Oe(r)){let{message:o}=B("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}let{topic:s,response:n}=r;try{await this.isValidSessionTopic(s)}catch(o){throw(t=r?.response)!=null&&t.id&&this.cleanupAfterResponse(r),o}if(!lg(n)){let{message:o}=B("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!Oe(r)){let{message:s}=B("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(s)}let{topic:t}=r;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async r=>{if(!Oe(r)){let{message:a}=B("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}let{topic:t,event:s,chainId:n}=r;await this.isValidSessionTopic(t);let{namespaces:o}=this.client.session.get(t);if(!ou(o,n)){let{message:a}=B("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!dg(s)){let{message:a}=B("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}if(!pg(o,n,s.name)){let{message:a}=B("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!Oe(r)){let{message:s}=B("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(s)}let{topic:t}=r;await this.isValidSessionOrPairingTopic(t)},this.isValidAuthenticate=r=>{let{chains:t,uri:s,domain:n,nonce:o}=r;if(!Array.isArray(t)||t.length===0)throw new Error("chains is required and must be a non-empty array");if(!me(s,!1))throw new Error("uri is required parameter");if(!me(n,!1))throw new Error("domain is required parameter");if(!me(o,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(c=>Ui(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:a}=Ui(t[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async r=>{let{attestationId:t,hash:s,encryptedId:n,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||Yr,validation:"UNKNOWN",origin:o.url||""}};try{if(a===de.link_mode){let d=this.getAppLinkIfEnabled(o,a);return c.verified.validation=d&&new URL(d).origin===new URL(o.url).origin?"VALID":"INVALID",c}let h=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:n,verifyUrl:o.verifyUrl});h&&(c.verified.origin=h.origin,c.verified.isScam=h.isScam,c.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c},this.validateSessionProps=(r,t)=>{Object.values(r).forEach(s=>{if(!me(s,!1)){let{message:n}=B("MISSING_OR_INVALID",`${t} must be in Record format. Received: ${JSON.stringify(s)}`);throw new Error(n)}})},this.getPendingAuthRequest=r=>{let t=this.client.auth.requests.get(r);return typeof t=="object"?t:void 0},this.addToRecentlyDeleted=(r,t)=>{if(this.recentlyDeletedMap.set(r,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0,n=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(s++>=n)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=r=>{let t=this.recentlyDeletedMap.get(r);if(t){let{message:s}=B("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${r}`);throw new Error(s)}},this.isLinkModeEnabled=(r,t)=>{var s,n,o,a,c,h,d,l,p;return!r||t!==de.link_mode?!1:((n=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((h=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:h.universal)!==""&&((d=r?.redirect)==null?void 0:d.universal)!==void 0&&((l=r?.redirect)==null?void 0:l.universal)!==""&&((p=r?.redirect)==null?void 0:p.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof window?.Linking<"u"},this.getAppLinkIfEnabled=(r,t)=>{var s;return this.isLinkModeEnabled(r,t)?(s=r?.redirect)==null?void 0:s.universal:void 0},this.handleLinkModeMessage=({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;let t=jc(r,"topic")||"",s=decodeURIComponent(jc(r,"wc_ev")||""),n=this.client.session.keys.includes(t);n&&this.client.session.update(t,{transportType:de.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:n})},this.registerLinkModeListeners=async()=>{var r;if(ki()||fr()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){let t=window?.Linking;if(typeof t<"u"){t.addEventListener("url",this.handleLinkModeMessage,this.client.name);let s=await t.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ue.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:r,message:t,attestation:s,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(jo)?this.client.auth.authKeys.get(jo):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,t,{receiverPublicKey:o,encoding:n===de.link_mode?Vr:pt});try{Jr(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:s,transportType:n,encryptedId:rt(t)})):Ht(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:n}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:n})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(je.expired,async e=>{let{topic:r,id:t}=Io(e.target);if(t&&this.client.pendingRequest.keys.includes(t))return await this.deletePendingSessionRequest(t,B("EXPIRED"),!0);if(t&&this.client.auth.requests.keys.includes(t))return await this.deletePendingAuthRequest(t,B("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):t&&(await this.deleteProposal(t,!0),this.client.events.emit("proposal_expire",{id:t}))})}registerPairingEvents(){this.client.core.pairing.events.on(Gt.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Gt.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!me(e,!1)){let{message:r}=B("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:r}=B("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(ft(this.client.core.pairing.pairings.get(e).expiry)){let{message:r}=B("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!me(e,!1)){let{message:r}=B("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:r}=B("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(ft(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:r}=B("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){let{message:r}=B("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(me(e,!1)){let{message:r}=B("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{let{message:r}=B("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!cg(e)){let{message:r}=B("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){let{message:r}=B("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(ft(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:r}=B("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}},Gu=class extends bt{constructor(e,r){super(e,r,dx,eh),this.core=e,this.logger=r}},Wu=class extends bt{constructor(e,r){super(e,r,px,eh),this.core=e,this.logger=r}},Ju=class extends bt{constructor(e,r){super(e,r,mx,eh,t=>t.id),this.core=e,this.logger=r}},Yu=class extends bt{constructor(e,r){super(e,r,Ex,Go,()=>jo),this.core=e,this.logger=r}},Xu=class extends bt{constructor(e,r){super(e,r,_x,Go),this.core=e,this.logger=r}},Qu=class extends bt{constructor(e,r){super(e,r,vx,Go,t=>t.id),this.core=e,this.logger=r}},Zu=class{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new Yu(this.core,this.logger),this.pairingTopics=new Xu(this.core,this.logger),this.requests=new Qu(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},$o=class i extends Un{constructor(e){super(e),this.protocol=U0,this.version=M0,this.name=ju.name,this.events=new Ho.EventEmitter,this.on=(t,s)=>this.events.on(t,s),this.once=(t,s)=>this.events.once(t,s),this.off=(t,s)=>this.events.off(t,s),this.removeListener=(t,s)=>this.events.removeListener(t,s),this.removeAllListeners=t=>this.events.removeAllListeners(t),this.connect=async t=>{try{return await this.engine.connect(t)}catch(s){throw this.logger.error(s.message),s}},this.pair=async t=>{try{return await this.engine.pair(t)}catch(s){throw this.logger.error(s.message),s}},this.approve=async t=>{try{return await this.engine.approve(t)}catch(s){throw this.logger.error(s.message),s}},this.reject=async t=>{try{return await this.engine.reject(t)}catch(s){throw this.logger.error(s.message),s}},this.update=async t=>{try{return await this.engine.update(t)}catch(s){throw this.logger.error(s.message),s}},this.extend=async t=>{try{return await this.engine.extend(t)}catch(s){throw this.logger.error(s.message),s}},this.request=async t=>{try{return await this.engine.request(t)}catch(s){throw this.logger.error(s.message),s}},this.respond=async t=>{try{return await this.engine.respond(t)}catch(s){throw this.logger.error(s.message),s}},this.ping=async t=>{try{return await this.engine.ping(t)}catch(s){throw this.logger.error(s.message),s}},this.emit=async t=>{try{return await this.engine.emit(t)}catch(s){throw this.logger.error(s.message),s}},this.disconnect=async t=>{try{return await this.engine.disconnect(t)}catch(s){throw this.logger.error(s.message),s}},this.find=t=>{try{return this.engine.find(t)}catch(s){throw this.logger.error(s.message),s}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(t){throw this.logger.error(t.message),t}},this.authenticate=async(t,s)=>{try{return await this.engine.authenticate(t,s)}catch(n){throw this.logger.error(n.message),n}},this.formatAuthMessage=t=>{try{return this.engine.formatAuthMessage(t)}catch(s){throw this.logger.error(s.message),s}},this.approveSessionAuthenticate=async t=>{try{return await this.engine.approveSessionAuthenticate(t)}catch(s){throw this.logger.error(s.message),s}},this.rejectSessionAuthenticate=async t=>{try{return await this.engine.rejectSessionAuthenticate(t)}catch(s){throw this.logger.error(s.message),s}},this.name=e?.name||ju.name,this.metadata=e?.metadata||zr(),this.signConfig=e?.signConfig;let r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Pt(si({level:e?.logger||ju.logger}));this.core=e?.core||new N0(e),this.logger=Ie(r,this.name),this.session=new Wu(this.core,this.logger),this.proposal=new Gu(this.core,this.logger),this.pendingRequest=new Ju(this.core,this.logger),this.engine=new Hu(this),this.auth=new Zu(this.core,this.logger)}static async init(e){let r=new i(e);return await r.initialize(),r}get context(){return Re(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}});var B0,ct,th=P(()=>{"use strict";B0=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],ct="mvx"});var ts=P(()=>{"use strict"});function Wo(i){return i[Math.floor(Math.random()*i.length)]}var rs,q0,rh,Zr=P(()=>{"use strict";rs=i=>typeof i=="string"?i.toUpperCase():i instanceof Error?i.message:JSON.stringify(i);q0="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",rh=i=>{if(!/^[0-9a-fA-F]+$/.test(i)||i.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(i.length/2);for(let r=0;rt.acknowledged);if(r.length>0){let t=r.length-1;return r[t]}if(e.session.length>0){let t=e.session.keys.length-1;return e.session.get(e.session.keys[t])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Nt(i,e){if(!e)throw new Error("WalletConnect is not initialized");let r=sh(i,e);if(!r?.topic)throw new Error("WalletConnect Session is not connected");return r.topic}function z0(i){return!!i}function nh(i){let e=i.namespaces[ct];if(e&&e.accounts){let r=e.accounts[0],[,,t]=r.split(":");return t}return""}function oh({transaction:i,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:r,guardianSignature:t,version:s,options:n,guardian:o}=e,a=i.guardian;if(a&&a!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(i.guardian=o),s&&(i.version=s),n!=null&&(i.options=n),i.signature=rh(r),t&&(i.guardianSignature=rh(t)),i}function V0(i){if(i)return{...i,url:zr().url}}async function K0(i){return await new Promise(e=>setTimeout(()=>{e()},i))}var j0=P(()=>{"use strict";ji();th();ts();Zr()});var Xe,is=P(()=>{"use strict";k0();ji();j0();th();ts();Xe=class{constructor(e,r,t,s,n,o,a,c){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=r,this.walletConnectV2Relay=t,this.walletConnectV2ProjectId=s,this.Message=n,this.Transaction=o,this.TransactionsConverter=a,this.options=c}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:V0(this.options?.metadata)}:{},r=await $o.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=r,this.isInitializing=!1,await this.subscribeToEvents(r),await this.checkPersistedState(r)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let r=ih(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...r})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let r=await e.approval();if(e.token){await K0(500);let t=nh(r),n=r.namespaces[ct].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:r.topic,request:{method:n,params:{token:e.token,address:t}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:r,signature:o})}return await this.onSessionConnected({session:r,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Nt(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:ce("USER_DISCONNECTED")});else{let r=Nt(this.chainId,this.walletConnector);this.processingTopic=r,await this.walletConnector.disconnect({topic:r,reason:ce("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let r=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let t=this.getAddress(),{signature:s}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:t,message:r.data.toString()}}});if(!s)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{r.signature=Buffer.from(s,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return r}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let r=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let t=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:r}}});return oh({transaction:e,response:t})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let r=e.map(t=>{if(this.chainId!==t.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(t)});try{let{signatures:t}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:r}}});if(!t)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(t)||e.length!==t.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[s,n]of e.entries()){let o=t[s];oh({transaction:n,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let r={...e.request},{method:t}=r,{response:s}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{...r,method:t}});s||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Nt(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?z0(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let r=nh(e.session);return r?(await this.loginAccount({address:r,signature:e.signature}),this.account.address=r,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let r=await this.getPairings();this.account.address&&!this.isInitializing&&r&&(r?.length===0?this.onClientConnect.onClientLogout():r[r.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:r}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:t}=r;if(t?.name&&Nt(this.chainId,this.walletConnector)===e){let s=t.data;this.onClientConnect.onClientEvent(s)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:r,params:t})=>{if(!this.session||this.session?.topic!==r)return;let{namespaces:s}=t,o={...e.session.get(r),namespaces:s};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:r})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==r)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:r})=>{!this.session||this.session?.topic!==r||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let r=sh(this.chainId,e);if(r)return await this.onSessionConnected({session:r}),r}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let r=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!Vt(r))return;for(let t of r)if(e.deletePairings)this.walletConnector.core?.expirer?.set(t.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(t.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}}});var $0={};Se($0,{initMobileProvider:()=>Nx});var Nx,H0=P(()=>{"use strict";is();Zr();Nx=async(i,e,r,t,s,n,o,a)=>{if(!o||!i.initOptions.chainType)return;let c={onClientLogin:()=>{},onClientLogout:()=>e(i),onClientEvent:l=>{console.log("wc2 session event: ",l)}},h=Wo(a),d=new Xe(c,r[i.initOptions.chainType].shortId,h,o,t,s,n);try{return await d.init(),d}catch{console.warn("Can't initialize the Dapp Provider!")}}});function Ot(i,e,r){if(e<0||e>31||i>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)r.push(i>>>t&1)}function At(i,e){return(i>>>e&1)!==0}function Z0(i,e){return i[Math.floor((e+7)/17)+1]}function em(i){let e=[];for(let r of i)Ot(r,8,e);return new ss(zx,i.length,e)}function Vx(i){if(!tm(i))throw new RangeError("String contains non-numeric characters");let e=[];for(let r=0;r=1<dh)throw new RangeError("Version number out of range");let e=(16*i+128)*i+64;if(i>=2){let r=Math.floor(i/7)+2;e-=(25*r-10)*r-55,i>=7&&(e-=36)}return e}function Xo(i,e){return Math.floor(uh(i)/8)-X0[e[0]][i]*Q0[e[0]][i]}function Gx(i){if(i<1||i>255)throw new RangeError("Degree out of range");let e=[];for(let t=0;t0);for(let t of i){let s=t^r.shift();r.push(0),e.forEach((n,o)=>r[o]^=hh(n,s))}return r}function hh(i,e){if(i>>>8||e>>>8)throw new RangeError("Byte out of range");let r=0;for(let t=7;t>=0;t--)r=r<<1^(r>>>7)*285,r^=(e>>>t&1)*i;return r}function Jx(i,e,r=1,t=40,s=-1,n=!0){if(!(lh<=r&&r<=t&&t<=dh)||s<-1||s>7)throw new RangeError("Invalid value");let o,a;for(o=r;;o++){let l=Xo(o,e)*8,p=$x(i,o);if(p<=l){a=p;break}if(o>=t)throw new RangeError("Data too long")}for(let l of[W0,J0,Y0])n&&a<=Xo(o,l)*8&&(e=l);let c=[];for(let l of i){Ot(l.mode[0],4,c),Ot(l.numChars,Z0(l.mode,o),c);for(let p of l.getData())c.push(p)}let h=Xo(o,e)*8;Ot(0,Math.min(4,h-c.length),c),Ot(0,(8-c.length%8)%8,c);for(let l=236;c.length0);return c.forEach((l,p)=>d[p>>>3]|=l<<7-(p&7)),new ch(o,e,d,s)}function Yx(i,e){let{ecc:r="L",boostEcc:t=!1,minVersion:s=1,maxVersion:n=40,maskPattern:o=-1,border:a=1}=e||{},c=typeof i=="string"?jx(i):Array.isArray(i)?[em(i)]:void 0;if(!c)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof i}`);let h=Jx(c,Lx[r],s,n,o,t),d=Xx({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},a);return e?.invert&&(d.data=d.data.map(l=>l.map(p=>!p))),e?.onEncoded?.(d),d}function Xx(i,e=1){if(!e)return i;let{size:r}=i,t=r+e*2;i.size=t,i.data.forEach(n=>{for(let o=0;o!1)),i.data.push(Array.from({length:t},o=>!1));let s=mr.Border;i.types.forEach(n=>{for(let o=0;os)),i.types.push(Array.from({length:t},o=>s));return i}function im(i,e={}){let r=Yx(i,e),{pixelSize:t=10,whiteColor:s="white",blackColor:n="black"}=e,o=r.size*t,a=r.size*t,c=``,h=[];for(let d=0;d`,c+=``,c+="",c}var mr,Ax,Ox,Jo,Px,W0,J0,Y0,Lx,Ux,Mx,ah,lh,dh,G0,Fx,Yo,kx,X0,Q0,ch,ss,Bx,qx,zx,sm=P(()=>{mr=(i=>(i[i.Border=-1]="Border",i[i.Data=0]="Data",i[i.Function=1]="Function",i[i.Position=2]="Position",i[i.Timing=3]="Timing",i[i.Alignment=4]="Alignment",i))(mr||{}),Ax=Object.defineProperty,Ox=(i,e,r)=>e in i?Ax(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Jo=(i,e,r)=>(Ox(i,typeof e!="symbol"?e+"":e,r),r),Px=[0,1],W0=[1,0],J0=[2,3],Y0=[3,2],Lx={L:Px,M:W0,Q:J0,H:Y0},Ux=/^[0-9]*$/,Mx=/^[A-Z0-9 $%*+.\/:-]*$/,ah="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",lh=1,dh=40,G0=3,Fx=3,Yo=40,kx=10,X0=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Q0=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],ch=class{constructor(e,r,t,s){if(this.version=e,this.ecc=r,Jo(this,"size"),Jo(this,"mask"),Jo(this,"modules",[]),Jo(this,"types",[]),edh)throw new RangeError("Version value out of range");if(s<-1||s>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let n=Array.from({length:this.size},()=>!1);for(let a=0;a0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(t);if(this.drawCodewords(o),s===-1){let a=1e9;for(let c=0;c<8;c++){this.applyMask(c),this.drawFormatBits(c);let h=this.getPenaltyScore();h=0&&e=0&&r>>9)*1335;let s=(r<<10|t)^21522;for(let n=0;n<=5;n++)this.setFunctionModule(8,n,At(s,n));this.setFunctionModule(8,7,At(s,6)),this.setFunctionModule(8,8,At(s,7)),this.setFunctionModule(7,8,At(s,8));for(let n=9;n<15;n++)this.setFunctionModule(14-n,8,At(s,n));for(let n=0;n<8;n++)this.setFunctionModule(this.size-1-n,8,At(s,n));for(let n=8;n<15;n++)this.setFunctionModule(8,this.size-15+n,At(s,n));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let r=this.version<<12|e;for(let t=0;t<18;t++){let s=At(r,t),n=this.size-11+t%3,o=Math.floor(t/3);this.setFunctionModule(n,o,s),this.setFunctionModule(o,n,s)}}drawFinderPattern(e,r){for(let t=-4;t<=4;t++)for(let s=-4;s<=4;s++){let n=Math.max(Math.abs(s),Math.abs(t)),o=e+s,a=r+t;o>=0&&o=0&&a{(p!==c-n||g>=a)&&l.push(f[p])});return l}drawCodewords(e){if(e.length!==Math.floor(uh(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let t=this.size-1;t>=1;t-=2){t===6&&(t=5);for(let s=0;s>>3],7-(r&7)),r++)}}}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let r=0;r5&&e++):(this.finderPenaltyAddHistory(a,c),o||(e+=this.finderPenaltyCountPatterns(c)*Yo),o=this.modules[n][h],a=1);e+=this.finderPenaltyTerminateAndCount(o,a,c)*Yo}for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(a,c),o||(e+=this.finderPenaltyCountPatterns(c)*Yo),o=this.modules[h][n],a=1);e+=this.finderPenaltyTerminateAndCount(o,a,c)*Yo}for(let n=0;no+(a?1:0),r);let t=this.size*this.size,s=Math.ceil(Math.abs(r*20-t*10)/t)-1;return e+=s*kx,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,r=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,t=[6];for(let s=this.size-7;t.length0&&e[2]===r&&e[3]===r*3&&e[4]===r&&e[5]===r;return(t&&e[0]>=r*4&&e[6]>=r?1:0)+(t&&e[6]>=r*4&&e[0]>=r?1:0)}finderPenaltyTerminateAndCount(e,r,t){return e&&(this.finderPenaltyAddHistory(r,t),r=0),r+=this.size,this.finderPenaltyAddHistory(r,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,r){r[0]===0&&(e+=this.size),r.pop(),r.unshift(e)}};ss=class{constructor(e,r,t){if(this.mode=e,this.numChars=r,this.bitData=t,r<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}getData(){return this.bitData.slice()}},Bx=[1,10,12,14],qx=[2,9,11,13],zx=[4,8,16,16]});var Zx,e2,t2,r2,fh,i2,Qo,s2,n2,o2,a2,c2,nm,om=P(()=>{"use strict";sm();is();Zr();Zr();ts();Zx=i=>{let e=document.createElement("template");return e.innerHTML=i.trim(),e.content.firstChild?.cloneNode(!0)},e2=i=>{let e=`${q0}?wallet-connect=${encodeURIComponent(i)}`,r=document.createElement("a");return r.setAttribute("href",e),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank"),r.textContent="xPortal login",r.classList.add("elven-qr-code-deep-link"),r},t2=()=>{let i=document.createElement("div");return i.classList.add("elven-wc-pairings"),i},r2=()=>{let i=document.createElement("div");return i.textContent="Existing WalletConnect pairings:",i.classList.add("elven-wc-pairings-header"),i},fh={},i2=(i,e)=>{let r=document.createElement("button");return r.classList.add("elven-wc-pairings-remove-btn"),r.textContent="\u2716",fh[i.topic]=new AbortController,r.addEventListener("click",t=>{t.stopImmediatePropagation(),e(i.topic)},{signal:fh[i.topic].signal}),r},Qo={},s2=(i,e,r)=>{let t=document.createElement("div"),s=document.createElement("div");t.classList.add("elven-wc-pairing-item"),t.setAttribute("id",i.topic),s.classList.add("elven-wc-pairing-item-description"),s.textContent=`${i.peerMetadata?.description} (${i.peerMetadata?.url})`,t.appendChild(s);let n=i2(i,e);return t.appendChild(n),Qo[i.topic]=new AbortController,t.addEventListener("click",()=>r(i.topic),{signal:Qo[i.topic].signal}),t},n2=()=>{let i=document.createElement("div");return i.classList.add("elven-wc-pairing-item-confirm-msessage"),i.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),i.innerText="Confirm on xPortal app!",i},o2=i=>{if(!i)return;document.getElementById(i)?.remove()},a2=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),c2=i=>i?im(i):void 0,nm=async(i,e,r,t)=>{if(!i)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let s=null;typeof i=="string"?s=document.getElementById(i):i instanceof HTMLElement&&(s=i);let n=c2(e),o;if(n&&(o=Zx(n)),s&&o&&(s.replaceChildren(),s.appendChild(o),a2()&&s.appendChild(e2(e))),s&&r instanceof Xe){let a=r.pairings,c=async d=>{try{d&&(await r.logout({topic:d}),o2(d))}catch(l){let p=rs(l);console.warn(`Something went wrong trying to remove the existing pairing: ${p}`)}finally{Qo[d].abort()}},h=async d=>{try{let{approval:l}=await r.connect({topic:d,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(d)?.after(n2()),await r.login({approval:l,token:t})}catch(l){let p=rs(l);console.warn(`Something went wrong trying to login the user: ${p}`)}finally{for(let l of Object.values(Qo))l?.abort();for(let l of Object.values(fh))l?.abort()}};if(a&&a.length>0){let d=t2();s.appendChild(d);let l=r2();d.appendChild(l);for(let p of a){let f=s2(p,c,h);d.appendChild(f)}}}return s}});var am={};Se(am,{loginWithMobile:()=>u2});var u2,cm=P(()=>{"use strict";Zr();om();is();ts();u2=async(i,e,r,t,s,n,o,a,c,h,d,l,p,f,g)=>{if(!g)throw new Error("You haven't provided the QR code container DOM element id");let w=Wo(f);if(!w||!i.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!p)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!i.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let b,v={onClientLogin:async()=>{if(i.dappProvider instanceof Xe){let I=await i.dappProvider.getAddress(),S=await i.dappProvider.getSignature();t.set("address",I),t.set("loginMethod","mobile"),t.set("expires",n()),await o(i),S&&t.set("signature",S),t.set("loginToken",e);let T=r.getToken(I,e,S);t.set("accessToken",T),a.run("onLoginSuccess"),b?.replaceChildren()}},onClientLogout:async()=>{i.dappProvider instanceof Xe&&await s(i)},onClientEvent:I=>{console.log("wc2 session event: ",I)}},x=new Xe(v,c[i.initOptions.chainType].shortId,w,p,h,d,l);try{if(x){i.dappProvider=x,a.run("onQrPending"),await x.init();let{uri:I,approval:S}=await x.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),T=e?`${I}&token=${e}`:I;return g&&T&&(b=await nm(g,T,x,e),a.run("onQrLoaded")),await x.login({approval:S,token:e}),x}}catch(I){let S=rs(I);console.warn(`Something went wrong trying to login the user: ${S}`),a.run("onLoginFailure",S)}}});is();var um=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:r,qrCodeContainer:t}){this.WalletConnectV2Provider=Xe;this.initMobileProvider=async(e,r,t,s,n,o)=>{let{initMobileProvider:a}=await Promise.resolve().then(()=>(H0(),$0));return a(e,r,t,s,n,o,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses)};this.loginWithMobile=async(e,r,t,s,n,o,a,c,h,d,l,p)=>{let{loginWithMobile:f}=await Promise.resolve().then(()=>(cm(),am));return f(e,r,t,s,n,o,a,c,h,d,l,p,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses,this.qrCodeContainer)};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=r,this.qrCodeContainer=t}};export{um as MobileSigningProvider}; /*! Bundled license information: -tslib/tslib.es6.js: - (*! ***************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** *) - js-sha3/src/sha3.js: (** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -64,4 +41,7 @@ js-sha3/src/sha3.js: * @copyright Chen, Yi-Cyuan 2015-2018 * @license MIT *) + +@noble/secp256k1/index.js: + (*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *) */ diff --git a/package-lock.json b/package-lock.json index e133f18..7edb8f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1468,6 +1468,15 @@ "node": ">=12" } }, + "node_modules/@noble/secp256k1": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-2.1.0.tgz", + "integrity": "sha512-XLEQQNdablO0XZOIniFQimiXsZDNwaYgL96dZwC54Q30imSbAOFf3NKtepc+cXyuZf5Q1HCgbqgZ2UFFuHVcEw==", + "dev": true, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@parcel/watcher": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.4.1.tgz", @@ -1953,15 +1962,6 @@ "undici-types": "~6.19.8" } }, - "node_modules/@types/qrcode": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.5.tgz", - "integrity": "sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@walletconnect/core": { "version": "2.17.1", "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.17.1.tgz", @@ -2374,15 +2374,6 @@ "node": ">=6" } }, - "node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -2461,72 +2452,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2621,15 +2546,6 @@ } } }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/decode-uri-component": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", @@ -2675,12 +2591,6 @@ "node": ">=0.10" } }, - "node_modules/dijkstrajs": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", - "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", - "dev": true - }, "node_modules/duplexify": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz", @@ -3094,15 +3004,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, "node_modules/get-port-please": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/get-port-please/-/get-port-please-3.1.2.tgz", @@ -3878,15 +3779,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", @@ -4018,15 +3910,6 @@ "pathe": "^1.1.2" } }, - "node_modules/pngjs": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", - "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", - "dev": true, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -4066,23 +3949,6 @@ "node": ">=6" } }, - "node_modules/qrcode": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", - "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==", - "dev": true, - "dependencies": { - "dijkstrajs": "^1.0.1", - "pngjs": "^5.0.0", - "yargs": "^15.3.1" - }, - "bin": { - "qrcode": "bin/qrcode" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/query-string": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.3.tgz", @@ -4157,21 +4023,6 @@ "node": ">= 12.13.0" } }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -4244,12 +4095,6 @@ "range-parser": "1.2.0" } }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", - "dev": true - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -4807,12 +4652,6 @@ "node": ">= 8" } }, - "node_modules/which-module": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", - "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", - "dev": true - }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -4937,140 +4776,6 @@ } } }, - "node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true - }, - "node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, - "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/yargs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/yargs/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/yargs/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -5093,12 +4798,15 @@ "name": "@elven.js/mobile-signing-provider", "version": "1.0.0", "devDependencies": { - "@types/qrcode": "1.5.5", + "@noble/secp256k1": "2.1.0", "@walletconnect/sign-client": "2.17.1", "@walletconnect/types": "2.17.1", "@walletconnect/utils": "2.17.1", "esbuild": "0.24.0", - "qrcode": "1.5.4" + "uqr": "0.1.2" + }, + "peerDependencies": { + "elven.js": "*" } } } diff --git a/packages/mobile-signing-provider/esbuild.config.js b/packages/mobile-signing-provider/esbuild.config.js index 3eaa9c8..53f91d6 100644 --- a/packages/mobile-signing-provider/esbuild.config.js +++ b/packages/mobile-signing-provider/esbuild.config.js @@ -1,11 +1,467 @@ import { baseConfig } from '@configs/esbuild'; import * as esbuild from 'esbuild'; import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; esbuild .build({ ...baseConfig, entryPoints: ['./src/mobile-signing-provider.ts'], + // These are workarounds to avoid not needed code being bundled + // Always review when updating the walletconnect packages + plugins: [ + { + name: 'bn-resolver', + setup(build) { + build.onResolve({ filter: /^bn\.js$/ }, () => { + return { path: 'virtual:bn.js', namespace: 'bn-shim' }; + }); + build.onLoad( + { filter: /^virtual:bn\.js$/, namespace: 'bn-shim' }, + () => ({ + contents: ` + export class BN { + constructor(value) { + this.value = BigInt(value); + } + + toString(base = 10) { + return this.value.toString(base); + } + + toNumber() { + return Number(this.value); + } + } + export default BN; + `, + }) + ); + }, + }, + { + name: 'customize-walletconnect', + setup(build) { + // Replace elliptic with our adapter + build.onResolve({ filter: /^elliptic$/ }, () => ({ + path: 'virtual:secp256k1-adapter', + namespace: 'virtual', + })); + + build.onLoad( + { filter: /^virtual:secp256k1-adapter$/, namespace: 'virtual' }, + () => ({ + contents: ` + import * as secp from '@noble/secp256k1'; + + class EC { + constructor(curve) { + if (curve !== 'secp256k1') throw new Error('Only secp256k1 is supported'); + } + + keyFromPrivate(priv) { + const privBytes = typeof priv === 'string' ? + secp.utils.hexToBytes(priv.replace('0x', '')) : + priv; + + return { + getPublic: (compact = false) => { + const pubKey = secp.getPublicKey(privBytes); + return { + encode: (enc) => pubKey + }; + } + }; + } + + keyFromPublic(pub) { + const pubBytes = typeof pub === 'string' ? + secp.utils.hexToBytes(pub.replace('0x', '')) : + pub; + + return { + verify: async (msg, sig) => { + return secp.verify(sig, msg, pubBytes); + } + }; + } + } + + export const ec = EC; + export { EC }; + export default { EC }; + `, + loader: 'js', + resolveDir: path.dirname(fileURLToPath(import.meta.url)), + }) + ); + }, + }, + { + name: 'replace-lodash-isequal', + setup(build) { + build.onResolve({ filter: /^lodash\.isequal$/ }, () => ({ + path: 'virtual:isequal', + namespace: 'virtual', + })); + + build.onLoad( + { filter: /^virtual:isequal$/, namespace: 'virtual' }, + () => ({ + contents: ` + export default function isEqual(a, b) { + if (a === b) return true; + + if (a && b && typeof a === 'object' && typeof b === 'object') { + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) return false; + for (let i = 0; i < a.length; i++) { + if (!isEqual(a[i], b[i])) return false; + } + return true; + } + + const keys = Object.keys(a); + if (keys.length !== Object.keys(b).length) return false; + + for (const key of keys) { + if (!b.hasOwnProperty(key) || !isEqual(a[key], b[key])) return false; + } + return true; + } + + return false; + } + `, + loader: 'js', + }) + ); + }, + }, + { + name: 'replace-query-string', + setup(build) { + build.onResolve({ filter: /^query-string$/ }, () => ({ + path: 'virtual:query-string', + namespace: 'virtual', + })); + + build.onLoad( + { filter: /^virtual:query-string$/, namespace: 'virtual' }, + () => ({ + contents: ` + export function parse(str) { + const searchParams = new URLSearchParams(str); + const result = {}; + for (const [key, value] of searchParams.entries()) { + result[key] = value; + } + return result; + } + + export function stringify(obj) { + const searchParams = new URLSearchParams(); + for (const key in obj) { + if (obj[key] != null) { + searchParams.append(key, obj[key]); + } + } + return searchParams.toString(); + } + + export function parseUrl(url) { + const [base, query] = url.split('?'); + return { + url: base, + query: parse(query || '') + }; + } + + export default { + parse, + stringify, + parseUrl, + extract: url => url.split('?')[1] || '' + }; + `, + loader: 'js', + }) + ); + }, + }, + { + name: 'inline-tslib', + setup(build) { + build.onResolve({ filter: /^tslib$/ }, () => ({ + path: 'virtual:tslib', + namespace: 'virtual', + })); + + build.onLoad( + { filter: /^virtual:tslib$/, namespace: 'virtual' }, + () => ({ + contents: ` + export function __awaiter(thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function(resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + } + + export function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); + } + + export function __createBinding(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); + } + + export function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + } + + export function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + } + `, + loader: 'js', + }) + ); + }, + }, + { + name: 'replace-unstorage', + setup(build) { + build.onResolve({ filter: /^unstorage$/ }, () => ({ + path: 'virtual:unstorage', + namespace: 'virtual', + })); + + build.onLoad( + { filter: /^virtual:unstorage$/, namespace: 'virtual' }, + () => ({ + contents: ` + export function createStorage(options = {}) { + return { + async getItem(key) { + try { + return localStorage.getItem(key); + } catch (e) { + console.warn('Storage getItem error:', e); + return null; + } + }, + async setItem(key, value) { + try { + localStorage.setItem(key, value); + } catch (e) { + console.warn('Storage setItem error:', e); + } + }, + async removeItem(key) { + try { + localStorage.removeItem(key); + } catch (e) { + console.warn('Storage removeItem error:', e); + } + }, + async clear() { + try { + localStorage.clear(); + } catch (e) { + console.warn('Storage clear error:', e); + } + }, + async mount() {}, + async unmount() {} + }; + } + + export default { + createStorage + }; + `, + loader: 'js', + }) + ); + }, + }, + { + name: 'replace-signing-key', + setup(build) { + build.onResolve({ filter: /^@ethersproject\/signing-key/ }, () => ({ + path: 'virtual:signing-key', + namespace: 'virtual', + })); + + build.onLoad( + { filter: /^virtual:signing-key$/, namespace: 'virtual' }, + () => ({ + contents: ` + import { getPublicKey, sign, utils } from '@noble/secp256k1'; + import { hexlify, arrayify } from '@ethersproject/bytes'; + + export class SigningKey { + #privateKey; + #publicKey; + + constructor(privateKey) { + this.#privateKey = arrayify(privateKey); + this.#publicKey = getPublicKey(this.#privateKey, false); + } + + get publicKey() { + return hexlify(this.#publicKey); + } + + get privateKey() { + return hexlify(this.#privateKey); + } + + get compressedPublicKey() { + return hexlify(getPublicKey(this.#privateKey, true)); + } + + signDigest(digest) { + const [signature, recovery] = sign(arrayify(digest), this.#privateKey, { + recovered: true, + der: false, + }); + + const r = hexlify(signature.slice(0, 32)); + const s = hexlify(signature.slice(32, 64)); + + return { + r, + s, + v: recovery + 27, + _vs: null, + recoveryParam: recovery + }; + } + } + + export function computePublicKey(key, compressed = false) { + const publicKey = getPublicKey(arrayify(key), compressed); + return hexlify(publicKey); + } + + export function recoverPublicKey(digest, signature, recoveryParam) { + const sig = new Uint8Array(64); + sig.set(arrayify(signature.r), 0); + sig.set(arrayify(signature.s), 32); + + const publicKey = utils.recoverPublicKey( + arrayify(digest), + sig, + recoveryParam, + false + ); + + return hexlify(publicKey); + } + `, + loader: 'js', + resolveDir: process.cwd(), + }) + ); + }, + }, + { + name: 'replace-pino', + setup(build) { + // Match any pino import pattern + build.onResolve( + { + filter: /^pino($|\/.*$)|^\.\.\/\.\.\/node_modules\/pino(\/.*)?$/, + }, + () => ({ + path: 'virtual:pino-browser', + namespace: 'virtual', + }) + ); + + build.onLoad( + { filter: /^virtual:pino-browser$/, namespace: 'virtual' }, + () => ({ + contents: ` + // Simplified logger implementation + const noop = () => {}; + + const levels = { + values: { + trace: 10, + debug: 20, + info: 30, + warn: 40, + error: 50, + fatal: 60, + } + }; + + function createLogger() { + return { + trace: noop, + debug: noop, + info: console.log.bind(console), + warn: console.warn.bind(console), + error: console.error.bind(console), + fatal: console.error.bind(console), + child: function() { return this; } + }; + } + + function pino() { + return createLogger(); + } + + // Static properties + pino.destination = () => ({ write: noop }); + pino.transport = () => createLogger(); + pino.levels = levels; + + // Named exports + export { levels }; + export { pino }; + + // Default export + export default pino; + `, + loader: 'js', + }) + ); + }, + }, + ], }) .then((result) => { fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); diff --git a/packages/mobile-signing-provider/package.json b/packages/mobile-signing-provider/package.json index 5806162..43deb1c 100644 --- a/packages/mobile-signing-provider/package.json +++ b/packages/mobile-signing-provider/package.json @@ -22,12 +22,12 @@ "clean": "rimraf build node_modules" }, "devDependencies": { - "@types/qrcode": "1.5.5", + "@noble/secp256k1": "2.1.0", "@walletconnect/sign-client": "2.17.1", "@walletconnect/types": "2.17.1", "@walletconnect/utils": "2.17.1", "esbuild": "0.24.0", - "qrcode": "1.5.4" + "uqr": "0.1.2" }, "peerDependencies": { "elven.js": "*" diff --git a/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts b/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts index 670548b..ec2e336 100644 --- a/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts +++ b/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts @@ -1,4 +1,4 @@ -import { toString } from 'qrcode'; +import { renderSVG } from 'uqr'; import { WalletConnectV2Provider, PairingTypes } from './walletconnect-signing'; import { walletConnectDeepLink } from './utils'; import { errorParse } from './utils'; @@ -116,16 +116,14 @@ const isMobile = () => navigator.userAgent ); -const generateQRCode = async (walletConnectUri: string) => { +const generateQRCode = (walletConnectUri: string) => { if (!walletConnectUri) { return; } - const svg = await toString(walletConnectUri, { - type: 'svg', - }); + const qrCode = renderSVG(walletConnectUri); - return svg; + return qrCode; }; export const qrCodeAndPairingsBuilder = async ( @@ -147,7 +145,7 @@ export const qrCodeAndPairingsBuilder = async ( containerElem = qrCodeContainer; } - const qrCodeElementString = await generateQRCode(walletConnectUri); + const qrCodeElementString = generateQRCode(walletConnectUri); // QRCode From e6988b722d74c26d3326df09feb2b974cc4b04dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Tue, 5 Nov 2024 22:35:27 +0100 Subject: [PATCH 10/13] remove bundle size experiments and cleanup --- demo-app/mobile-signing-provider.js | 39 +- .../mobile-signing-provider/esbuild.config.js | 456 ------------------ .../src/components/init-mobile-provider.ts | 49 -- .../src/components/login-with-mobile.ts | 150 ------ .../src/components/types.ts | 22 + .../src/mobile-signing-provider.ts | 226 +++++++-- 6 files changed, 230 insertions(+), 712 deletions(-) delete mode 100644 packages/mobile-signing-provider/src/components/init-mobile-provider.ts delete mode 100644 packages/mobile-signing-provider/src/components/login-with-mobile.ts diff --git a/demo-app/mobile-signing-provider.js b/demo-app/mobile-signing-provider.js index f08eb98..1a1557a 100644 --- a/demo-app/mobile-signing-provider.js +++ b/demo-app/mobile-signing-provider.js @@ -6,7 +6,7 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var hm=Object.create;var on=Object.defineProperty;var lm=Object.getOwnPropertyDescriptor;var dm=Object.getOwnPropertyNames;var fm=Object.getPrototypeOf,pm=Object.prototype.hasOwnProperty;var ph=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var P=(i,e)=>()=>(i&&(e=i(i=0)),e);var oe=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),Se=(i,e)=>{for(var r in e)on(i,r,{get:e[r],enumerable:!0})},nn=(i,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of dm(e))!pm.call(i,s)&&s!==r&&on(i,s,{get:()=>e[s],enumerable:!(t=lm(e,s))||t.enumerable});return i},Me=(i,e,r)=>(nn(i,e,"default"),r&&nn(r,e,"default")),pe=(i,e,r)=>(r=i!=null?hm(fm(i)):{},nn(e||!i||!i.__esModule?on(r,"default",{value:i,enumerable:!0}):r,i)),ei=i=>nn(on({},"__esModule",{value:!0}),i);var Yt=oe((l2,Zo)=>{"use strict";var yr=typeof Reflect=="object"?Reflect:null,gh=yr&&typeof yr.apply=="function"?yr.apply:function(e,r,t){return Function.prototype.apply.call(e,r,t)},an;yr&&typeof yr.ownKeys=="function"?an=yr.ownKeys:Object.getOwnPropertySymbols?an=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:an=function(e){return Object.getOwnPropertyNames(e)};function gm(i){console&&console.warn&&console.warn(i)}var yh=Number.isNaN||function(e){return e!==e};function he(){he.init.call(this)}Zo.exports=he;Zo.exports.once=bm;he.EventEmitter=he;he.prototype._events=void 0;he.prototype._eventsCount=0;he.prototype._maxListeners=void 0;var mh=10;function cn(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(he,"defaultMaxListeners",{enumerable:!0,get:function(){return mh},set:function(i){if(typeof i!="number"||i<0||yh(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");mh=i}});he.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};he.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||yh(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function wh(i){return i._maxListeners===void 0?he.defaultMaxListeners:i._maxListeners}he.prototype.getMaxListeners=function(){return wh(this)};he.prototype.emit=function(e){for(var r=[],t=1;t0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(c===void 0)return!1;if(typeof c=="function")gh(c,this,r);else for(var h=c.length,d=xh(c,h),t=0;t0&&o.length>s&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=i,a.type=e,a.count=o.length,gm(a)}return i}he.prototype.addListener=function(e,r){return bh(this,e,r,!1)};he.prototype.on=he.prototype.addListener;he.prototype.prependListener=function(e,r){return bh(this,e,r,!0)};function mm(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Eh(i,e,r){var t={fired:!1,wrapFn:void 0,target:i,type:e,listener:r},s=mm.bind(t);return s.listener=r,t.wrapFn=s,s}he.prototype.once=function(e,r){return cn(r),this.on(e,Eh(this,e,r)),this};he.prototype.prependOnceListener=function(e,r){return cn(r),this.prependListener(e,Eh(this,e,r)),this};he.prototype.removeListener=function(e,r){var t,s,n,o,a;if(cn(r),s=this._events,s===void 0)return this;if(t=s[e],t===void 0)return this;if(t===r||t.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,t.listener||r));else if(typeof t!="function"){for(n=-1,o=t.length-1;o>=0;o--)if(t[o]===r||t[o].listener===r){a=t[o].listener,n=o;break}if(n<0)return this;n===0?t.shift():ym(t,n),t.length===1&&(s[e]=t[0]),s.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};he.prototype.off=he.prototype.removeListener;he.prototype.removeAllListeners=function(e){var r,t,s;if(t=this._events,t===void 0)return this;if(t.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):t[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete t[e]),this;if(arguments.length===0){var n=Object.keys(t),o;for(s=0;s=0;s--)this.removeListener(e,r[s]);return this};function _h(i,e,r){var t=i._events;if(t===void 0)return[];var s=t[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?wm(s):xh(s,s.length)}he.prototype.listeners=function(e){return _h(this,e,!0)};he.prototype.rawListeners=function(e){return _h(this,e,!1)};he.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):vh.call(i,e)};he.prototype.listenerCount=vh;function vh(i){var e=this._events;if(e!==void 0){var r=e[i];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}he.prototype.eventNames=function(){return this._eventsCount>0?an(this._events):[]};function xh(i,e){for(var r=new Array(e),t=0;t_m,__createBinding:()=>Ih,__exportStar:()=>vm,__read:()=>Sm,__values:()=>xm});function _m(i,e,r,t){return new(r||(r=Promise))(function(s,n){function o(h){try{c(t.next(h))}catch(d){n(d)}}function a(h){try{c(t.throw(h))}catch(d){n(d)}}function c(h){h.done?s(h.value):new r(function(d){d(h.value)}).then(o,a)}c((t=t.apply(i,e||[])).next())})}function vm(i,e){for(var r in i)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&Ih(e,i,r)}function Ih(i,e,r,t){t===void 0&&(t=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(i,t,s)}function xm(i){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&i[e],t=0;if(r)return r.call(i);if(i&&typeof i.length=="number")return{next:function(){return i&&t>=i.length&&(i=void 0),{value:i&&i[t++],done:!i}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Sm(i,e){var r=typeof Symbol=="function"&&i[Symbol.iterator];if(!r)return i;var t=r.call(i),s,n=[],o;try{for(;(e===void 0||e-- >0)&&!(s=t.next()).done;)n.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(r=t.return)&&r.call(t)}finally{if(o)throw o.error}}return n}var br=P(()=>{});var Dh=oe(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.delay=void 0;function Im(i){return new Promise(e=>{setTimeout(()=>{e(!0)},i)})}un.delay=Im});var Th=oe(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.ONE_THOUSAND=Er.ONE_HUNDRED=void 0;Er.ONE_HUNDRED=100;Er.ONE_THOUSAND=1e3});var Rh=oe(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.ONE_YEAR=K.FOUR_WEEKS=K.THREE_WEEKS=K.TWO_WEEKS=K.ONE_WEEK=K.THIRTY_DAYS=K.SEVEN_DAYS=K.FIVE_DAYS=K.THREE_DAYS=K.ONE_DAY=K.TWENTY_FOUR_HOURS=K.TWELVE_HOURS=K.SIX_HOURS=K.THREE_HOURS=K.ONE_HOUR=K.SIXTY_MINUTES=K.THIRTY_MINUTES=K.TEN_MINUTES=K.FIVE_MINUTES=K.ONE_MINUTE=K.SIXTY_SECONDS=K.THIRTY_SECONDS=K.TEN_SECONDS=K.FIVE_SECONDS=K.ONE_SECOND=void 0;K.ONE_SECOND=1;K.FIVE_SECONDS=5;K.TEN_SECONDS=10;K.THIRTY_SECONDS=30;K.SIXTY_SECONDS=60;K.ONE_MINUTE=K.SIXTY_SECONDS;K.FIVE_MINUTES=K.ONE_MINUTE*5;K.TEN_MINUTES=K.ONE_MINUTE*10;K.THIRTY_MINUTES=K.ONE_MINUTE*30;K.SIXTY_MINUTES=K.ONE_MINUTE*60;K.ONE_HOUR=K.SIXTY_MINUTES;K.THREE_HOURS=K.ONE_HOUR*3;K.SIX_HOURS=K.ONE_HOUR*6;K.TWELVE_HOURS=K.ONE_HOUR*12;K.TWENTY_FOUR_HOURS=K.ONE_HOUR*24;K.ONE_DAY=K.TWENTY_FOUR_HOURS;K.THREE_DAYS=K.ONE_DAY*3;K.FIVE_DAYS=K.ONE_DAY*5;K.SEVEN_DAYS=K.ONE_DAY*7;K.THIRTY_DAYS=K.ONE_DAY*30;K.ONE_WEEK=K.SEVEN_DAYS;K.TWO_WEEKS=K.ONE_WEEK*2;K.THREE_WEEKS=K.ONE_WEEK*3;K.FOUR_WEEKS=K.ONE_WEEK*4;K.ONE_YEAR=K.ONE_DAY*365});var ea=oe(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});var Ch=(br(),ei(wr));Ch.__exportStar(Th(),hn);Ch.__exportStar(Rh(),hn)});var Ah=oe(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.fromMiliseconds=_r.toMiliseconds=void 0;var Nh=ea();function Dm(i){return i*Nh.ONE_THOUSAND}_r.toMiliseconds=Dm;function Tm(i){return Math.floor(i/Nh.ONE_THOUSAND)}_r.fromMiliseconds=Tm});var Ph=oe(ln=>{"use strict";Object.defineProperty(ln,"__esModule",{value:!0});var Oh=(br(),ei(wr));Oh.__exportStar(Dh(),ln);Oh.__exportStar(Ah(),ln)});var Lh=oe(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});ti.Watch=void 0;var dn=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let r=this.get(e);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let t=Date.now()-r.started;this.timestamps.set(e,{started:r.started,elapsed:t})}get(e){let r=this.timestamps.get(e);if(typeof r>"u")throw new Error(`No timestamp found for label: ${e}`);return r}elapsed(e){let r=this.get(e);return r.elapsed||Date.now()-r.started}};ti.Watch=dn;ti.default=dn});var Uh=oe(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.IWatch=void 0;var ta=class{};fn.IWatch=ta});var Mh=oe(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});var Rm=(br(),ei(wr));Rm.__exportStar(Uh(),ra)});var xr=oe(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});var pn=(br(),ei(wr));pn.__exportStar(Ph(),vr);pn.__exportStar(Lh(),vr);pn.__exportStar(Mh(),vr);pn.__exportStar(ea(),vr)});var Qe,Fh=P(()=>{Qe=class{}});var ia=P(()=>{Fh()});var Bh,mn,sa,kh,Xt,gn,qh=P(()=>{Bh=pe(Yt()),mn=pe(xr());ia();sa=class extends Qe{constructor(e){super()}},kh=mn.FIVE_SECONDS,Xt={pulse:"heartbeat_pulse"},gn=class i extends sa{constructor(e){super(e),this.events=new Bh.EventEmitter,this.interval=kh,this.interval=e?.interval||kh}static async init(e){let r=new i(e);return await r.init(),r}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,mn.toMiliseconds)(this.interval))}pulse(){this.events.emit(Xt.pulse)}}});function zh(i={}){return{async getItem(e){try{return localStorage.getItem(e)}catch(r){return console.warn("Storage getItem error:",r),null}},async setItem(e,r){try{localStorage.setItem(e,r)}catch(t){console.warn("Storage setItem error:",t)}},async removeItem(e){try{localStorage.removeItem(e)}catch(r){console.warn("Storage removeItem error:",r)}},async clear(){try{localStorage.clear()}catch(e){console.warn("Storage clear error:",e)}},async mount(){},async unmount(){}}}var Vh=P(()=>{});function Qt(i){return new Promise((e,r)=>{i.oncomplete=i.onsuccess=()=>e(i.result),i.onabort=i.onerror=()=>r(i.error)})}function oa(i,e){let r=indexedDB.open(i);r.onupgradeneeded=()=>r.result.createObjectStore(e);let t=Qt(r);return(s,n)=>t.then(o=>n(o.transaction(e,s).objectStore(e)))}function ri(){return na||(na=oa("keyval-store","keyval")),na}function aa(i,e=ri()){return e("readonly",r=>Qt(r.get(i)))}function Kh(i,e,r=ri()){return r("readwrite",t=>(t.put(e,i),Qt(t.transaction)))}function jh(i,e=ri()){return e("readwrite",r=>(r.delete(i),Qt(r.transaction)))}function $h(i=ri()){return i("readwrite",e=>(e.clear(),Qt(e.transaction)))}function Cm(i,e){return i.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},Qt(i.transaction)}function Hh(i=ri()){return i("readonly",e=>{if(e.getAllKeys)return Qt(e.getAllKeys());let r=[];return Cm(e,t=>r.push(t.key)).then(()=>r)})}var na,Gh=P(()=>{});function ut(i){if(typeof i!="string")throw new Error(`Cannot safe json parse value of type ${typeof i}`);try{return Am(i)}catch{return i}}function $e(i){return typeof i=="string"?i:Nm(i)||""}var Nm,Am,Sr=P(()=>{Nm=i=>JSON.stringify(i,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),Am=i=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=i.replace(e,'$1"$2n"$3');return JSON.parse(r,(t,s)=>typeof s=="string"&&s.match(/^\d+n$/)?BigInt(s.substring(0,s.length-1)):s)}});function Mm(i){var e;return[i[0],ut((e=i[1])!=null?e:"")]}var Om,Pm,Lm,Um,ua,ca,yn,ha,Fm,Wh,km,Bm,wn,Jh=P(()=>{Vh();Gh();Sr();Om="idb-keyval",Pm=(i={})=>{let e=i.base&&i.base.length>0?`${i.base}:`:"",r=s=>e+s,t;return i.dbName&&i.storeName&&(t=oa(i.dbName,i.storeName)),{name:Om,options:i,async hasItem(s){return!(typeof await aa(r(s),t)>"u")},async getItem(s){return await aa(r(s),t)??null},setItem(s,n){return Kh(r(s),n,t)},removeItem(s){return jh(r(s),t)},getKeys(){return Hh(t)},clear(){return $h(t)}}},Lm="WALLET_CONNECT_V2_INDEXED_DB",Um="keyvaluestorage",ua=class{constructor(){this.indexedDb=zh({driver:Pm({dbName:Lm,storeName:Um})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let r=await this.indexedDb.getItem(e);if(r!==null)return r}async setItem(e,r){await this.indexedDb.setItem(e,$e(r))}async removeItem(e){await this.indexedDb.removeItem(e)}},ca=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},yn={exports:{}};(function(){let i;function e(){}i=e,i.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},i.prototype.setItem=function(r,t){this[r]=String(t)},i.prototype.removeItem=function(r){delete this[r]},i.prototype.clear=function(){let r=this;Object.keys(r).forEach(function(t){r[t]=void 0,delete r[t]})},i.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},i.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof ca<"u"&&ca.localStorage?yn.exports=ca.localStorage:typeof window<"u"&&window.localStorage?yn.exports=window.localStorage:yn.exports=new e})();ha=class{constructor(){this.localStorage=yn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Mm)}async getItem(e){let r=this.localStorage.getItem(e);if(r!==null)return ut(r)}async setItem(e,r){this.localStorage.setItem(e,$e(r))}async removeItem(e){this.localStorage.removeItem(e)}},Fm="wc_storage_version",Wh=1,km=async(i,e,r)=>{let t=Fm,s=await e.getItem(t);if(s&&s>=Wh){r(e);return}let n=await i.getKeys();if(!n.length){r(e);return}let o=[];for(;n.length;){let a=n.shift();if(!a)continue;let c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){let h=await i.getItem(a);await e.setItem(a,h),o.push(a)}}await e.setItem(t,Wh),r(e),Bm(i,o)},Bm=async(i,e)=>{e.length&&e.forEach(async r=>{await i.removeItem(r)})},wn=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};let e=new ha;this.storage=e;try{let r=new ua;km(e,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,r){return await this.initialize(),this.storage.setItem(e,r)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let r=setInterval(()=>{this.initialized&&(clearInterval(r),e())},20)})}}});function Yh(){return{trace:la,debug:la,info:console.log.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),fatal:console.error.bind(console),child:function(){return this}}}function bn(){return Yh()}var la,Zt,Pt,da=P(()=>{la=()=>{},Zt={values:{trace:10,debug:20,info:30,warn:40,error:50,fatal:60}};bn.destination=()=>({write:la});bn.transport=()=>Yh();bn.levels=Zt;Pt=bn});function si(i){return xn(vn({},i),{level:i?.level||qm.level})}function Hm(i,e=ii){return i[e]||""}function Gm(i,e,r=ii){return i[r]=e,i}function Re(i,e=ii){let r="";return typeof i.bindings>"u"?r=Hm(i,e):r=i.bindings().context||"",r}function Wm(i,e,r=ii){let t=Re(i,r);return t.trim()?`${t}/${e}`:e}function Ie(i,e,r=ii){let t=Wm(i,e,r),s=i.child({context:t});return Gm(s,t,r)}function Jm(i){var e,r;let t=new pa((e=i.opts)==null?void 0:e.level,i.maxSizeInBytes);return{logger:Pt(xn(vn({},i.opts),{level:"trace",browser:xn(vn({},(r=i.opts)==null?void 0:r.browser),{write:s=>t.write(s)})})),chunkLoggerController:t}}function Ym(i){var e;let r=new ga((e=i.opts)==null?void 0:e.level,i.maxSizeInBytes);return{logger:Pt(xn(vn({},i.opts),{level:"trace"}),r),chunkLoggerController:r}}function Zh(i){return typeof i.loggerOverride<"u"&&typeof i.loggerOverride!="string"?{logger:i.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Jm(i):Ym(i)}var qm,ii,ma,fa,En,_n,pa,ga,zm,Vm,Km,Xh,jm,$m,Qh,vn,xn,ya=P(()=>{da();da();Sr();qm={level:"info"},ii="custom_context",ma=1e3*1024,fa=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},En=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let r=new fa(e);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],r=this.head;for(;r!==null;)e.push(r.value),r=r.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let r=e.value;return e=e.next,{done:!1,value:r}}}}},_n=class{constructor(e,r=ma){this.level=e??"error",this.levelValue=Zt.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new En(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,r){r===Zt.values.error?console.error(e):r===Zt.values.warn?console.warn(e):r===Zt.values.debug?console.debug(e):r===Zt.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append($e({timestamp:new Date().toISOString(),log:e}));let r=typeof e=="string"?JSON.parse(e).level:e.level;r>=this.levelValue&&this.forwardToConsole(e,r)}getLogs(){return this.logs}clearLogs(){this.logs=new En(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let r=this.getLogArray();return r.push($e({extraMetadata:e})),new Blob(r,{type:"application/json"})}},pa=class{constructor(e,r=ma){this.baseChunkLogger=new _n(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let r=URL.createObjectURL(this.logsToBlob(e)),t=document.createElement("a");t.href=r,t.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(t),t.click(),document.body.removeChild(t),URL.revokeObjectURL(r)}},ga=class{constructor(e,r=ma){this.baseChunkLogger=new _n(e,r)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},zm=Object.defineProperty,Vm=Object.defineProperties,Km=Object.getOwnPropertyDescriptors,Xh=Object.getOwnPropertySymbols,jm=Object.prototype.hasOwnProperty,$m=Object.prototype.propertyIsEnumerable,Qh=(i,e,r)=>e in i?zm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,vn=(i,e)=>{for(var r in e||(e={}))jm.call(e,r)&&Qh(i,r,e[r]);if(Xh)for(var r of Xh(e))$m.call(e,r)&&Qh(i,r,e[r]);return i},xn=(i,e)=>Vm(i,Km(e))});var el,Sn,In,Dn,Tn,Rn,Cn,Nn,An,On,Pn,Ln,Un,Mn,wa=P(()=>{ia();el=pe(Yt()),Sn=class extends Qe{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}},In=class extends Qe{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}},Dn=class{constructor(e,r){this.logger=e,this.core=r}},Tn=class extends Qe{constructor(e,r){super(),this.relayer=e,this.logger=r}},Rn=class extends Qe{constructor(e){super()}},Cn=class{constructor(e,r,t,s){this.core=e,this.logger=r,this.name=t}},Nn=class extends Qe{constructor(e,r){super(),this.relayer=e,this.logger=r}},An=class extends Qe{constructor(e,r){super(),this.core=e,this.logger=r}},On=class{constructor(e,r,t){this.core=e,this.logger=r,this.store=t}},Pn=class{constructor(e,r){this.projectId=e,this.logger=r}},Ln=class{constructor(e,r,t){this.core=e,this.logger=r,this.telemetryEnabled=t}},Un=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},Mn=class{constructor(e){this.client=e}}});var rl=oe(Fn=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});Fn.BrowserRandomSource=void 0;var tl=65536,ba=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let r=new Uint8Array(e);for(let t=0;t{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});function Xm(i){for(var e=0;e{});var sl=oe(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.NodeRandomSource=void 0;var Qm=He(),_a=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof ph<"u"){let e=il();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let t=new Uint8Array(e);for(let s=0;s{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.SystemRandomSource=void 0;var Zm=rl(),ey=sl(),va=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Zm.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new ey.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Bn.SystemRandomSource=va});var ol=oe(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});function ty(i,e){var r=i>>>16&65535,t=i&65535,s=e>>>16&65535,n=e&65535;return t*n+(r*n+t*s<<16>>>0)|0}ze.mul=Math.imul||ty;function ry(i,e){return i+e|0}ze.add=ry;function iy(i,e){return i-e|0}ze.sub=iy;function sy(i,e){return i<>>32-e}ze.rotl=sy;function ny(i,e){return i<<32-e|i>>>e}ze.rotr=ny;function oy(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i}ze.isInteger=Number.isInteger||oy;ze.MAX_SAFE_INTEGER=9007199254740991;ze.isSafeInteger=function(i){return ze.isInteger(i)&&i>=-ze.MAX_SAFE_INTEGER&&i<=ze.MAX_SAFE_INTEGER}});var Ir=oe(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});var al=ol();function ay(i,e){return e===void 0&&(e=0),(i[e+0]<<8|i[e+1])<<16>>16}ne.readInt16BE=ay;function cy(i,e){return e===void 0&&(e=0),(i[e+0]<<8|i[e+1])>>>0}ne.readUint16BE=cy;function uy(i,e){return e===void 0&&(e=0),(i[e+1]<<8|i[e])<<16>>16}ne.readInt16LE=uy;function hy(i,e){return e===void 0&&(e=0),(i[e+1]<<8|i[e])>>>0}ne.readUint16LE=hy;function cl(i,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=i>>>8,e[r+1]=i>>>0,e}ne.writeUint16BE=cl;ne.writeInt16BE=cl;function ul(i,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=i>>>0,e[r+1]=i>>>8,e}ne.writeUint16LE=ul;ne.writeInt16LE=ul;function xa(i,e){return e===void 0&&(e=0),i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}ne.readInt32BE=xa;function Sa(i,e){return e===void 0&&(e=0),(i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0}ne.readUint32BE=Sa;function Ia(i,e){return e===void 0&&(e=0),i[e+3]<<24|i[e+2]<<16|i[e+1]<<8|i[e]}ne.readInt32LE=Ia;function Da(i,e){return e===void 0&&(e=0),(i[e+3]<<24|i[e+2]<<16|i[e+1]<<8|i[e])>>>0}ne.readUint32LE=Da;function qn(i,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=i>>>24,e[r+1]=i>>>16,e[r+2]=i>>>8,e[r+3]=i>>>0,e}ne.writeUint32BE=qn;ne.writeInt32BE=qn;function zn(i,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=i>>>0,e[r+1]=i>>>8,e[r+2]=i>>>16,e[r+3]=i>>>24,e}ne.writeUint32LE=zn;ne.writeInt32LE=zn;function ly(i,e){e===void 0&&(e=0);var r=xa(i,e),t=xa(i,e+4);return r*4294967296+t-(t>>31)*4294967296}ne.readInt64BE=ly;function dy(i,e){e===void 0&&(e=0);var r=Sa(i,e),t=Sa(i,e+4);return r*4294967296+t}ne.readUint64BE=dy;function fy(i,e){e===void 0&&(e=0);var r=Ia(i,e),t=Ia(i,e+4);return t*4294967296+r-(r>>31)*4294967296}ne.readInt64LE=fy;function py(i,e){e===void 0&&(e=0);var r=Da(i,e),t=Da(i,e+4);return t*4294967296+r}ne.readUint64LE=py;function hl(i,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),qn(i/4294967296>>>0,e,r),qn(i>>>0,e,r+4),e}ne.writeUint64BE=hl;ne.writeInt64BE=hl;function ll(i,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),zn(i>>>0,e,r),zn(i/4294967296>>>0,e,r+4),e}ne.writeUint64LE=ll;ne.writeInt64LE=ll;function gy(i,e,r){if(r===void 0&&(r=0),i%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(i/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var t=0,s=1,n=i/8+r-1;n>=r;n--)t+=e[n]*s,s*=256;return t}ne.readUintBE=gy;function my(i,e,r){if(r===void 0&&(r=0),i%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(i/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var t=0,s=1,n=r;n=t;n--)r[n]=e/s&255,s*=256;return r}ne.writeUintBE=yy;function wy(i,e,r,t){if(r===void 0&&(r=new Uint8Array(i/8)),t===void 0&&(t=0),i%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!al.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var s=1,n=t;n{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.randomStringForEntropy=Ce.randomString=Ce.randomUint32=Ce.randomBytes=Ce.defaultRandomSource=void 0;var Ty=nl(),Ry=Ir(),dl=He();Ce.defaultRandomSource=new Ty.SystemRandomSource;function Ta(i,e=Ce.defaultRandomSource){return e.randomBytes(i)}Ce.randomBytes=Ta;function Cy(i=Ce.defaultRandomSource){let e=Ta(4,i),r=(0,Ry.readUint32LE)(e);return(0,dl.wipe)(e),r}Ce.randomUint32=Cy;var fl="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function pl(i,e=fl,r=Ce.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let t="",s=e.length,n=256-256%s;for(;i>0;){let o=Ta(Math.ceil(i*256/n),r);for(let a=0;a0;a++){let c=o[a];c{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});var Tr=Ir(),Dr=He();_t.DIGEST_LENGTH=64;_t.BLOCK_SIZE=128;var ml=function(){function i(){this.digestLength=_t.DIGEST_LENGTH,this.blockSize=_t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return i.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},i.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},i.prototype.clean=function(){Dr.wipe(this._buffer),Dr.wipe(this._tempHi),Dr.wipe(this._tempLo),this.reset()},i.prototype.update=function(e,r){if(r===void 0&&(r=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var t=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength<_t.BLOCK_SIZE&&r>0;)this._buffer[this._bufferLength++]=e[t++],r--;this._bufferLength===this.blockSize&&(Ra(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(t=Ra(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,t,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=e[t++],r--;return this},i.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,t=this._bufferLength,s=r/536870912|0,n=r<<3,o=r%128<112?128:256;this._buffer[t]=128;for(var a=t+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},i.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},i.prototype.cleanSavedState=function(e){Dr.wipe(e.stateHi),Dr.wipe(e.stateLo),e.buffer&&Dr.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},i}();_t.SHA512=ml;var gl=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Ra(i,e,r,t,s,n,o){for(var a=r[0],c=r[1],h=r[2],d=r[3],l=r[4],p=r[5],f=r[6],g=r[7],w=t[0],b=t[1],v=t[2],x=t[3],I=t[4],S=t[5],T=t[6],L=t[7],y,m,k,$,O,C,R,N;o>=128;){for(var G=0;G<16;G++){var H=8*G+n;i[G]=Tr.readUint32BE(s,H),e[G]=Tr.readUint32BE(s,H+4)}for(var G=0;G<80;G++){var q=a,j=c,re=h,Y=d,Z=l,V=p,J=f,X=g,u=w,E=b,_=v,D=x,A=I,U=S,F=T,M=L;if(y=g,m=L,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=(l>>>14|I<<18)^(l>>>18|I<<14)^(I>>>9|l<<23),m=(I>>>14|l<<18)^(I>>>18|l<<14)^(l>>>9|I<<23),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=l&p^~l&f,m=I&S^~I&T,O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=gl[G*2],m=gl[G*2+1],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=i[G%16],m=e[G%16],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,k=R&65535|N<<16,$=O&65535|C<<16,y=k,m=$,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=(a>>>28|w<<4)^(w>>>2|a<<30)^(w>>>7|a<<25),m=(w>>>28|a<<4)^(a>>>2|w<<30)^(a>>>7|w<<25),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,y=a&c^a&h^c&h,m=w&b^w&v^b&v,O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,X=R&65535|N<<16,M=O&65535|C<<16,y=Y,m=D,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=k,m=$,O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,Y=R&65535|N<<16,D=O&65535|C<<16,c=q,h=j,d=re,l=Y,p=Z,f=V,g=J,a=X,b=u,v=E,x=_,I=D,S=A,T=U,L=F,w=M,G%16===15)for(var H=0;H<16;H++)y=i[H],m=e[H],O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=i[(H+9)%16],m=e[(H+9)%16],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,k=i[(H+1)%16],$=e[(H+1)%16],y=(k>>>1|$<<31)^(k>>>8|$<<24)^k>>>7,m=($>>>1|k<<31)^($>>>8|k<<24)^($>>>7|k<<25),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,k=i[(H+14)%16],$=e[(H+14)%16],y=(k>>>19|$<<13)^($>>>29|k<<3)^k>>>6,m=($>>>19|k<<13)^(k>>>29|$<<3)^($>>>6|k<<26),O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,i[H]=R&65535|N<<16,e[H]=O&65535|C<<16}y=a,m=w,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[0],m=t[0],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[0]=a=R&65535|N<<16,t[0]=w=O&65535|C<<16,y=c,m=b,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[1],m=t[1],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[1]=c=R&65535|N<<16,t[1]=b=O&65535|C<<16,y=h,m=v,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[2],m=t[2],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[2]=h=R&65535|N<<16,t[2]=v=O&65535|C<<16,y=d,m=x,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[3],m=t[3],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[3]=d=R&65535|N<<16,t[3]=x=O&65535|C<<16,y=l,m=I,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[4],m=t[4],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[4]=l=R&65535|N<<16,t[4]=I=O&65535|C<<16,y=p,m=S,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[5],m=t[5],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[5]=p=R&65535|N<<16,t[5]=S=O&65535|C<<16,y=f,m=T,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[6],m=t[6],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[6]=f=R&65535|N<<16,t[6]=T=O&65535|C<<16,y=g,m=L,O=m&65535,C=m>>>16,R=y&65535,N=y>>>16,y=r[7],m=t[7],O+=m&65535,C+=m>>>16,R+=y&65535,N+=y>>>16,C+=O>>>16,R+=C>>>16,N+=R>>>16,r[7]=g=R&65535|N<<16,t[7]=L=O&65535|C<<16,n+=128,o-=128}return n}function Ay(i){var e=new ml;e.update(i);var r=e.digest();return e.clean(),r}_t.hash=Ay});var Al=oe(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});ue.convertSecretKeyToX25519=ue.convertPublicKeyToX25519=ue.verify=ue.sign=ue.extractPublicKeyFromSecretKey=ue.generateKeyPair=ue.generateKeyPairFromSeed=ue.SEED_LENGTH=ue.SECRET_KEY_LENGTH=ue.PUBLIC_KEY_LENGTH=ue.SIGNATURE_LENGTH=void 0;var Oy=ni(),oi=yl(),vl=He();ue.SIGNATURE_LENGTH=64;ue.PUBLIC_KEY_LENGTH=32;ue.SECRET_KEY_LENGTH=64;ue.SEED_LENGTH=32;function te(i){let e=new Float64Array(16);if(i)for(let r=0;r>16&1),r[o-1]&=65535;r[15]=t[15]-32767-(r[14]>>16&1);let n=r[15]>>16&1;r[14]&=65535,xl(t,r,1-n)}for(let s=0;s<16;s++)i[2*s]=t[s]&255,i[2*s+1]=t[s]>>8}function Sl(i,e){let r=0;for(let t=0;t<32;t++)r|=i[t]^e[t];return(1&r-1>>>8)-1}function El(i,e){let r=new Uint8Array(32),t=new Uint8Array(32);return ai(r,i),ai(t,e),Sl(r,t)}function Il(i){let e=new Uint8Array(32);return ai(e,i),e[0]&1}function Fy(i,e){for(let r=0;r<16;r++)i[r]=e[2*r]+(e[2*r+1]<<8);i[15]&=32767}function er(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]+r[t]}function rr(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]-r[t]}function le(i,e,r){let t,s,n=0,o=0,a=0,c=0,h=0,d=0,l=0,p=0,f=0,g=0,w=0,b=0,v=0,x=0,I=0,S=0,T=0,L=0,y=0,m=0,k=0,$=0,O=0,C=0,R=0,N=0,G=0,H=0,q=0,j=0,re=0,Y=r[0],Z=r[1],V=r[2],J=r[3],X=r[4],u=r[5],E=r[6],_=r[7],D=r[8],A=r[9],U=r[10],F=r[11],M=r[12],Q=r[13],z=r[14],ee=r[15];t=e[0],n+=t*Y,o+=t*Z,a+=t*V,c+=t*J,h+=t*X,d+=t*u,l+=t*E,p+=t*_,f+=t*D,g+=t*A,w+=t*U,b+=t*F,v+=t*M,x+=t*Q,I+=t*z,S+=t*ee,t=e[1],o+=t*Y,a+=t*Z,c+=t*V,h+=t*J,d+=t*X,l+=t*u,p+=t*E,f+=t*_,g+=t*D,w+=t*A,b+=t*U,v+=t*F,x+=t*M,I+=t*Q,S+=t*z,T+=t*ee,t=e[2],a+=t*Y,c+=t*Z,h+=t*V,d+=t*J,l+=t*X,p+=t*u,f+=t*E,g+=t*_,w+=t*D,b+=t*A,v+=t*U,x+=t*F,I+=t*M,S+=t*Q,T+=t*z,L+=t*ee,t=e[3],c+=t*Y,h+=t*Z,d+=t*V,l+=t*J,p+=t*X,f+=t*u,g+=t*E,w+=t*_,b+=t*D,v+=t*A,x+=t*U,I+=t*F,S+=t*M,T+=t*Q,L+=t*z,y+=t*ee,t=e[4],h+=t*Y,d+=t*Z,l+=t*V,p+=t*J,f+=t*X,g+=t*u,w+=t*E,b+=t*_,v+=t*D,x+=t*A,I+=t*U,S+=t*F,T+=t*M,L+=t*Q,y+=t*z,m+=t*ee,t=e[5],d+=t*Y,l+=t*Z,p+=t*V,f+=t*J,g+=t*X,w+=t*u,b+=t*E,v+=t*_,x+=t*D,I+=t*A,S+=t*U,T+=t*F,L+=t*M,y+=t*Q,m+=t*z,k+=t*ee,t=e[6],l+=t*Y,p+=t*Z,f+=t*V,g+=t*J,w+=t*X,b+=t*u,v+=t*E,x+=t*_,I+=t*D,S+=t*A,T+=t*U,L+=t*F,y+=t*M,m+=t*Q,k+=t*z,$+=t*ee,t=e[7],p+=t*Y,f+=t*Z,g+=t*V,w+=t*J,b+=t*X,v+=t*u,x+=t*E,I+=t*_,S+=t*D,T+=t*A,L+=t*U,y+=t*F,m+=t*M,k+=t*Q,$+=t*z,O+=t*ee,t=e[8],f+=t*Y,g+=t*Z,w+=t*V,b+=t*J,v+=t*X,x+=t*u,I+=t*E,S+=t*_,T+=t*D,L+=t*A,y+=t*U,m+=t*F,k+=t*M,$+=t*Q,O+=t*z,C+=t*ee,t=e[9],g+=t*Y,w+=t*Z,b+=t*V,v+=t*J,x+=t*X,I+=t*u,S+=t*E,T+=t*_,L+=t*D,y+=t*A,m+=t*U,k+=t*F,$+=t*M,O+=t*Q,C+=t*z,R+=t*ee,t=e[10],w+=t*Y,b+=t*Z,v+=t*V,x+=t*J,I+=t*X,S+=t*u,T+=t*E,L+=t*_,y+=t*D,m+=t*A,k+=t*U,$+=t*F,O+=t*M,C+=t*Q,R+=t*z,N+=t*ee,t=e[11],b+=t*Y,v+=t*Z,x+=t*V,I+=t*J,S+=t*X,T+=t*u,L+=t*E,y+=t*_,m+=t*D,k+=t*A,$+=t*U,O+=t*F,C+=t*M,R+=t*Q,N+=t*z,G+=t*ee,t=e[12],v+=t*Y,x+=t*Z,I+=t*V,S+=t*J,T+=t*X,L+=t*u,y+=t*E,m+=t*_,k+=t*D,$+=t*A,O+=t*U,C+=t*F,R+=t*M,N+=t*Q,G+=t*z,H+=t*ee,t=e[13],x+=t*Y,I+=t*Z,S+=t*V,T+=t*J,L+=t*X,y+=t*u,m+=t*E,k+=t*_,$+=t*D,O+=t*A,C+=t*U,R+=t*F,N+=t*M,G+=t*Q,H+=t*z,q+=t*ee,t=e[14],I+=t*Y,S+=t*Z,T+=t*V,L+=t*J,y+=t*X,m+=t*u,k+=t*E,$+=t*_,O+=t*D,C+=t*A,R+=t*U,N+=t*F,G+=t*M,H+=t*Q,q+=t*z,j+=t*ee,t=e[15],S+=t*Y,T+=t*Z,L+=t*V,y+=t*J,m+=t*X,k+=t*u,$+=t*E,O+=t*_,C+=t*D,R+=t*A,N+=t*U,G+=t*F,H+=t*M,q+=t*Q,j+=t*z,re+=t*ee,n+=38*T,o+=38*L,a+=38*y,c+=38*m,h+=38*k,d+=38*$,l+=38*O,p+=38*C,f+=38*R,g+=38*N,w+=38*G,b+=38*H,v+=38*q,x+=38*j,I+=38*re,s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),i[0]=n,i[1]=o,i[2]=a,i[3]=c,i[4]=h,i[5]=d,i[6]=l,i[7]=p,i[8]=f,i[9]=g,i[10]=w,i[11]=b,i[12]=v,i[13]=x,i[14]=I,i[15]=S}function tr(i,e){le(i,e,e)}function Dl(i,e){let r=te(),t;for(t=0;t<16;t++)r[t]=e[t];for(t=253;t>=0;t--)tr(r,r),t!==2&&t!==4&&le(r,r,e);for(t=0;t<16;t++)i[t]=r[t]}function ky(i,e){let r=te(),t;for(t=0;t<16;t++)r[t]=e[t];for(t=250;t>=0;t--)tr(r,r),t!==1&&le(r,r,e);for(t=0;t<16;t++)i[t]=r[t]}function Oa(i,e){let r=te(),t=te(),s=te(),n=te(),o=te(),a=te(),c=te(),h=te(),d=te();rr(r,i[1],i[0]),rr(d,e[1],e[0]),le(r,r,d),er(t,i[0],i[1]),er(d,e[0],e[1]),le(t,t,d),le(s,i[3],e[3]),le(s,s,Uy),le(n,i[2],e[2]),er(n,n,n),rr(o,t,r),rr(a,n,s),er(c,n,s),er(h,t,r),le(i[0],o,a),le(i[1],h,c),le(i[2],c,a),le(i[3],o,h)}function _l(i,e,r){for(let t=0;t<4;t++)xl(i[t],e[t],r)}function La(i,e){let r=te(),t=te(),s=te();Dl(s,e[2]),le(r,e[0],s),le(t,e[1],s),ai(i,t),i[31]^=Il(r)<<7}function Tl(i,e,r){Lt(i[0],Aa),Lt(i[1],Rr),Lt(i[2],Rr),Lt(i[3],Aa);for(let t=255;t>=0;--t){let s=r[t/8|0]>>(t&7)&1;_l(i,e,s),Oa(e,i),Oa(i,i),_l(i,e,s)}}function Ua(i,e){let r=[te(),te(),te(),te()];Lt(r[0],wl),Lt(r[1],bl),Lt(r[2],Rr),le(r[3],wl,bl),Tl(i,r,e)}function Rl(i){if(i.length!==ue.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ue.SEED_LENGTH} bytes`);let e=(0,oi.hash)(i);e[0]&=248,e[31]&=127,e[31]|=64;let r=new Uint8Array(32),t=[te(),te(),te(),te()];Ua(t,e),La(r,t);let s=new Uint8Array(64);return s.set(i),s.set(r,32),{publicKey:r,secretKey:s}}ue.generateKeyPairFromSeed=Rl;function By(i){let e=(0,Oy.randomBytes)(32,i),r=Rl(e);return(0,vl.wipe)(e),r}ue.generateKeyPair=By;function qy(i){if(i.length!==ue.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ue.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(i.subarray(32))}ue.extractPublicKeyFromSecretKey=qy;var Na=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Cl(i,e){let r,t,s,n;for(t=63;t>=32;--t){for(r=0,s=t-32,n=t-12;s>4)*Na[s],r=e[s]>>8,e[s]&=255;for(s=0;s<32;s++)e[s]-=r*Na[s];for(t=0;t<32;t++)e[t+1]+=e[t]>>8,i[t]=e[t]&255}function Pa(i){let e=new Float64Array(64);for(let r=0;r<64;r++)e[r]=i[r];for(let r=0;r<64;r++)i[r]=0;Cl(i,e)}function zy(i,e){let r=new Float64Array(64),t=[te(),te(),te(),te()],s=(0,oi.hash)(i.subarray(0,32));s[0]&=248,s[31]&=127,s[31]|=64;let n=new Uint8Array(64);n.set(s.subarray(32),32);let o=new oi.SHA512;o.update(n.subarray(32)),o.update(e);let a=o.digest();o.clean(),Pa(a),Ua(t,a),La(n,t),o.reset(),o.update(n.subarray(0,32)),o.update(i.subarray(32)),o.update(e);let c=o.digest();Pa(c);for(let h=0;h<32;h++)r[h]=a[h];for(let h=0;h<32;h++)for(let d=0;d<32;d++)r[h+d]+=c[h]*s[d];return Cl(n.subarray(32),r),n}ue.sign=zy;function Nl(i,e){let r=te(),t=te(),s=te(),n=te(),o=te(),a=te(),c=te();return Lt(i[2],Rr),Fy(i[1],e),tr(s,i[1]),le(n,s,Ly),rr(s,s,i[2]),er(n,i[2],n),tr(o,n),tr(a,o),le(c,a,o),le(r,c,s),le(r,r,n),ky(r,r),le(r,r,s),le(r,r,n),le(r,r,n),le(i[0],r,n),tr(t,i[0]),le(t,t,n),El(t,s)&&le(i[0],i[0],My),tr(t,i[0]),le(t,t,n),El(t,s)?-1:(Il(i[0])===e[31]>>7&&rr(i[0],Aa,i[0]),le(i[3],i[0],i[1]),0)}function Vy(i,e,r){let t=new Uint8Array(32),s=[te(),te(),te(),te()],n=[te(),te(),te(),te()];if(r.length!==ue.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ue.SIGNATURE_LENGTH} bytes`);if(Nl(n,i))return!1;let o=new oi.SHA512;o.update(r.subarray(0,32)),o.update(i),o.update(e);let a=o.digest();return Pa(a),Tl(s,n,a),Ua(n,r.subarray(32)),Oa(s,n),La(t,s),!Sl(r,t)}ue.verify=Vy;function Ky(i){let e=[te(),te(),te(),te()];if(Nl(e,i))throw new Error("Ed25519: invalid public key");let r=te(),t=te(),s=e[1];er(r,Rr,s),rr(t,Rr,s),Dl(t,t),le(r,r,t);let n=new Uint8Array(32);return ai(n,r),n}ue.convertPublicKeyToX25519=Ky;function jy(i){let e=(0,oi.hash)(i.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let r=new Uint8Array(e.subarray(0,32));return(0,vl.wipe)(e),r}ue.convertSecretKeyToX25519=jy});var Ol,Pl,ci,ui,Ma,Fa,Ll,Ul,Ml,ka,Fl,kl,Vn=P(()=>{Ol="EdDSA",Pl="JWT",ci=".",ui="base64url",Ma="utf8",Fa="utf8",Ll=":",Ul="did",Ml="key",ka="base58btc",Fl="z",kl="K36"});function hi(i=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(i):new Uint8Array(i)}var Kn=P(()=>{});function ir(i,e){e||(e=i.reduce((s,n)=>s+n.length,0));let r=hi(e),t=0;for(let s of i)r.set(s,t),t+=s.length;return r}var Ba=P(()=>{Kn()});function $y(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),t=0;t>>0,S=new Uint8Array(I);v!==x;){for(var T=g[v],L=0,y=I-1;(T!==0||L>>0,S[y]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");b=L,v++}for(var m=I-b;m!==I&&S[m]===0;)m++;for(var k=c.repeat(w);m>>0,I=new Uint8Array(x);g[w];){var S=r[g.charCodeAt(w)];if(S===255)return;for(var T=0,L=x-1;(S!==0||T>>0,I[L]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");v=T,w++}if(g[w]!==" "){for(var y=x-v;y!==x&&I[y]===0;)y++;for(var m=new Uint8Array(b+(x-y)),k=b;y!==x;)m[k++]=I[y++];return m}}}function f(g){var w=p(g);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:f}}var Hy,Gy,Bl,ql=P(()=>{Hy=$y,Gy=Hy,Bl=Gy});var s3,zl,vt,Vl,Kl,Ut=P(()=>{s3=new Uint8Array(0),zl=(i,e)=>{if(i===e)return!0;if(i.byteLength!==e.byteLength)return!1;for(let r=0;r{if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")},Vl=i=>new TextEncoder().encode(i),Kl=i=>new TextDecoder().decode(i)});var qa,za,Va,$l,Ka,Cr,Mt,Wy,Jy,ye,Ze=P(()=>{ql();Ut();qa=class{constructor(e,r,t){this.name=e,this.prefix=r,this.baseEncode=t}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},za=class{constructor(e,r,t){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=t}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return $l(this,e)}},Va=class{constructor(e){this.decoders=e}or(e){return $l(this,e)}decode(e){let r=e[0],t=this.decoders[r];if(t)return t.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},$l=(i,e)=>new Va({...i.decoders||{[i.prefix]:i},...e.decoders||{[e.prefix]:e}}),Ka=class{constructor(e,r,t,s){this.name=e,this.prefix=r,this.baseEncode=t,this.baseDecode=s,this.encoder=new qa(e,r,t),this.decoder=new za(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Cr=({name:i,prefix:e,encode:r,decode:t})=>new Ka(i,e,r,t),Mt=({prefix:i,name:e,alphabet:r})=>{let{encode:t,decode:s}=Bl(r,e);return Cr({prefix:i,name:e,encode:t,decode:n=>vt(s(n))})},Wy=(i,e,r,t)=>{let s={};for(let d=0;d=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Jy=(i,e,r)=>{let t=e[e.length-1]==="=",s=(1<r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<Cr({prefix:e,name:i,encode(s){return Jy(s,t,r)},decode(s){return Wy(s,t,r,i)}})});var ja={};Se(ja,{identity:()=>Yy});var Yy,Hl=P(()=>{Ze();Ut();Yy=Cr({prefix:"\0",name:"identity",encode:i=>Kl(i),decode:i=>Vl(i)})});var $a={};Se($a,{base2:()=>Xy});var Xy,Gl=P(()=>{Ze();Xy=ye({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})});var Ha={};Se(Ha,{base8:()=>Qy});var Qy,Wl=P(()=>{Ze();Qy=ye({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})});var Ga={};Se(Ga,{base10:()=>Zy});var Zy,Jl=P(()=>{Ze();Zy=Mt({prefix:"9",name:"base10",alphabet:"0123456789"})});var Wa={};Se(Wa,{base16:()=>ew,base16upper:()=>tw});var ew,tw,Yl=P(()=>{Ze();ew=ye({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),tw=ye({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});var Ja={};Se(Ja,{base32:()=>Nr,base32hex:()=>nw,base32hexpad:()=>aw,base32hexpadupper:()=>cw,base32hexupper:()=>ow,base32pad:()=>iw,base32padupper:()=>sw,base32upper:()=>rw,base32z:()=>uw});var Nr,rw,iw,sw,nw,ow,aw,cw,uw,Ya=P(()=>{Ze();Nr=ye({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rw=ye({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),iw=ye({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),sw=ye({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nw=ye({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ow=ye({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),aw=ye({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),cw=ye({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),uw=ye({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})});var Xa={};Se(Xa,{base36:()=>hw,base36upper:()=>lw});var hw,lw,Xl=P(()=>{Ze();hw=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lw=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})});var Qa={};Se(Qa,{base58btc:()=>ht,base58flickr:()=>dw});var ht,dw,Za=P(()=>{Ze();ht=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),dw=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});var ec={};Se(ec,{base64:()=>fw,base64pad:()=>pw,base64url:()=>gw,base64urlpad:()=>mw});var fw,pw,gw,mw,Ql=P(()=>{Ze();fw=ye({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pw=ye({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gw=ye({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mw=ye({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});var tc={};Se(tc,{base256emoji:()=>_w});function bw(i){return i.reduce((e,r)=>(e+=yw[r],e),"")}function Ew(i){let e=[];for(let r of i){let t=ww[r.codePointAt(0)];if(t===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}var Zl,yw,ww,_w,ed=P(()=>{Ze();Zl=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),yw=Zl.reduce((i,e,r)=>(i[r]=e,i),[]),ww=Zl.reduce((i,e,r)=>(i[e.codePointAt(0)]=r,i),[]);_w=Cr({prefix:"\u{1F680}",name:"base256emoji",encode:bw,decode:Ew})});function id(i,e,r){e=e||[],r=r||0;for(var t=r;i>=Iw;)e[r++]=i&255|td,i/=128;for(;i&Sw;)e[r++]=i&255|td,i>>>=7;return e[r]=i|0,id.bytes=r-t+1,e}function rc(i,t){var r=0,t=t||0,s=0,n=t,o,a=i.length;do{if(n>=a)throw rc.bytes=0,new RangeError("Could not decode varint");o=i[n++],r+=s<28?(o&rd)<=Tw);return rc.bytes=n-t,r}var vw,td,xw,Sw,Iw,Dw,Tw,rd,Rw,Cw,Nw,Aw,Ow,Pw,Lw,Uw,Mw,Fw,kw,Bw,li,sd=P(()=>{vw=id,td=128,xw=127,Sw=~xw,Iw=Math.pow(2,31);Dw=rc,Tw=128,rd=127;Rw=Math.pow(2,7),Cw=Math.pow(2,14),Nw=Math.pow(2,21),Aw=Math.pow(2,28),Ow=Math.pow(2,35),Pw=Math.pow(2,42),Lw=Math.pow(2,49),Uw=Math.pow(2,56),Mw=Math.pow(2,63),Fw=function(i){return i{sd();di=(i,e=0)=>[li.decode(i,e),li.decode.bytes],Ar=(i,e,r=0)=>(li.encode(i,e,r),e),Or=i=>li.encodingLength(i)});var sr,nd,od,Pr,pi=P(()=>{Ut();$n();sr=(i,e)=>{let r=e.byteLength,t=Or(i),s=t+Or(r),n=new Uint8Array(s+r);return Ar(i,n,0),Ar(r,n,t),n.set(e,s),new Pr(i,r,e,n)},nd=i=>{let e=vt(i),[r,t]=di(e),[s,n]=di(e.subarray(t)),o=e.subarray(t+n);if(o.byteLength!==s)throw new Error("Incorrect length");return new Pr(r,s,o,e)},od=(i,e)=>i===e?!0:i.code===e.code&&i.size===e.size&&zl(i.bytes,e.bytes),Pr=class{constructor(e,r,t,s){this.code=e,this.size=r,this.digest=t,this.bytes=s}}});var sc,ic,nc=P(()=>{pi();sc=({name:i,code:e,encode:r})=>new ic(i,e,r),ic=class{constructor(e,r,t){this.name=e,this.code=r,this.encode=t}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?sr(this.code,r):r.then(t=>sr(this.code,t))}else throw Error("Unknown type, must be binary type")}}});var oc={};Se(oc,{sha256:()=>qw,sha512:()=>zw});var cd,qw,zw,ud=P(()=>{nc();cd=i=>async e=>new Uint8Array(await crypto.subtle.digest(i,e)),qw=sc({name:"sha2-256",code:18,encode:cd("SHA-256")}),zw=sc({name:"sha2-512",code:19,encode:cd("SHA-512")})});var ac={};Se(ac,{identity:()=>jw});var hd,Vw,ld,Kw,jw,dd=P(()=>{Ut();pi();hd=0,Vw="identity",ld=vt,Kw=i=>sr(hd,ld(i)),jw={code:hd,name:Vw,encode:ld,digest:Kw}});var fd=P(()=>{Ut()});var I3,D3,pd=P(()=>{I3=new TextEncoder,D3=new TextDecoder});var Wn,Gw,Ww,Jw,gi,Yw,gd,md,Hn,Gn,Xw,Qw,Zw,yd=P(()=>{$n();pi();Za();Ya();Ut();Wn=class i{constructor(e,r,t,s){this.code=r,this.version=e,this.multihash=t,this.bytes=s,this.byteOffset=s.byteOffset,this.byteLength=s.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Gn,byteLength:Gn,code:Hn,version:Hn,multihash:Hn,bytes:Hn,_baseCache:Gn,asCID:Gn})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:r}=this;if(e!==gi)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Yw)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return i.createV0(r)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,t=sr(e,r);return i.createV1(this.code,t)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&od(this.multihash,e.multihash)}toString(e){let{bytes:r,version:t,_baseCache:s}=this;switch(t){case 0:return Ww(r,s,e||ht.encoder);default:return Jw(r,s,e||Nr.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return Qw(/^0\.0/,Zw),!!(e&&(e[md]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof i)return e;if(e!=null&&e.asCID===e){let{version:r,code:t,multihash:s,bytes:n}=e;return new i(r,t,s,n||gd(r,t,s.bytes))}else if(e!=null&&e[md]===!0){let{version:r,multihash:t,code:s}=e,n=nd(t);return i.create(r,s,n)}else return null}static create(e,r,t){if(typeof r!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(r!==gi)throw new Error(`Version 0 CID must use dag-pb (code: ${gi}) block encoding`);return new i(e,r,t,t.bytes)}case 1:{let s=gd(e,r,t.bytes);return new i(e,r,t,s)}default:throw new Error("Invalid version")}}static createV0(e){return i.create(0,gi,e)}static createV1(e,r){return i.create(1,e,r)}static decode(e){let[r,t]=i.decodeFirst(e);if(t.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=i.inspectBytes(e),t=r.size-r.multihashSize,s=vt(e.subarray(t,t+r.multihashSize));if(s.byteLength!==r.multihashSize)throw new Error("Incorrect length");let n=s.subarray(r.multihashSize-r.digestSize),o=new Pr(r.multihashCode,r.digestSize,n,s);return[r.version===0?i.createV0(o):i.createV1(r.codec,o),e.subarray(r.size)]}static inspectBytes(e){let r=0,t=()=>{let[l,p]=di(e.subarray(r));return r+=p,l},s=t(),n=gi;if(s===18?(s=0,r=0):s===1&&(n=t()),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let o=r,a=t(),c=t(),h=r+c,d=h-o;return{version:s,codec:n,multihashCode:a,digestSize:c,multihashSize:d,size:h}}static parse(e,r){let[t,s]=Gw(e,r),n=i.decode(s);return n._baseCache.set(t,e),n}},Gw=(i,e)=>{switch(i[0]){case"Q":{let r=e||ht;return[ht.prefix,r.decode(`${ht.prefix}${i}`)]}case ht.prefix:{let r=e||ht;return[ht.prefix,r.decode(i)]}case Nr.prefix:{let r=e||Nr;return[Nr.prefix,r.decode(i)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[i[0],e.decode(i)]}}},Ww=(i,e,r)=>{let{prefix:t}=r;if(t!==ht.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let s=e.get(t);if(s==null){let n=r.encode(i).slice(1);return e.set(t,n),n}else return s},Jw=(i,e,r)=>{let{prefix:t}=r,s=e.get(t);if(s==null){let n=r.encode(i);return e.set(t,n),n}else return s},gi=112,Yw=18,gd=(i,e,r)=>{let t=Or(i),s=t+Or(e),n=new Uint8Array(s+r.byteLength);return Ar(i,n,0),Ar(e,n,t),n.set(r,s),n},md=Symbol.for("@ipld/js-cid/CID"),Hn={writable:!1,configurable:!1,enumerable:!0},Gn={writable:!1,enumerable:!1,configurable:!1},Xw="0.0.0-dev",Qw=(i,e)=>{if(i.test(Xw))console.warn(e);else throw new Error(e)},Zw=`CID.isCID(v) is deprecated and will be removed in the next major release. +var _y=Object.create;var Jo=Object.defineProperty;var xy=Object.getOwnPropertyDescriptor;var Ey=Object.getOwnPropertyNames;var Sy=Object.getPrototypeOf,Iy=Object.prototype.hasOwnProperty;var al=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var My=(r,e)=>()=>(r&&(e=r(r=0)),e);var Z=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Dt=(r,e)=>{for(var t in e)Jo(r,t,{get:e[t],enumerable:!0})},Wo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ey(e))!Iy.call(r,n)&&n!==t&&Jo(r,n,{get:()=>e[n],enumerable:!(i=xy(e,n))||i.enumerable});return r},qt=(r,e,t)=>(Wo(r,e,"default"),t&&Wo(t,e,"default")),qe=(r,e,t)=>(t=r!=null?_y(Sy(r)):{},Wo(e||!r||!r.__esModule?Jo(t,"default",{value:r,enumerable:!0}):t,r)),qs=r=>Wo(Jo({},"__esModule",{value:!0}),r);var hn=Z((BS,uc)=>{"use strict";var qn=typeof Reflect=="object"?Reflect:null,fl=qn&&typeof qn.apply=="function"?qn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Yo;qn&&typeof qn.ownKeys=="function"?Yo=qn.ownKeys:Object.getOwnPropertySymbols?Yo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yo=function(e){return Object.getOwnPropertyNames(e)};function Ay(r){console&&console.warn&&console.warn(r)}var hl=Number.isNaN||function(e){return e!==e};function Ke(){Ke.init.call(this)}uc.exports=Ke;uc.exports.once=Py;Ke.EventEmitter=Ke;Ke.prototype._events=void 0;Ke.prototype._eventsCount=0;Ke.prototype._maxListeners=void 0;var cl=10;function Xo(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ke,"defaultMaxListeners",{enumerable:!0,get:function(){return cl},set:function(r){if(typeof r!="number"||r<0||hl(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");cl=r}});Ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ke.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||hl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ul(r){return r._maxListeners===void 0?Ke.defaultMaxListeners:r._maxListeners}Ke.prototype.getMaxListeners=function(){return ul(this)};Ke.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var d=s[e];if(d===void 0)return!1;if(typeof d=="function")fl(d,this,t);else for(var h=d.length,b=bl(d,h),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,Ay(f)}return r}Ke.prototype.addListener=function(e,t){return dl(this,e,t,!1)};Ke.prototype.on=Ke.prototype.addListener;Ke.prototype.prependListener=function(e,t){return dl(this,e,t,!0)};function Ry(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ll(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=Ry.bind(i);return n.listener=t,i.wrapFn=n,n}Ke.prototype.once=function(e,t){return Xo(t),this.on(e,ll(this,e,t)),this};Ke.prototype.prependOnceListener=function(e,t){return Xo(t),this.prependListener(e,ll(this,e,t)),this};Ke.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Xo(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Ty(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ke.prototype.off=Ke.prototype.removeListener;Ke.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function pl(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?Dy(n):bl(n,n.length)}Ke.prototype.listeners=function(e){return pl(this,e,!0)};Ke.prototype.rawListeners=function(e){return pl(this,e,!1)};Ke.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):gl.call(r,e)};Ke.prototype.listenerCount=gl;function gl(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ke.prototype.eventNames=function(){return this._eventsCount>0?Yo(this._events):[]};function bl(r,e){for(var t=new Array(e),i=0;ilc,__asyncDelegator:()=>$y,__asyncGenerator:()=>Vy,__asyncValues:()=>Hy,__await:()=>Us,__awaiter:()=>Uy,__classPrivateFieldGet:()=>Yy,__classPrivateFieldSet:()=>Xy,__createBinding:()=>By,__decorate:()=>Ly,__exportStar:()=>ky,__extends:()=>Cy,__generator:()=>zy,__importDefault:()=>Jy,__importStar:()=>Wy,__makeTemplateObject:()=>Gy,__metadata:()=>qy,__param:()=>Fy,__read:()=>ml,__rest:()=>Oy,__spread:()=>Ky,__spreadArrays:()=>jy,__values:()=>pc});function Cy(r,e){dc(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Fy(r,e){return function(t,i){e(t,i,r)}}function qy(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Uy(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{h(i.next(b))}catch(y){o(y)}}function d(b){try{h(i.throw(b))}catch(y){o(y)}}function h(b){b.done?s(b.value):n(b.value).then(f,d)}h((i=i.apply(r,e||[])).next())})}function zy(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(b){return d([h,b])}}function d(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ml(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Ky(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{d(i[S](I))}catch(M){y(s[0][3],M)}}function d(S){S.value instanceof Us?Promise.resolve(S.value.v).then(h,b):y(s[0][2],S)}function h(S){f("next",S)}function b(S){f("throw",S)}function y(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function $y(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Us(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function Hy(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof pc=="function"?pc(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,d){o=r[s](o),n(f,d,o.done,o.value)})}}function n(s,o,f,d){Promise.resolve(d).then(function(h){s({value:h,done:f})},o)}}function Gy(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wy(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function Jy(r){return r&&r.__esModule?r:{default:r}}function Yy(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Xy(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var dc,lc,zn=My(()=>{dc=function(r,e){return dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},dc(r,e)};lc=function(){return lc=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.delay=void 0;function Zy(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Zo.delay=Zy});var wl=Z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.ONE_THOUSAND=Bn.ONE_HUNDRED=void 0;Bn.ONE_HUNDRED=100;Bn.ONE_THOUSAND=1e3});var _l=Z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.ONE_YEAR=Q.FOUR_WEEKS=Q.THREE_WEEKS=Q.TWO_WEEKS=Q.ONE_WEEK=Q.THIRTY_DAYS=Q.SEVEN_DAYS=Q.FIVE_DAYS=Q.THREE_DAYS=Q.ONE_DAY=Q.TWENTY_FOUR_HOURS=Q.TWELVE_HOURS=Q.SIX_HOURS=Q.THREE_HOURS=Q.ONE_HOUR=Q.SIXTY_MINUTES=Q.THIRTY_MINUTES=Q.TEN_MINUTES=Q.FIVE_MINUTES=Q.ONE_MINUTE=Q.SIXTY_SECONDS=Q.THIRTY_SECONDS=Q.TEN_SECONDS=Q.FIVE_SECONDS=Q.ONE_SECOND=void 0;Q.ONE_SECOND=1;Q.FIVE_SECONDS=5;Q.TEN_SECONDS=10;Q.THIRTY_SECONDS=30;Q.SIXTY_SECONDS=60;Q.ONE_MINUTE=Q.SIXTY_SECONDS;Q.FIVE_MINUTES=Q.ONE_MINUTE*5;Q.TEN_MINUTES=Q.ONE_MINUTE*10;Q.THIRTY_MINUTES=Q.ONE_MINUTE*30;Q.SIXTY_MINUTES=Q.ONE_MINUTE*60;Q.ONE_HOUR=Q.SIXTY_MINUTES;Q.THREE_HOURS=Q.ONE_HOUR*3;Q.SIX_HOURS=Q.ONE_HOUR*6;Q.TWELVE_HOURS=Q.ONE_HOUR*12;Q.TWENTY_FOUR_HOURS=Q.ONE_HOUR*24;Q.ONE_DAY=Q.TWENTY_FOUR_HOURS;Q.THREE_DAYS=Q.ONE_DAY*3;Q.FIVE_DAYS=Q.ONE_DAY*5;Q.SEVEN_DAYS=Q.ONE_DAY*7;Q.THIRTY_DAYS=Q.ONE_DAY*30;Q.ONE_WEEK=Q.SEVEN_DAYS;Q.TWO_WEEKS=Q.ONE_WEEK*2;Q.THREE_WEEKS=Q.ONE_WEEK*3;Q.FOUR_WEEKS=Q.ONE_WEEK*4;Q.ONE_YEAR=Q.ONE_DAY*365});var gc=Z(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});var xl=(zn(),qs(Un));xl.__exportStar(wl(),Qo);xl.__exportStar(_l(),Qo)});var Sl=Z(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.fromMiliseconds=kn.toMiliseconds=void 0;var El=gc();function Qy(r){return r*El.ONE_THOUSAND}kn.toMiliseconds=Qy;function e2(r){return Math.floor(r/El.ONE_THOUSAND)}kn.fromMiliseconds=e2});var Ml=Z(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var Il=(zn(),qs(Un));Il.__exportStar(yl(),ea);Il.__exportStar(Sl(),ea)});var Al=Z(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.Watch=void 0;var ta=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};zs.Watch=ta;zs.default=ta});var Rl=Z(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.IWatch=void 0;var bc=class{};ra.IWatch=bc});var Tl=Z(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var t2=(zn(),qs(Un));t2.__exportStar(Rl(),vc)});var jn=Z(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var ia=(zn(),qs(Un));ia.__exportStar(Ml(),Kn);ia.__exportStar(Al(),Kn);ia.__exportStar(Tl(),Kn);ia.__exportStar(gc(),Kn)});var $l=Z((lI,Vl)=>{"use strict";function E2(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}Vl.exports=S2;function S2(r,e,t){var i=t&&t.stringify||E2,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=d||e[b]==null)break;y=d||e[b]==null)break;y=d||e[b]===void 0)break;y",y=I+2,I++;break}h+=i(e[b]),y=I+2,I++;break;case 115:if(b>=d)break;y{"use strict";var Hl=$l();Jl.exports=qr;var Vs=O2().console||{},I2={mapHttpRequest:fa,mapHttpResponse:fa,wrapRequestSerializer:Mc,wrapResponseSerializer:Mc,wrapErrorSerializer:Mc,req:fa,res:fa,err:D2};function M2(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function qr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||Vs;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=M2(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",d=Object.create(t);d.log||(d.log=$s),Object.defineProperty(d,"levelVal",{get:b}),Object.defineProperty(d,"level",{get:y,set:S});let h={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:P2(r)};d.levels=qr.levels,d.level=f,d.setMaxListeners=d.getMaxListeners=d.emit=d.addListener=d.on=d.prependListener=d.once=d.prependOnceListener=d.removeListener=d.removeAllListeners=d.listeners=d.listenerCount=d.eventNames=d.write=d.flush=$s,d.serializers=i,d._serialize=n,d._stdErrSerialize=s,d.child=I,e&&(d._logEvent=Ac());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,Vn(h,d,"error","log"),Vn(h,d,"fatal","error"),Vn(h,d,"warn","error"),Vn(h,d,"info","log"),Vn(h,d,"debug","log"),Vn(h,d,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let C=T.serializers;if(n&&C){var P=Object.assign({},i,C),U=r.browser.serialize===!0?Object.keys(P):n;delete M.serializers,ca([M],U,P,this._stdErrSerialize)}function B(z){this._childLevel=(z._childLevel|0)+1,this.error=$n(z,M,"error"),this.fatal=$n(z,M,"fatal"),this.warn=$n(z,M,"warn"),this.info=$n(z,M,"info"),this.debug=$n(z,M,"debug"),this.trace=$n(z,M,"trace"),P&&(this.serializers=P,this._serialize=U),e&&(this._logEvent=Ac([].concat(z._logEvent.bindings,M)))}return B.prototype=this,new B(this)}return d}qr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};qr.stdSerializers=I2;qr.stdTimeFunctions=Object.assign({},{nullTime:Gl,epochTime:Wl,unixTime:N2,isoTime:C2});function Vn(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?$s:n[t]?n[t]:Vs[t]||Vs[i]||$s,A2(r,e,t)}function A2(r,e,t){!r.transmit&&e[t]===$s||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Vs?Vs:this;for(var d=0;d-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function $n(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.BrowserRandomSource=void 0;var e0=65536,Cc=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function H2(r){for(var e=0;e{});var r0=Z(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.NodeRandomSource=void 0;var G2=Jt(),Fc=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof al<"u"){let e=Lc();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.SystemRandomSource=void 0;var W2=t0(),J2=r0(),qc=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new W2.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new J2.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Ta.SystemRandomSource=qc});var n0=Z(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Y2(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Ut.mul=Math.imul||Y2;function X2(r,e){return r+e|0}Ut.add=X2;function Z2(r,e){return r-e|0}Ut.sub=Z2;function Q2(r,e){return r<>>32-e}Ut.rotl=Q2;function e3(r,e){return r<<32-e|r>>>e}Ut.rotr=e3;function t3(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Ut.isInteger=Number.isInteger||t3;Ut.MAX_SAFE_INTEGER=9007199254740991;Ut.isSafeInteger=function(r){return Ut.isInteger(r)&&r>=-Ut.MAX_SAFE_INTEGER&&r<=Ut.MAX_SAFE_INTEGER}});var Hn=Z(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var s0=n0();function r3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Le.readInt16BE=r3;function i3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Le.readUint16BE=i3;function n3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Le.readInt16LE=n3;function s3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Le.readUint16LE=s3;function o0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Le.writeUint16BE=o0;Le.writeInt16BE=o0;function a0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Le.writeUint16LE=a0;Le.writeInt16LE=a0;function Uc(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Le.readInt32BE=Uc;function zc(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Le.readUint32BE=zc;function Bc(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Le.readInt32LE=Bc;function kc(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Le.readUint32LE=kc;function Da(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Le.writeUint32BE=Da;Le.writeInt32BE=Da;function Pa(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Le.writeUint32LE=Pa;Le.writeInt32LE=Pa;function o3(r,e){e===void 0&&(e=0);var t=Uc(r,e),i=Uc(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Le.readInt64BE=o3;function a3(r,e){e===void 0&&(e=0);var t=zc(r,e),i=zc(r,e+4);return t*4294967296+i}Le.readUint64BE=a3;function f3(r,e){e===void 0&&(e=0);var t=Bc(r,e),i=Bc(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Le.readInt64LE=f3;function c3(r,e){e===void 0&&(e=0);var t=kc(r,e),i=kc(r,e+4);return i*4294967296+t}Le.readUint64LE=c3;function f0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Da(r/4294967296>>>0,e,t),Da(r>>>0,e,t+4),e}Le.writeUint64BE=f0;Le.writeInt64BE=f0;function c0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Pa(r>>>0,e,t),Pa(r/4294967296>>>0,e,t+4),e}Le.writeUint64LE=c0;Le.writeInt64LE=c0;function h3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Le.readUintBE=h3;function u3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Le.writeUintBE=d3;function l3(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!s0.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.randomStringForEntropy=wt.randomString=wt.randomUint32=wt.randomBytes=wt.defaultRandomSource=void 0;var x3=i0(),E3=Hn(),h0=Jt();wt.defaultRandomSource=new x3.SystemRandomSource;function Kc(r,e=wt.defaultRandomSource){return e.randomBytes(r)}wt.randomBytes=Kc;function S3(r=wt.defaultRandomSource){let e=Kc(4,r),t=(0,E3.readUint32LE)(e);return(0,h0.wipe)(e),t}wt.randomUint32=S3;var u0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function d0(r,e=u0,t=wt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Kc(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let d=o[f];d{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});var Wn=Hn(),Gn=Jt();fi.DIGEST_LENGTH=64;fi.BLOCK_SIZE=128;var p0=function(){function r(){this.digestLength=fi.DIGEST_LENGTH,this.blockSize=fi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Gn.wipe(this._buffer),Gn.wipe(this._tempHi),Gn.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Gn.wipe(e.stateHi),Gn.wipe(e.stateLo),e.buffer&&Gn.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();fi.SHA512=p0;var l0=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function jc(r,e,t,i,n,s,o){for(var f=t[0],d=t[1],h=t[2],b=t[3],y=t[4],S=t[5],I=t[6],M=t[7],T=i[0],C=i[1],P=i[2],U=i[3],B=i[4],z=i[5],j=i[6],H=i[7],L,O,W,D,l,w,p,a;o>=128;){for(var u=0;u<16;u++){var v=8*u+s;r[u]=Wn.readUint32BE(n,v),e[u]=Wn.readUint32BE(n,v+4)}for(var u=0;u<80;u++){var _=f,m=d,c=h,x=b,A=y,g=S,R=I,k=M,E=T,N=C,F=P,q=U,K=B,J=z,$=j,V=H;if(L=M,O=H,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=(y>>>14|B<<18)^(y>>>18|B<<14)^(B>>>9|y<<23),O=(B>>>14|y<<18)^(B>>>18|y<<14)^(y>>>9|B<<23),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=y&S^~y&I,O=B&z^~B&j,l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=l0[u*2],O=l0[u*2+1],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=r[u%16],O=e[u%16],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,W=p&65535|a<<16,D=l&65535|w<<16,L=W,O=D,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),O=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=f&d^f&h^d&h,O=T&C^T&P^C&P,l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,k=p&65535|a<<16,V=l&65535|w<<16,L=x,O=q,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=W,O=D,l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,q=l&65535|w<<16,d=_,h=m,b=c,y=x,S=A,I=g,M=R,f=k,C=E,P=N,U=F,B=q,z=K,j=J,H=$,T=V,u%16===15)for(var v=0;v<16;v++)L=r[v],O=e[v],l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=r[(v+9)%16],O=e[(v+9)%16],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,W=r[(v+1)%16],D=e[(v+1)%16],L=(W>>>1|D<<31)^(W>>>8|D<<24)^W>>>7,O=(D>>>1|W<<31)^(D>>>8|W<<24)^(D>>>7|W<<25),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,W=r[(v+14)%16],D=e[(v+14)%16],L=(W>>>19|D<<13)^(D>>>29|W<<3)^W>>>6,O=(D>>>19|W<<13)^(W>>>29|D<<3)^(D>>>6|W<<26),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[v]=p&65535|a<<16,e[v]=l&65535|w<<16}L=f,O=T,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[0],O=i[0],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=d,O=C,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[1],O=i[1],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=d=p&65535|a<<16,i[1]=C=l&65535|w<<16,L=h,O=P,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[2],O=i[2],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=h=p&65535|a<<16,i[2]=P=l&65535|w<<16,L=b,O=U,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[3],O=i[3],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=U=l&65535|w<<16,L=y,O=B,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[4],O=i[4],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=y=p&65535|a<<16,i[4]=B=l&65535|w<<16,L=S,O=z,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[5],O=i[5],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=z=l&65535|w<<16,L=I,O=j,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[6],O=i[6],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=j=l&65535|w<<16,L=M,O=H,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[7],O=i[7],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=H=l&65535|w<<16,s+=128,o-=128}return s}function M3(r){var e=new p0;e.update(r);var t=e.digest();return e.clean(),t}fi.hash=M3});var T0=Z(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var A3=Js(),Ys=g0(),w0=Jt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function te(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,_0(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function x0(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function m0(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Xs(t,r),Xs(i,e),x0(t,i)}function E0(r){let e=new Uint8Array(32);return Xs(e,r),e[0]&1}function N3(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ln(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function gn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function je(r,e,t){let i,n,s=0,o=0,f=0,d=0,h=0,b=0,y=0,S=0,I=0,M=0,T=0,C=0,P=0,U=0,B=0,z=0,j=0,H=0,L=0,O=0,W=0,D=0,l=0,w=0,p=0,a=0,u=0,v=0,_=0,m=0,c=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,d+=i*R,h+=i*k,b+=i*E,y+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,C+=i*$,P+=i*V,U+=i*ee,B+=i*G,z+=i*Y,i=e[1],o+=i*x,f+=i*A,d+=i*g,h+=i*R,b+=i*k,y+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,C+=i*J,P+=i*$,U+=i*V,B+=i*ee,z+=i*G,j+=i*Y,i=e[2],f+=i*x,d+=i*A,h+=i*g,b+=i*R,y+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,C+=i*K,P+=i*J,U+=i*$,B+=i*V,z+=i*ee,j+=i*G,H+=i*Y,i=e[3],d+=i*x,h+=i*A,b+=i*g,y+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,C+=i*q,P+=i*K,U+=i*J,B+=i*$,z+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],h+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,C+=i*F,P+=i*q,U+=i*K,B+=i*J,z+=i*$,j+=i*V,H+=i*ee,L+=i*G,O+=i*Y,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,C+=i*N,P+=i*F,U+=i*q,B+=i*K,z+=i*J,j+=i*$,H+=i*V,L+=i*ee,O+=i*G,W+=i*Y,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,C+=i*E,P+=i*N,U+=i*F,B+=i*q,z+=i*K,j+=i*J,H+=i*$,L+=i*V,O+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,C+=i*k,P+=i*E,U+=i*N,B+=i*F,z+=i*q,j+=i*K,H+=i*J,L+=i*$,O+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,C+=i*R,P+=i*k,U+=i*E,B+=i*N,z+=i*F,j+=i*q,H+=i*K,L+=i*J,O+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,C+=i*g,P+=i*R,U+=i*k,B+=i*E,z+=i*N,j+=i*F,H+=i*q,L+=i*K,O+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,C+=i*A,P+=i*g,U+=i*R,B+=i*k,z+=i*E,j+=i*N,H+=i*F,L+=i*q,O+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],C+=i*x,P+=i*A,U+=i*g,B+=i*R,z+=i*k,j+=i*E,H+=i*N,L+=i*F,O+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,u+=i*Y,i=e[12],P+=i*x,U+=i*A,B+=i*g,z+=i*R,j+=i*k,H+=i*E,L+=i*N,O+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,u+=i*G,v+=i*Y,i=e[13],U+=i*x,B+=i*A,z+=i*g,j+=i*R,H+=i*k,L+=i*E,O+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,u+=i*ee,v+=i*G,_+=i*Y,i=e[14],B+=i*x,z+=i*A,j+=i*g,H+=i*R,L+=i*k,O+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,u+=i*V,v+=i*ee,_+=i*G,m+=i*Y,i=e[15],z+=i*x,j+=i*A,H+=i*g,L+=i*R,O+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,u+=i*$,v+=i*V,_+=i*ee,m+=i*G,c+=i*Y,s+=38*j,o+=38*H,f+=38*L,d+=38*O,h+=38*W,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*u,C+=38*v,P+=38*_,U+=38*m,B+=38*c,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=d,r[4]=h,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=C,r[12]=P,r[13]=U,r[14]=B,r[15]=z}function pn(r,e){je(r,e,e)}function S0(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)pn(t,t),i!==2&&i!==4&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function C3(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)pn(t,t),i!==1&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Gc(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),d=te(),h=te(),b=te();gn(t,r[1],r[0]),gn(b,e[1],e[0]),je(t,t,b),ln(i,r[0],r[1]),ln(b,e[0],e[1]),je(i,i,b),je(n,r[3],e[3]),je(n,n,D3),je(s,r[2],e[2]),ln(s,s,s),gn(o,i,t),gn(f,s,n),ln(d,s,n),ln(h,i,t),je(r[0],o,f),je(r[1],h,d),je(r[2],d,f),je(r[3],o,h)}function y0(r,e,t){for(let i=0;i<4;i++)_0(r[i],e[i],t)}function Jc(r,e){let t=te(),i=te(),n=te();S0(n,e[2]),je(t,e[0],n),je(i,e[1],n),Xs(r,i),r[31]^=E0(t)<<7}function I0(r,e,t){Ai(r[0],Hc),Ai(r[1],Jn),Ai(r[2],Jn),Ai(r[3],Hc);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;y0(r,e,n),Gc(e,r),Gc(r,r),y0(r,e,n)}}function Yc(r,e){let t=[te(),te(),te(),te()];Ai(t[0],b0),Ai(t[1],v0),Ai(t[2],Jn),je(t[3],b0,v0),I0(r,t,e)}function M0(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ys.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[te(),te(),te(),te()];Yc(i,e),Jc(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=M0;function O3(r){let e=(0,A3.randomBytes)(32,r),t=M0(e);return(0,w0.wipe)(e),t}ze.generateKeyPair=O3;function L3(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=L3;var $c=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function A0(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*$c[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*$c[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Wc(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;A0(r,e)}function F3(r,e){let t=new Float64Array(64),i=[te(),te(),te(),te()],n=(0,Ys.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ys.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Wc(f),Yc(i,f),Jc(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let d=o.digest();Wc(d);for(let h=0;h<32;h++)t[h]=f[h];for(let h=0;h<32;h++)for(let b=0;b<32;b++)t[h+b]+=d[h]*n[b];return A0(s.subarray(32),t),s}ze.sign=F3;function R0(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),d=te();return Ai(r[2],Jn),N3(r[1],e),pn(n,r[1]),je(s,n,T3),gn(n,n,r[2]),ln(s,r[2],s),pn(o,s),pn(f,o),je(d,f,o),je(t,d,n),je(t,t,s),C3(t,t),je(t,t,n),je(t,t,s),je(t,t,s),je(r[0],t,s),pn(i,r[0]),je(i,i,s),m0(i,n)&&je(r[0],r[0],P3),pn(i,r[0]),je(i,i,s),m0(i,n)?-1:(E0(r[0])===e[31]>>7&&gn(r[0],Hc,r[0]),je(r[3],r[0],r[1]),0)}function q3(r,e,t){let i=new Uint8Array(32),n=[te(),te(),te(),te()],s=[te(),te(),te(),te()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(R0(s,r))return!1;let o=new Ys.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Wc(f),I0(n,s,f),Yc(s,t.subarray(32)),Gc(n,s),Jc(i,n),!x0(t,i)}ze.verify=q3;function U3(r){let e=[te(),te(),te(),te()];if(R0(e,r))throw new Error("Ed25519: invalid public key");let t=te(),i=te(),n=e[1];ln(t,Jn,n),gn(i,Jn,n),S0(i,i),je(t,t,i);let s=new Uint8Array(32);return Xs(s,t),s}ze.convertPublicKeyToX25519=U3;function z3(r){let e=(0,Ys.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,w0.wipe)(e),t}ze.convertSecretKeyToX25519=z3});var za=Z(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.getLocalStorage=He.getLocalStorageOrThrow=He.getCrypto=He.getCryptoOrThrow=He.getLocation=He.getLocationOrThrow=He.getNavigator=He.getNavigatorOrThrow=He.getDocument=He.getDocumentOrThrow=He.getFromWindowOrThrow=He.getFromWindow=void 0;function mn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}He.getFromWindow=mn;function rs(r){let e=mn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}He.getFromWindowOrThrow=rs;function dw(){return rs("document")}He.getDocumentOrThrow=dw;function lw(){return mn("document")}He.getDocument=lw;function pw(){return rs("navigator")}He.getNavigatorOrThrow=pw;function gw(){return mn("navigator")}He.getNavigator=gw;function bw(){return rs("location")}He.getLocationOrThrow=bw;function vw(){return mn("location")}He.getLocation=vw;function mw(){return rs("crypto")}He.getCryptoOrThrow=mw;function yw(){return mn("crypto")}He.getCrypto=yw;function ww(){return rs("localStorage")}He.getLocalStorageOrThrow=ww;function _w(){return mn("localStorage")}He.getLocalStorage=_w});var gp=Z(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.getWindowMetadata=void 0;var pp=za();function xw(){let r,e;try{r=pp.getDocumentOrThrow(),e=pp.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let C=M.getAttribute("href");if(C)if(C.toLowerCase().indexOf("https:")===-1&&C.toLowerCase().indexOf("http:")===-1&&C.indexOf("//")!==0){let P=e.protocol+"//"+e.host;if(C.indexOf("/")===0)P+=C;else{let U=e.pathname.split("/");U.pop();let B=U.join("/");P+=B+"/"+C}S.push(P)}else if(C.indexOf("//")===0){let P=e.protocol+C;S.push(P)}else S.push(C)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(C)).filter(C=>C?y.includes(C):!1);if(T.length&&T){let C=M.getAttribute("content");if(C)return C}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),d=e.origin,h=t();return{description:f,url:d,icons:h,name:o}}Ba.getWindowMetadata=xw});var vp=Z((zM,bp)=>{"use strict";bp.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var xp=Z((BM,_p)=>{"use strict";var wp="%[a-f0-9]{2}",mp=new RegExp("("+wp+")|([^%]+?)","gi"),yp=new RegExp("("+wp+")+","gi");function xh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],xh(t),xh(i))}function Ew(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(mp)||[],t=1;t{"use strict";Ep.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Mp=Z((KM,Ip)=>{"use strict";Ip.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Iw=vp(),Mw=xp(),Rp=Sp(),Aw=Mp(),Rw=r=>r==null,Eh=Symbol("encodeFragmentIdentifier");function Tw(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[",n,"]"].join("")]:[...t,[it(e,r),"[",it(n,r),"]=",it(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[]"].join("")]:[...t,[it(e,r),"[]=",it(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),":list="].join("")]:[...t,[it(e,r),":list=",it(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[it(t,r),e,it(n,r)].join("")]:[[i,it(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,it(e,r)]:[...t,[it(e,r),"=",it(i,r)].join("")]}}function Dw(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&hi(i,r).includes(r.arrayFormatSeparator);i=o?hi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(d=>hi(d,r)):i===null?i:hi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&hi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>hi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Tp(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function it(r,e){return e.encode?e.strict?Iw(r):encodeURIComponent(r):r}function hi(r,e){return e.decode?Mw(r):r}function Dp(r){return Array.isArray(r)?r.sort():typeof r=="object"?Dp(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Pp(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Pw(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Np(r){r=Pp(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ap(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Cp(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Tp(e.arrayFormatSeparator);let t=Dw(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Rp(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:hi(o,e),t(hi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ap(s[o],e);else i[n]=Ap(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Dp(o):n[s]=o,n},Object.create(null))}Ct.extract=Np;Ct.parse=Cp;Ct.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Tp(e.arrayFormatSeparator);let t=o=>e.skipNull&&Rw(r[o])||e.skipEmptyString&&r[o]==="",i=Tw(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?it(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?it(o,e)+"[]":f.reduce(i(o),[]).join("&"):it(o,e)+"="+it(f,e)}).filter(o=>o.length>0).join("&")};Ct.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Rp(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Cp(Np(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:hi(i,e)}:{})};Ct.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Eh]:!0},e);let t=Pp(r.url).split("?")[0]||"",i=Ct.extract(r.url),n=Ct.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ct.stringify(s,e);o&&(o=`?${o}`);let f=Pw(r.url);return r.fragmentIdentifier&&(f=`#${e[Eh]?it(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ct.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Eh]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ct.parseUrl(r,t);return Ct.stringifyUrl({url:i,query:Aw(n,e),fragmentIdentifier:s},t)};Ct.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ct.pick(r,i,t)}});var Lp=Z((VM,ka)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=window:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ka=="object"&&ka.exports,f=typeof define=="function"&&define.amd,d=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],C=[224,256,384,512],P=[128,256],U=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),d&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var z=function(E,N,F){return function(q){return new g(E,N,E).update(q)[F]()}},j=function(E,N,F){return function(q,K){return new g(E,N,K).update(q)[F]()}},H=function(E,N,F){return function(q,K,J,$){return a["cshake"+E].update(q,K,J,$)[F]()}},L=function(E,N,F){return function(q,K,J,$){return a["kmac"+E].update(q,K,J,$)[F]()}},O=function(E,N,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(d&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!d||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}for(var q=this.blocks,K=this.byteCount,J=E.length,$=this.blockCount,V=0,ee=this.s,G,Y;V>2]|=E[V]<>2]|=Y<>2]|=(192|Y>>6)<>2]|=(128|Y&63)<=57344?(q[G>>2]|=(224|Y>>12)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<>2]|=(240|Y>>18)<>2]|=(128|Y>>12&63)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<=K){for(this.start=G-K,this.block=q[$],G=0;G<$;++G)ee[G]^=q[G];k(ee),this.reset=!0}else this.start=G}return this},g.prototype.encode=function(E,N){var F=E&255,q=1,K=[F];for(E=E>>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return N?K.push(q):K.unshift(q),this.update(K),K.length},g.prototype.encodeString=function(E){var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(d&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!d||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}var q=0,K=E.length;if(N)q=K;else for(var J=0;J=57344?q+=3:($=65536+(($&1023)<<10|E.charCodeAt(++J)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},g.prototype.bytepad=function(E,N){for(var F=this.encode(N),q=0;q>2]|=this.padding[N&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],N=1;N>4&15]+h[V&15]+h[V>>12&15]+h[V>>8&15]+h[V>>20&15]+h[V>>16&15]+h[V>>28&15]+h[V>>24&15];J%E===0&&(k(N),K=0)}return q&&(V=N[K],$+=h[V>>4&15]+h[V&15],q>1&&($+=h[V>>12&15]+h[V>>8&15]),q>2&&($+=h[V>>20&15]+h[V>>16&15])),$},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,N=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,J=0,$=this.outputBits>>3,V;q?V=new ArrayBuffer(F+1<<2):V=new ArrayBuffer($);for(var ee=new Uint32Array(V);J>8&255,$[V+2]=ee>>16&255,$[V+3]=ee>>24&255;J%E===0&&k(N)}return q&&(V=J<<2,ee=N[K],$[V]=ee&255,q>1&&($[V+1]=ee>>8&255),q>2&&($[V+2]=ee>>16&255)),$};function R(E,N,F){g.call(this,E,N,F)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var k=function(E){var N,F,q,K,J,$,V,ee,G,Y,_r,ie,ne,xr,se,oe,Er,ae,fe,Sr,ce,he,Ir,ue,de,Mr,le,pe,Ar,ge,be,Rr,ve,me,Tr,ye,we,Dr,_e,xe,Pr,Ee,Se,Nr,Ie,Me,Cr,Ae,Re,Or,Te,De,Lr,Pe,Ne,nr,Be,ke,jt,Vt,$t,Ht,Gt;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],J=E[1]^E[11]^E[21]^E[31]^E[41],$=E[2]^E[12]^E[22]^E[32]^E[42],V=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],Y=E[6]^E[16]^E[26]^E[36]^E[46],_r=E[7]^E[17]^E[27]^E[37]^E[47],ie=E[8]^E[18]^E[28]^E[38]^E[48],ne=E[9]^E[19]^E[29]^E[39]^E[49],N=ie^($<<1|V>>>31),F=ne^(V<<1|$>>>31),E[0]^=N,E[1]^=F,E[10]^=N,E[11]^=F,E[20]^=N,E[21]^=F,E[30]^=N,E[31]^=F,E[40]^=N,E[41]^=F,N=K^(ee<<1|G>>>31),F=J^(G<<1|ee>>>31),E[2]^=N,E[3]^=F,E[12]^=N,E[13]^=F,E[22]^=N,E[23]^=F,E[32]^=N,E[33]^=F,E[42]^=N,E[43]^=F,N=$^(Y<<1|_r>>>31),F=V^(_r<<1|Y>>>31),E[4]^=N,E[5]^=F,E[14]^=N,E[15]^=F,E[24]^=N,E[25]^=F,E[34]^=N,E[35]^=F,E[44]^=N,E[45]^=F,N=ee^(ie<<1|ne>>>31),F=G^(ne<<1|ie>>>31),E[6]^=N,E[7]^=F,E[16]^=N,E[17]^=F,E[26]^=N,E[27]^=F,E[36]^=N,E[37]^=F,E[46]^=N,E[47]^=F,N=Y^(K<<1|J>>>31),F=_r^(J<<1|K>>>31),E[8]^=N,E[9]^=F,E[18]^=N,E[19]^=F,E[28]^=N,E[29]^=F,E[38]^=N,E[39]^=F,E[48]^=N,E[49]^=F,xr=E[0],se=E[1],Me=E[11]<<4|E[10]>>>28,Cr=E[10]<<4|E[11]>>>28,pe=E[20]<<3|E[21]>>>29,Ar=E[21]<<3|E[20]>>>29,Vt=E[31]<<9|E[30]>>>23,$t=E[30]<<9|E[31]>>>23,Ee=E[40]<<18|E[41]>>>14,Se=E[41]<<18|E[40]>>>14,me=E[2]<<1|E[3]>>>31,Tr=E[3]<<1|E[2]>>>31,oe=E[13]<<12|E[12]>>>20,Er=E[12]<<12|E[13]>>>20,Ae=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,ge=E[33]<<13|E[32]>>>19,be=E[32]<<13|E[33]>>>19,Ht=E[42]<<2|E[43]>>>30,Gt=E[43]<<2|E[42]>>>30,Pe=E[5]<<30|E[4]>>>2,Ne=E[4]<<30|E[5]>>>2,ye=E[14]<<6|E[15]>>>26,we=E[15]<<6|E[14]>>>26,ae=E[25]<<11|E[24]>>>21,fe=E[24]<<11|E[25]>>>21,Or=E[34]<<15|E[35]>>>17,Te=E[35]<<15|E[34]>>>17,Rr=E[45]<<29|E[44]>>>3,ve=E[44]<<29|E[45]>>>3,ue=E[6]<<28|E[7]>>>4,de=E[7]<<28|E[6]>>>4,nr=E[17]<<23|E[16]>>>9,Be=E[16]<<23|E[17]>>>9,Dr=E[26]<<25|E[27]>>>7,_e=E[27]<<25|E[26]>>>7,Sr=E[36]<<21|E[37]>>>11,ce=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Lr=E[46]<<24|E[47]>>>8,Nr=E[8]<<27|E[9]>>>5,Ie=E[9]<<27|E[8]>>>5,Mr=E[18]<<20|E[19]>>>12,le=E[19]<<20|E[18]>>>12,ke=E[29]<<7|E[28]>>>25,jt=E[28]<<7|E[29]>>>25,xe=E[38]<<8|E[39]>>>24,Pr=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Ir=E[49]<<14|E[48]>>>18,E[0]=xr^~oe&ae,E[1]=se^~Er&fe,E[10]=ue^~Mr&pe,E[11]=de^~le&Ar,E[20]=me^~ye&Dr,E[21]=Tr^~we&_e,E[30]=Nr^~Me&Ae,E[31]=Ie^~Cr&Re,E[40]=Pe^~nr&ke,E[41]=Ne^~Be&jt,E[2]=oe^~ae&Sr,E[3]=Er^~fe&ce,E[12]=Mr^~pe&ge,E[13]=le^~Ar&be,E[22]=ye^~Dr&xe,E[23]=we^~_e&Pr,E[32]=Me^~Ae&Or,E[33]=Cr^~Re&Te,E[42]=nr^~ke&Vt,E[43]=Be^~jt&$t,E[4]=ae^~Sr&he,E[5]=fe^~ce&Ir,E[14]=pe^~ge&Rr,E[15]=Ar^~be&ve,E[24]=Dr^~xe&Ee,E[25]=_e^~Pr&Se,E[34]=Ae^~Or&De,E[35]=Re^~Te&Lr,E[44]=ke^~Vt&Ht,E[45]=jt^~$t&Gt,E[6]=Sr^~he&xr,E[7]=ce^~Ir&se,E[16]=ge^~Rr&ue,E[17]=be^~ve&de,E[26]=xe^~Ee&me,E[27]=Pr^~Se&Tr,E[36]=Or^~De&Nr,E[37]=Te^~Lr&Ie,E[46]=Vt^~Ht&Pe,E[47]=$t^~Gt&Ne,E[8]=he^~xr&oe,E[9]=Ir^~se&Er,E[18]=Rr^~ue&Mr,E[19]=ve^~de&le,E[28]=Ee^~me&ye,E[29]=Se^~Tr&we,E[38]=De^~Nr&Me,E[39]=Lr^~Ie&Cr,E[48]=Ht^~Pe&nr,E[49]=Gt^~Ne&Be,E[0]^=T[q],E[1]^=T[q+1]};if(o)ka.exports=a;else{for(v=0;v{});var Ph=Z((Gp,Dh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var u=function(){};u.prototype=a.prototype,p.prototype=new u,p.prototype.constructor=p}function n(p,a,u){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(u=a,a=10),this._init(p||0,a||10,u||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,u){return a.cmp(u)>0?a:u},n.min=function(a,u){return a.cmp(u)<0?a:u},n.prototype._init=function(a,u,v){if(typeof a=="number")return this._initNumber(a,u,v);if(typeof a=="object")return this._initArray(a,u,v);u==="hex"&&(u=16),t(u===(u|0)&&u>=2&&u<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)c=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[m]|=c<>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);else if(v==="le")for(_=0,m=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);return this._strip()};function o(p,a){var u=p.charCodeAt(a);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;t(!1,"Invalid character in "+p)}function f(p,a,u){var v=o(p,u);return u-1>=a&&(v|=o(p,u-1)<<4),v}n.prototype._parseHex=function(a,u,v){this.length=Math.ceil((a.length-u)/6),this.words=new Array(this.length);for(var _=0;_=u;_-=2)x=f(a,u,_)<=18?(m-=18,c+=1,this.words[c]|=x>>>26):m+=8;else{var A=a.length-u;for(_=A%2===0?u+1:u;_=18?(m-=18,c+=1,this.words[c]|=x>>>26):m+=8}this._strip()};function d(p,a,u,v){for(var _=0,m=0,c=Math.min(p.length,u),x=a;x=49?m=A-49+10:A>=17?m=A-17+10:m=A,t(A>=0&&m1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,u){a=a||10,u=u|0||1;var v;if(a===16||a==="hex"){v="";for(var _=0,m=0,c=0;c>>24-_&16777215,_+=2,_>=26&&(_-=26,c--),m!==0||c!==this.length-1?v=y[6-A.length]+A+v:v=A+v}for(m!==0&&(v=m.toString(16)+v);v.length%u!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];v="";var k=this.clone();for(k.negative=0;!k.isZero();){var E=k.modrn(R).toString(a);k=k.idivn(R),k.isZero()?v=E+v:v=y[g-E.length]+E+v}for(this.isZero()&&(v="0"+v);v.length%u!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,u){return this.toArrayLike(s,a,u)}),n.prototype.toArray=function(a,u){return this.toArrayLike(Array,a,u)};var M=function(a,u){return a.allocUnsafe?a.allocUnsafe(u):new a(u)};n.prototype.toArrayLike=function(a,u,v){this._strip();var _=this.byteLength(),m=v||Math.max(1,_);t(_<=m,"byte array longer than desired length"),t(m>0,"Requested array length <= 0");var c=M(a,m),x=u==="le"?"LE":"BE";return this["_toArrayLike"+x](c,_),c},n.prototype._toArrayLikeLE=function(a,u){for(var v=0,_=0,m=0,c=0;m>8&255),v>16&255),c===6?(v>24&255),_=0,c=0):(_=x>>>24,c+=2)}if(v=0&&(a[v--]=x>>8&255),v>=0&&(a[v--]=x>>16&255),c===6?(v>=0&&(a[v--]=x>>24&255),_=0,c=0):(_=x>>>24,c+=2)}if(v>=0)for(a[v--]=_;v>=0;)a[v--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var u=a,v=0;return u>=4096&&(v+=13,u>>>=13),u>=64&&(v+=7,u>>>=7),u>=8&&(v+=4,u>>>=4),u>=2&&(v+=2,u>>>=2),v+u},n.prototype._zeroBits=function(a){if(a===0)return 26;var u=a,v=0;return u&8191||(v+=13,u>>>=13),u&127||(v+=7,u>>>=7),u&15||(v+=4,u>>>=4),u&3||(v+=2,u>>>=2),u&1||v++,v},n.prototype.bitLength=function(){var a=this.words[this.length-1],u=this._countBits(a);return(this.length-1)*26+u};function T(p){for(var a=new Array(p.bitLength()),u=0;u>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,u=0;ua.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var u;this.length>a.length?u=a:u=this;for(var v=0;va.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var u,v;this.length>a.length?(u=this,v=a):(u=a,v=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var u=Math.ceil(a/26)|0,v=a%26;this._expand(u),v>0&&u--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-v),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,u){t(typeof a=="number"&&a>=0);var v=a/26|0,_=a%26;return this._expand(v+1),u?this.words[v]=this.words[v]|1<<_:this.words[v]=this.words[v]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var u;if(this.negative!==0&&a.negative===0)return this.negative=0,u=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,u=this.isub(a),a.negative=1,u._normSign();var v,_;this.length>a.length?(v=this,_=a):(v=a,_=this);for(var m=0,c=0;c<_.length;c++)u=(v.words[c]|0)+(_.words[c]|0)+m,this.words[c]=u&67108863,m=u>>>26;for(;m!==0&&c>>26;if(this.length=v.length,m!==0)this.words[this.length]=m,this.length++;else if(v!==this)for(;ca.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var u=this.iadd(a);return a.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var v=this.cmp(a);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,m;v>0?(_=this,m=a):(_=a,m=this);for(var c=0,x=0;x>26,this.words[x]=u&67108863;for(;c!==0&&x<_.length;x++)u=(_.words[x]|0)+c,c=u>>26,this.words[x]=u&67108863;if(c===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function C(p,a,u){u.negative=a.negative^p.negative;var v=p.length+a.length|0;u.length=v,v=v-1|0;var _=p.words[0]|0,m=a.words[0]|0,c=_*m,x=c&67108863,A=c/67108864|0;u.words[0]=x;for(var g=1;g>>26,k=A&67108863,E=Math.min(g,a.length-1),N=Math.max(0,g-p.length+1);N<=E;N++){var F=g-N|0;_=p.words[F]|0,m=a.words[N]|0,c=_*m+k,R+=c/67108864|0,k=c&67108863}u.words[g]=k|0,A=R|0}return A!==0?u.words[g]=A|0:u.length--,u._strip()}var P=function(a,u,v){var _=a.words,m=u.words,c=v.words,x=0,A,g,R,k=_[0]|0,E=k&8191,N=k>>>13,F=_[1]|0,q=F&8191,K=F>>>13,J=_[2]|0,$=J&8191,V=J>>>13,ee=_[3]|0,G=ee&8191,Y=ee>>>13,_r=_[4]|0,ie=_r&8191,ne=_r>>>13,xr=_[5]|0,se=xr&8191,oe=xr>>>13,Er=_[6]|0,ae=Er&8191,fe=Er>>>13,Sr=_[7]|0,ce=Sr&8191,he=Sr>>>13,Ir=_[8]|0,ue=Ir&8191,de=Ir>>>13,Mr=_[9]|0,le=Mr&8191,pe=Mr>>>13,Ar=m[0]|0,ge=Ar&8191,be=Ar>>>13,Rr=m[1]|0,ve=Rr&8191,me=Rr>>>13,Tr=m[2]|0,ye=Tr&8191,we=Tr>>>13,Dr=m[3]|0,_e=Dr&8191,xe=Dr>>>13,Pr=m[4]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=m[5]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=m[6]|0,Ae=Cr&8191,Re=Cr>>>13,Or=m[7]|0,Te=Or&8191,De=Or>>>13,Lr=m[8]|0,Pe=Lr&8191,Ne=Lr>>>13,nr=m[9]|0,Be=nr&8191,ke=nr>>>13;v.negative=a.negative^u.negative,v.length=19,A=Math.imul(E,ge),g=Math.imul(E,be),g=g+Math.imul(N,ge)|0,R=Math.imul(N,be);var jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(jt>>>26)|0,jt&=67108863,A=Math.imul(q,ge),g=Math.imul(q,be),g=g+Math.imul(K,ge)|0,R=Math.imul(K,be),A=A+Math.imul(E,ve)|0,g=g+Math.imul(E,me)|0,g=g+Math.imul(N,ve)|0,R=R+Math.imul(N,me)|0;var Vt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,A=Math.imul($,ge),g=Math.imul($,be),g=g+Math.imul(V,ge)|0,R=Math.imul(V,be),A=A+Math.imul(q,ve)|0,g=g+Math.imul(q,me)|0,g=g+Math.imul(K,ve)|0,R=R+Math.imul(K,me)|0,A=A+Math.imul(E,ye)|0,g=g+Math.imul(E,we)|0,g=g+Math.imul(N,ye)|0,R=R+Math.imul(N,we)|0;var $t=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+($t>>>26)|0,$t&=67108863,A=Math.imul(G,ge),g=Math.imul(G,be),g=g+Math.imul(Y,ge)|0,R=Math.imul(Y,be),A=A+Math.imul($,ve)|0,g=g+Math.imul($,me)|0,g=g+Math.imul(V,ve)|0,R=R+Math.imul(V,me)|0,A=A+Math.imul(q,ye)|0,g=g+Math.imul(q,we)|0,g=g+Math.imul(K,ye)|0,R=R+Math.imul(K,we)|0,A=A+Math.imul(E,_e)|0,g=g+Math.imul(E,xe)|0,g=g+Math.imul(N,_e)|0,R=R+Math.imul(N,xe)|0;var Ht=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,A=Math.imul(ie,ge),g=Math.imul(ie,be),g=g+Math.imul(ne,ge)|0,R=Math.imul(ne,be),A=A+Math.imul(G,ve)|0,g=g+Math.imul(G,me)|0,g=g+Math.imul(Y,ve)|0,R=R+Math.imul(Y,me)|0,A=A+Math.imul($,ye)|0,g=g+Math.imul($,we)|0,g=g+Math.imul(V,ye)|0,R=R+Math.imul(V,we)|0,A=A+Math.imul(q,_e)|0,g=g+Math.imul(q,xe)|0,g=g+Math.imul(K,_e)|0,R=R+Math.imul(K,xe)|0,A=A+Math.imul(E,Ee)|0,g=g+Math.imul(E,Se)|0,g=g+Math.imul(N,Ee)|0,R=R+Math.imul(N,Se)|0;var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(se,ge),g=Math.imul(se,be),g=g+Math.imul(oe,ge)|0,R=Math.imul(oe,be),A=A+Math.imul(ie,ve)|0,g=g+Math.imul(ie,me)|0,g=g+Math.imul(ne,ve)|0,R=R+Math.imul(ne,me)|0,A=A+Math.imul(G,ye)|0,g=g+Math.imul(G,we)|0,g=g+Math.imul(Y,ye)|0,R=R+Math.imul(Y,we)|0,A=A+Math.imul($,_e)|0,g=g+Math.imul($,xe)|0,g=g+Math.imul(V,_e)|0,R=R+Math.imul(V,xe)|0,A=A+Math.imul(q,Ee)|0,g=g+Math.imul(q,Se)|0,g=g+Math.imul(K,Ee)|0,R=R+Math.imul(K,Se)|0,A=A+Math.imul(E,Ie)|0,g=g+Math.imul(E,Me)|0,g=g+Math.imul(N,Ie)|0,R=R+Math.imul(N,Me)|0;var Zi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,A=Math.imul(ae,ge),g=Math.imul(ae,be),g=g+Math.imul(fe,ge)|0,R=Math.imul(fe,be),A=A+Math.imul(se,ve)|0,g=g+Math.imul(se,me)|0,g=g+Math.imul(oe,ve)|0,R=R+Math.imul(oe,me)|0,A=A+Math.imul(ie,ye)|0,g=g+Math.imul(ie,we)|0,g=g+Math.imul(ne,ye)|0,R=R+Math.imul(ne,we)|0,A=A+Math.imul(G,_e)|0,g=g+Math.imul(G,xe)|0,g=g+Math.imul(Y,_e)|0,R=R+Math.imul(Y,xe)|0,A=A+Math.imul($,Ee)|0,g=g+Math.imul($,Se)|0,g=g+Math.imul(V,Ee)|0,R=R+Math.imul(V,Se)|0,A=A+Math.imul(q,Ie)|0,g=g+Math.imul(q,Me)|0,g=g+Math.imul(K,Ie)|0,R=R+Math.imul(K,Me)|0,A=A+Math.imul(E,Ae)|0,g=g+Math.imul(E,Re)|0,g=g+Math.imul(N,Ae)|0,R=R+Math.imul(N,Re)|0;var Qi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,A=Math.imul(ce,ge),g=Math.imul(ce,be),g=g+Math.imul(he,ge)|0,R=Math.imul(he,be),A=A+Math.imul(ae,ve)|0,g=g+Math.imul(ae,me)|0,g=g+Math.imul(fe,ve)|0,R=R+Math.imul(fe,me)|0,A=A+Math.imul(se,ye)|0,g=g+Math.imul(se,we)|0,g=g+Math.imul(oe,ye)|0,R=R+Math.imul(oe,we)|0,A=A+Math.imul(ie,_e)|0,g=g+Math.imul(ie,xe)|0,g=g+Math.imul(ne,_e)|0,R=R+Math.imul(ne,xe)|0,A=A+Math.imul(G,Ee)|0,g=g+Math.imul(G,Se)|0,g=g+Math.imul(Y,Ee)|0,R=R+Math.imul(Y,Se)|0,A=A+Math.imul($,Ie)|0,g=g+Math.imul($,Me)|0,g=g+Math.imul(V,Ie)|0,R=R+Math.imul(V,Me)|0,A=A+Math.imul(q,Ae)|0,g=g+Math.imul(q,Re)|0,g=g+Math.imul(K,Ae)|0,R=R+Math.imul(K,Re)|0,A=A+Math.imul(E,Te)|0,g=g+Math.imul(E,De)|0,g=g+Math.imul(N,Te)|0,R=R+Math.imul(N,De)|0;var en=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(en>>>26)|0,en&=67108863,A=Math.imul(ue,ge),g=Math.imul(ue,be),g=g+Math.imul(de,ge)|0,R=Math.imul(de,be),A=A+Math.imul(ce,ve)|0,g=g+Math.imul(ce,me)|0,g=g+Math.imul(he,ve)|0,R=R+Math.imul(he,me)|0,A=A+Math.imul(ae,ye)|0,g=g+Math.imul(ae,we)|0,g=g+Math.imul(fe,ye)|0,R=R+Math.imul(fe,we)|0,A=A+Math.imul(se,_e)|0,g=g+Math.imul(se,xe)|0,g=g+Math.imul(oe,_e)|0,R=R+Math.imul(oe,xe)|0,A=A+Math.imul(ie,Ee)|0,g=g+Math.imul(ie,Se)|0,g=g+Math.imul(ne,Ee)|0,R=R+Math.imul(ne,Se)|0,A=A+Math.imul(G,Ie)|0,g=g+Math.imul(G,Me)|0,g=g+Math.imul(Y,Ie)|0,R=R+Math.imul(Y,Me)|0,A=A+Math.imul($,Ae)|0,g=g+Math.imul($,Re)|0,g=g+Math.imul(V,Ae)|0,R=R+Math.imul(V,Re)|0,A=A+Math.imul(q,Te)|0,g=g+Math.imul(q,De)|0,g=g+Math.imul(K,Te)|0,R=R+Math.imul(K,De)|0,A=A+Math.imul(E,Pe)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(N,Pe)|0,R=R+Math.imul(N,Ne)|0;var tn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(tn>>>26)|0,tn&=67108863,A=Math.imul(le,ge),g=Math.imul(le,be),g=g+Math.imul(pe,ge)|0,R=Math.imul(pe,be),A=A+Math.imul(ue,ve)|0,g=g+Math.imul(ue,me)|0,g=g+Math.imul(de,ve)|0,R=R+Math.imul(de,me)|0,A=A+Math.imul(ce,ye)|0,g=g+Math.imul(ce,we)|0,g=g+Math.imul(he,ye)|0,R=R+Math.imul(he,we)|0,A=A+Math.imul(ae,_e)|0,g=g+Math.imul(ae,xe)|0,g=g+Math.imul(fe,_e)|0,R=R+Math.imul(fe,xe)|0,A=A+Math.imul(se,Ee)|0,g=g+Math.imul(se,Se)|0,g=g+Math.imul(oe,Ee)|0,R=R+Math.imul(oe,Se)|0,A=A+Math.imul(ie,Ie)|0,g=g+Math.imul(ie,Me)|0,g=g+Math.imul(ne,Ie)|0,R=R+Math.imul(ne,Me)|0,A=A+Math.imul(G,Ae)|0,g=g+Math.imul(G,Re)|0,g=g+Math.imul(Y,Ae)|0,R=R+Math.imul(Y,Re)|0,A=A+Math.imul($,Te)|0,g=g+Math.imul($,De)|0,g=g+Math.imul(V,Te)|0,R=R+Math.imul(V,De)|0,A=A+Math.imul(q,Pe)|0,g=g+Math.imul(q,Ne)|0,g=g+Math.imul(K,Pe)|0,R=R+Math.imul(K,Ne)|0,A=A+Math.imul(E,Be)|0,g=g+Math.imul(E,ke)|0,g=g+Math.imul(N,Be)|0,R=R+Math.imul(N,ke)|0;var rn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(rn>>>26)|0,rn&=67108863,A=Math.imul(le,ve),g=Math.imul(le,me),g=g+Math.imul(pe,ve)|0,R=Math.imul(pe,me),A=A+Math.imul(ue,ye)|0,g=g+Math.imul(ue,we)|0,g=g+Math.imul(de,ye)|0,R=R+Math.imul(de,we)|0,A=A+Math.imul(ce,_e)|0,g=g+Math.imul(ce,xe)|0,g=g+Math.imul(he,_e)|0,R=R+Math.imul(he,xe)|0,A=A+Math.imul(ae,Ee)|0,g=g+Math.imul(ae,Se)|0,g=g+Math.imul(fe,Ee)|0,R=R+Math.imul(fe,Se)|0,A=A+Math.imul(se,Ie)|0,g=g+Math.imul(se,Me)|0,g=g+Math.imul(oe,Ie)|0,R=R+Math.imul(oe,Me)|0,A=A+Math.imul(ie,Ae)|0,g=g+Math.imul(ie,Re)|0,g=g+Math.imul(ne,Ae)|0,R=R+Math.imul(ne,Re)|0,A=A+Math.imul(G,Te)|0,g=g+Math.imul(G,De)|0,g=g+Math.imul(Y,Te)|0,R=R+Math.imul(Y,De)|0,A=A+Math.imul($,Pe)|0,g=g+Math.imul($,Ne)|0,g=g+Math.imul(V,Pe)|0,R=R+Math.imul(V,Ne)|0,A=A+Math.imul(q,Be)|0,g=g+Math.imul(q,ke)|0,g=g+Math.imul(K,Be)|0,R=R+Math.imul(K,ke)|0;var nn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nn>>>26)|0,nn&=67108863,A=Math.imul(le,ye),g=Math.imul(le,we),g=g+Math.imul(pe,ye)|0,R=Math.imul(pe,we),A=A+Math.imul(ue,_e)|0,g=g+Math.imul(ue,xe)|0,g=g+Math.imul(de,_e)|0,R=R+Math.imul(de,xe)|0,A=A+Math.imul(ce,Ee)|0,g=g+Math.imul(ce,Se)|0,g=g+Math.imul(he,Ee)|0,R=R+Math.imul(he,Se)|0,A=A+Math.imul(ae,Ie)|0,g=g+Math.imul(ae,Me)|0,g=g+Math.imul(fe,Ie)|0,R=R+Math.imul(fe,Me)|0,A=A+Math.imul(se,Ae)|0,g=g+Math.imul(se,Re)|0,g=g+Math.imul(oe,Ae)|0,R=R+Math.imul(oe,Re)|0,A=A+Math.imul(ie,Te)|0,g=g+Math.imul(ie,De)|0,g=g+Math.imul(ne,Te)|0,R=R+Math.imul(ne,De)|0,A=A+Math.imul(G,Pe)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(Y,Pe)|0,R=R+Math.imul(Y,Ne)|0,A=A+Math.imul($,Be)|0,g=g+Math.imul($,ke)|0,g=g+Math.imul(V,Be)|0,R=R+Math.imul(V,ke)|0;var sn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(sn>>>26)|0,sn&=67108863,A=Math.imul(le,_e),g=Math.imul(le,xe),g=g+Math.imul(pe,_e)|0,R=Math.imul(pe,xe),A=A+Math.imul(ue,Ee)|0,g=g+Math.imul(ue,Se)|0,g=g+Math.imul(de,Ee)|0,R=R+Math.imul(de,Se)|0,A=A+Math.imul(ce,Ie)|0,g=g+Math.imul(ce,Me)|0,g=g+Math.imul(he,Ie)|0,R=R+Math.imul(he,Me)|0,A=A+Math.imul(ae,Ae)|0,g=g+Math.imul(ae,Re)|0,g=g+Math.imul(fe,Ae)|0,R=R+Math.imul(fe,Re)|0,A=A+Math.imul(se,Te)|0,g=g+Math.imul(se,De)|0,g=g+Math.imul(oe,Te)|0,R=R+Math.imul(oe,De)|0,A=A+Math.imul(ie,Pe)|0,g=g+Math.imul(ie,Ne)|0,g=g+Math.imul(ne,Pe)|0,R=R+Math.imul(ne,Ne)|0,A=A+Math.imul(G,Be)|0,g=g+Math.imul(G,ke)|0,g=g+Math.imul(Y,Be)|0,R=R+Math.imul(Y,ke)|0;var on=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(on>>>26)|0,on&=67108863,A=Math.imul(le,Ee),g=Math.imul(le,Se),g=g+Math.imul(pe,Ee)|0,R=Math.imul(pe,Se),A=A+Math.imul(ue,Ie)|0,g=g+Math.imul(ue,Me)|0,g=g+Math.imul(de,Ie)|0,R=R+Math.imul(de,Me)|0,A=A+Math.imul(ce,Ae)|0,g=g+Math.imul(ce,Re)|0,g=g+Math.imul(he,Ae)|0,R=R+Math.imul(he,Re)|0,A=A+Math.imul(ae,Te)|0,g=g+Math.imul(ae,De)|0,g=g+Math.imul(fe,Te)|0,R=R+Math.imul(fe,De)|0,A=A+Math.imul(se,Pe)|0,g=g+Math.imul(se,Ne)|0,g=g+Math.imul(oe,Pe)|0,R=R+Math.imul(oe,Ne)|0,A=A+Math.imul(ie,Be)|0,g=g+Math.imul(ie,ke)|0,g=g+Math.imul(ne,Be)|0,R=R+Math.imul(ne,ke)|0;var an=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(an>>>26)|0,an&=67108863,A=Math.imul(le,Ie),g=Math.imul(le,Me),g=g+Math.imul(pe,Ie)|0,R=Math.imul(pe,Me),A=A+Math.imul(ue,Ae)|0,g=g+Math.imul(ue,Re)|0,g=g+Math.imul(de,Ae)|0,R=R+Math.imul(de,Re)|0,A=A+Math.imul(ce,Te)|0,g=g+Math.imul(ce,De)|0,g=g+Math.imul(he,Te)|0,R=R+Math.imul(he,De)|0,A=A+Math.imul(ae,Pe)|0,g=g+Math.imul(ae,Ne)|0,g=g+Math.imul(fe,Pe)|0,R=R+Math.imul(fe,Ne)|0,A=A+Math.imul(se,Be)|0,g=g+Math.imul(se,ke)|0,g=g+Math.imul(oe,Be)|0,R=R+Math.imul(oe,ke)|0;var fn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fn>>>26)|0,fn&=67108863,A=Math.imul(le,Ae),g=Math.imul(le,Re),g=g+Math.imul(pe,Ae)|0,R=Math.imul(pe,Re),A=A+Math.imul(ue,Te)|0,g=g+Math.imul(ue,De)|0,g=g+Math.imul(de,Te)|0,R=R+Math.imul(de,De)|0,A=A+Math.imul(ce,Pe)|0,g=g+Math.imul(ce,Ne)|0,g=g+Math.imul(he,Pe)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(ae,Be)|0,g=g+Math.imul(ae,ke)|0,g=g+Math.imul(fe,Be)|0,R=R+Math.imul(fe,ke)|0;var cn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cn>>>26)|0,cn&=67108863,A=Math.imul(le,Te),g=Math.imul(le,De),g=g+Math.imul(pe,Te)|0,R=Math.imul(pe,De),A=A+Math.imul(ue,Pe)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(de,Pe)|0,R=R+Math.imul(de,Ne)|0,A=A+Math.imul(ce,Be)|0,g=g+Math.imul(ce,ke)|0,g=g+Math.imul(he,Be)|0,R=R+Math.imul(he,ke)|0;var fc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fc>>>26)|0,fc&=67108863,A=Math.imul(le,Pe),g=Math.imul(le,Ne),g=g+Math.imul(pe,Pe)|0,R=Math.imul(pe,Ne),A=A+Math.imul(ue,Be)|0,g=g+Math.imul(ue,ke)|0,g=g+Math.imul(de,Be)|0,R=R+Math.imul(de,ke)|0;var cc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cc>>>26)|0,cc&=67108863,A=Math.imul(le,Be),g=Math.imul(le,ke),g=g+Math.imul(pe,Be)|0,R=Math.imul(pe,ke);var hc=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(hc>>>26)|0,hc&=67108863,c[0]=jt,c[1]=Vt,c[2]=$t,c[3]=Ht,c[4]=Gt,c[5]=Zi,c[6]=Qi,c[7]=en,c[8]=tn,c[9]=rn,c[10]=nn,c[11]=sn,c[12]=on,c[13]=an,c[14]=fn,c[15]=cn,c[16]=fc,c[17]=cc,c[18]=hc,x!==0&&(c[19]=x,v.length++),v};Math.imul||(P=C);function U(p,a,u){u.negative=a.negative^p.negative,u.length=p.length+a.length;for(var v=0,_=0,m=0;m>>26)|0,_+=c>>>26,c&=67108863}u.words[m]=x,v=c,c=_}return v!==0?u.words[m]=v:u.length--,u._strip()}function B(p,a,u){return U(p,a,u)}n.prototype.mulTo=function(a,u){var v,_=this.length+a.length;return this.length===10&&a.length===10?v=P(this,a,u):_<63?v=C(this,a,u):_<1024?v=U(this,a,u):v=B(this,a,u),v};function z(p,a){this.x=p,this.y=a}z.prototype.makeRBT=function(a){for(var u=new Array(a),v=n.prototype._countBits(a)-1,_=0;_>=1;return _},z.prototype.permute=function(a,u,v,_,m,c){for(var x=0;x>>1)m++;return 1<>>13,v[2*c+1]=m&8191,m=m>>>13;for(c=2*u;c<_;++c)v[c]=0;t(m===0),t((m&-8192)===0)},z.prototype.stub=function(a){for(var u=new Array(a),v=0;v>=26,v+=m/67108864|0,v+=c>>>26,this.words[_]=c&67108863}return v!==0&&(this.words[_]=v,this.length++),u?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var u=T(a);if(u.length===0)return new n(1);for(var v=this,_=0;_=0);var u=a%26,v=(a-u)/26,_=67108863>>>26-u<<26-u,m;if(u!==0){var c=0;for(m=0;m>>26-u}c&&(this.words[m]=c,this.length++)}if(v!==0){for(m=this.length-1;m>=0;m--)this.words[m+v]=this.words[m];for(m=0;m=0);var _;u?_=(u-u%26)/26:_=0;var m=a%26,c=Math.min((a-m)/26,this.length),x=67108863^67108863>>>m<c)for(this.length-=c,g=0;g=0&&(R!==0||g>=_);g--){var k=this.words[g]|0;this.words[g]=R<<26-m|k>>>m,R=k&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,u,v){return t(this.negative===0),this.iushrn(a,u,v)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var u=a%26,v=(a-u)/26,_=1<=0);var u=a%26,v=(a-u)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(u!==0&&v++,this.length=Math.min(v,this.length),u!==0){var _=67108863^67108863>>>u<=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u>26)-(A/67108864|0),this.words[m+v]=c&67108863}for(;m>26,this.words[m+v]=c&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,m=0;m>26,this.words[m]=c&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,u){var v=this.length-a.length,_=this.clone(),m=a,c=m.words[m.length-1]|0,x=this._countBits(c);v=26-x,v!==0&&(m=m.ushln(v),_.iushln(v),c=m.words[m.length-1]|0);var A=_.length-m.length,g;if(u!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var N=(_.words[m.length+E]|0)*67108864+(_.words[m.length+E-1]|0);for(N=Math.min(N/c|0,67108863),_._ishlnsubmul(m,N,E);_.negative!==0;)N--,_.negative=0,_._ishlnsubmul(m,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=N)}return g&&g._strip(),_._strip(),u!=="div"&&v!==0&&_.iushrn(v),{div:g||null,mod:_}},n.prototype.divmod=function(a,u,v){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,m,c;return this.negative!==0&&a.negative===0?(c=this.neg().divmod(a,u),u!=="mod"&&(_=c.div.neg()),u!=="div"&&(m=c.mod.neg(),v&&m.negative!==0&&m.iadd(a)),{div:_,mod:m}):this.negative===0&&a.negative!==0?(c=this.divmod(a.neg(),u),u!=="mod"&&(_=c.div.neg()),{div:_,mod:c.mod}):this.negative&a.negative?(c=this.neg().divmod(a.neg(),u),u!=="div"&&(m=c.mod.neg(),v&&m.negative!==0&&m.isub(a)),{div:c.div,mod:m}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?u==="div"?{div:this.divn(a.words[0]),mod:null}:u==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,u)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var u=this.divmod(a);if(u.mod.isZero())return u.div;var v=u.div.negative!==0?u.mod.isub(a):u.mod,_=a.ushrn(1),m=a.andln(1),c=v.cmp(_);return c<0||m===1&&c===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},n.prototype.modrn=function(a){var u=a<0;u&&(a=-a),t(a<=67108863);for(var v=(1<<26)%a,_=0,m=this.length-1;m>=0;m--)_=(v*_+(this.words[m]|0))%a;return u?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var u=a<0;u&&(a=-a),t(a<=67108863);for(var v=0,_=this.length-1;_>=0;_--){var m=(this.words[_]|0)+v*67108864;this.words[_]=m/a|0,v=m%a}return this._strip(),u?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var u=this,v=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var _=new n(1),m=new n(0),c=new n(0),x=new n(1),A=0;u.isEven()&&v.isEven();)u.iushrn(1),v.iushrn(1),++A;for(var g=v.clone(),R=u.clone();!u.isZero();){for(var k=0,E=1;!(u.words[0]&E)&&k<26;++k,E<<=1);if(k>0)for(u.iushrn(k);k-- >0;)(_.isOdd()||m.isOdd())&&(_.iadd(g),m.isub(R)),_.iushrn(1),m.iushrn(1);for(var N=0,F=1;!(v.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(v.iushrn(N);N-- >0;)(c.isOdd()||x.isOdd())&&(c.iadd(g),x.isub(R)),c.iushrn(1),x.iushrn(1);u.cmp(v)>=0?(u.isub(v),_.isub(c),m.isub(x)):(v.isub(u),c.isub(_),x.isub(m))}return{a:c,b:x,gcd:v.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var u=this,v=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var _=new n(1),m=new n(0),c=v.clone();u.cmpn(1)>0&&v.cmpn(1)>0;){for(var x=0,A=1;!(u.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(u.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(c),_.iushrn(1);for(var g=0,R=1;!(v.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(v.iushrn(g);g-- >0;)m.isOdd()&&m.iadd(c),m.iushrn(1);u.cmp(v)>=0?(u.isub(v),_.isub(m)):(v.isub(u),m.isub(_))}var k;return u.cmpn(1)===0?k=_:k=m,k.cmpn(0)<0&&k.iadd(a),k},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var u=this.clone(),v=a.clone();u.negative=0,v.negative=0;for(var _=0;u.isEven()&&v.isEven();_++)u.iushrn(1),v.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;v.isEven();)v.iushrn(1);var m=u.cmp(v);if(m<0){var c=u;u=v,v=c}else if(m===0||v.cmpn(1)===0)break;u.isub(v)}while(!0);return v.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var u=a%26,v=(a-u)/26,_=1<>>26,x&=67108863,this.words[c]=x}return m!==0&&(this.words[c]=m,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var u=a<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var v;if(this.length>1)v=1;else{u&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;v=_===a?0:_a.length)return 1;if(this.length=0;v--){var _=this.words[v]|0,m=a.words[v]|0;if(_!==m){_m&&(u=1);break}}return u},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var j={k256:null,p224:null,p192:null,p25519:null};function H(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var u=a,v;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),v=u.bitLength();while(v>this.n);var _=v0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},H.prototype.split=function(a,u){a.iushrn(this.n,0,u)},H.prototype.imulK=function(a){return a.imul(this.k)};function L(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,H),L.prototype.split=function(a,u){for(var v=4194303,_=Math.min(a.length,9),m=0;m<_;m++)u.words[m]=a.words[m];if(u.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var c=a.words[9];for(u.words[u.length++]=c&v,m=10;m>>22,c=x}c>>>=22,a.words[m-10]=c,c===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var u=0,v=0;v>>=26,a.words[v]=m,u=_}return u!==0&&(a.words[a.length++]=u),a},n._prime=function(a){if(j[a])return j[a];var u;if(a==="k256")u=new L;else if(a==="p224")u=new O;else if(a==="p192")u=new W;else if(a==="p25519")u=new D;else throw new Error("Unknown prime "+a);return j[a]=u,u};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,u){t((a.negative|u.negative)===0,"red works only with positives"),t(a.red&&a.red===u.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(h(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,u){this._verify2(a,u);var v=a.add(u);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},l.prototype.iadd=function(a,u){this._verify2(a,u);var v=a.iadd(u);return v.cmp(this.m)>=0&&v.isub(this.m),v},l.prototype.sub=function(a,u){this._verify2(a,u);var v=a.sub(u);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},l.prototype.isub=function(a,u){this._verify2(a,u);var v=a.isub(u);return v.cmpn(0)<0&&v.iadd(this.m),v},l.prototype.shl=function(a,u){return this._verify1(a),this.imod(a.ushln(u))},l.prototype.imul=function(a,u){return this._verify2(a,u),this.imod(a.imul(u))},l.prototype.mul=function(a,u){return this._verify2(a,u),this.imod(a.mul(u))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var u=this.m.andln(3);if(t(u%2===1),u===3){var v=this.m.add(new n(1)).iushrn(2);return this.pow(a,v)}for(var _=this.m.subn(1),m=0;!_.isZero()&&_.andln(1)===0;)m++,_.iushrn(1);t(!_.isZero());var c=new n(1).toRed(this),x=c.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),k=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),N=m;E.cmp(c)!==0;){for(var F=E,q=0;F.cmp(c)!==0;q++)F=F.redSqr();t(q=0;m--){for(var R=u.words[m],k=g-1;k>=0;k--){var E=R>>k&1;if(c!==_[0]&&(c=this.sqr(c)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==v&&(m!==0||k!==0))&&(c=this.mul(c,_[x]),A=0,x=0)}g=26}return c},l.prototype.convertTo=function(a){var u=a.umod(this.m);return u===a?u.clone():u},l.prototype.convertFrom=function(a){var u=a.clone();return u.red=null,u},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var u=this.imod(a.mul(this.rinv));return u.red=null,u},w.prototype.imul=function(a,u){if(a.isZero()||u.isZero())return a.words[0]=0,a.length=1,a;var v=a.imul(u),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),c=m;return m.cmp(this.m)>=0?c=m.isub(this.m):m.cmpn(0)<0&&(c=m.iadd(this.m)),c._forceRed(this)},w.prototype.mul=function(a,u){if(a.isZero()||u.isZero())return new n(0)._forceRed(this);var v=a.mul(u),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),c=m;return m.cmp(this.m)>=0?c=m.isub(this.m):m.cmpn(0)<0&&(c=m.iadd(this.m)),c._forceRed(this)},w.prototype.invm=function(a){var u=this.imod(a._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(typeof Dh>"u"||Dh,Gp)});var Di=Z((UA,o1)=>{o1.exports=s1;function s1(r,e){if(!r)throw new Error(e||"Assertion failed")}s1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var co=Z((zA,Oh)=>{typeof Object.create=="function"?Oh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Oh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var fr=Z(Ve=>{"use strict";var jw=Di(),Vw=co();Ve.inherits=Vw;function $w(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Hw(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):$w(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ve.htonl=a1;function Ww(r,e){for(var t="",i=0;i>>0}return s}Ve.join32=Jw;function Yw(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ve.split32=Yw;function Xw(r,e){return r>>>e|r<<32-e}Ve.rotr32=Xw;function Zw(r,e){return r<>>32-e}Ve.rotl32=Zw;function Qw(r,e){return r+e>>>0}Ve.sum32=Qw;function e5(r,e,t){return r+e+t>>>0}Ve.sum32_3=e5;function t5(r,e,t,i){return r+e+t+i>>>0}Ve.sum32_4=t5;function r5(r,e,t,i,n){return r+e+t+i+n>>>0}Ve.sum32_5=r5;function i5(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}Ve.sum64=i5;function n5(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ve.sum64_hi=n5;function s5(r,e,t,i){var n=e+i;return n>>>0}Ve.sum64_lo=s5;function o5(r,e,t,i,n,s,o,f){var d=0,h=e;h=h+i>>>0,d+=h>>0,d+=h>>0,d+=h>>0}Ve.sum64_4_hi=o5;function a5(r,e,t,i,n,s,o,f){var d=e+i+s+f;return d>>>0}Ve.sum64_4_lo=a5;function f5(r,e,t,i,n,s,o,f,d,h){var b=0,y=e;y=y+i>>>0,b+=y>>0,b+=y>>0,b+=y>>0,b+=y>>0}Ve.sum64_5_hi=f5;function c5(r,e,t,i,n,s,o,f,d,h){var b=e+i+s+f+h;return b>>>0}Ve.sum64_5_lo=c5;function h5(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ve.rotr64_hi=h5;function u5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.rotr64_lo=u5;function d5(r,e,t){return r>>>t}Ve.shr64_hi=d5;function l5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.shr64_lo=l5});var os=Z(u1=>{"use strict";var h1=fr(),p5=Di();function Ga(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}u1.BlockHash=Ga;Ga.prototype.update=function(e,t){if(e=h1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=h1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var g5=fr(),zr=g5.rotr32;function b5(r,e,t,i){if(r===0)return d1(e,t,i);if(r===1||r===3)return p1(e,t,i);if(r===2)return l1(e,t,i)}ui.ft_1=b5;function d1(r,e,t){return r&e^~r&t}ui.ch32=d1;function l1(r,e,t){return r&e^r&t^e&t}ui.maj32=l1;function p1(r,e,t){return r^e^t}ui.p32=p1;function v5(r){return zr(r,2)^zr(r,13)^zr(r,22)}ui.s0_256=v5;function m5(r){return zr(r,6)^zr(r,11)^zr(r,25)}ui.s1_256=m5;function y5(r){return zr(r,7)^zr(r,18)^r>>>3}ui.g0_256=y5;function w5(r){return zr(r,17)^zr(r,19)^r>>>10}ui.g1_256=w5});var v1=Z((jA,b1)=>{"use strict";var as=fr(),_5=os(),x5=Lh(),Fh=as.rotl32,ho=as.sum32,E5=as.sum32_5,S5=x5.ft_1,g1=_5.BlockHash,I5=[1518500249,1859775393,2400959708,3395469782];function Br(){if(!(this instanceof Br))return new Br;g1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}as.inherits(Br,g1);b1.exports=Br;Br.blockSize=512;Br.outSize=160;Br.hmacStrength=80;Br.padLength=64;Br.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var fs=fr(),M5=os(),cs=Lh(),A5=Di(),cr=fs.sum32,R5=fs.sum32_4,T5=fs.sum32_5,D5=cs.ch32,P5=cs.maj32,N5=cs.s0_256,C5=cs.s1_256,O5=cs.g0_256,L5=cs.g1_256,m1=M5.BlockHash,F5=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function kr(){if(!(this instanceof kr))return new kr;m1.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=F5,this.W=new Array(64)}fs.inherits(kr,m1);y1.exports=kr;kr.blockSize=512;kr.outSize=256;kr.hmacStrength=192;kr.padLength=64;kr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Uh=fr(),w1=qh();function di(){if(!(this instanceof di))return new di;w1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Uh.inherits(di,w1);_1.exports=di;di.blockSize=512;di.outSize=224;di.hmacStrength=192;di.padLength=64;di.prototype._digest=function(e){return e==="hex"?Uh.toHex32(this.h.slice(0,7),"big"):Uh.split32(this.h.slice(0,7),"big")}});var kh=Z((HA,M1)=>{"use strict";var Ot=fr(),q5=os(),U5=Di(),Kr=Ot.rotr64_hi,jr=Ot.rotr64_lo,E1=Ot.shr64_hi,S1=Ot.shr64_lo,Pi=Ot.sum64,zh=Ot.sum64_hi,Bh=Ot.sum64_lo,z5=Ot.sum64_4_hi,B5=Ot.sum64_4_lo,k5=Ot.sum64_5_hi,K5=Ot.sum64_5_lo,I1=q5.BlockHash,j5=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function hr(){if(!(this instanceof hr))return new hr;I1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=j5,this.W=new Array(160)}Ot.inherits(hr,I1);M1.exports=hr;hr.blockSize=1024;hr.outSize=512;hr.hmacStrength=192;hr.padLength=128;hr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Kh=fr(),A1=kh();function li(){if(!(this instanceof li))return new li;A1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Kh.inherits(li,A1);R1.exports=li;li.blockSize=1024;li.outSize=384;li.hmacStrength=192;li.padLength=128;li.prototype._digest=function(e){return e==="hex"?Kh.toHex32(this.h.slice(0,12),"big"):Kh.split32(this.h.slice(0,12),"big")}});var D1=Z(hs=>{"use strict";hs.sha1=v1();hs.sha224=x1();hs.sha256=qh();hs.sha384=T1();hs.sha512=kh()});var F1=Z(L1=>{"use strict";var wn=fr(),r8=os(),Wa=wn.rotl32,P1=wn.sum32,uo=wn.sum32_3,N1=wn.sum32_4,O1=r8.BlockHash;function Vr(){if(!(this instanceof Vr))return new Vr;O1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}wn.inherits(Vr,O1);L1.ripemd160=Vr;Vr.blockSize=512;Vr.outSize=160;Vr.hmacStrength=192;Vr.padLength=64;Vr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],d=i,h=n,b=s,y=o,S=f,I=0;I<80;I++){var M=P1(Wa(N1(i,C1(I,n,s,o),e[s8[I]+t],i8(I)),a8[I]),f);i=f,f=o,o=Wa(s,10),s=n,n=M,M=P1(Wa(N1(d,C1(79-I,h,b,y),e[o8[I]+t],n8(I)),f8[I]),S),d=S,S=y,y=Wa(b,10),b=h,h=M}M=uo(this.h[1],s,y),this.h[1]=uo(this.h[2],o,S),this.h[2]=uo(this.h[3],f,d),this.h[3]=uo(this.h[4],i,h),this.h[4]=uo(this.h[0],n,b),this.h[0]=M};Vr.prototype._digest=function(e){return e==="hex"?wn.toHex32(this.h,"little"):wn.split32(this.h,"little")};function C1(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function i8(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function n8(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var s8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o8=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],a8=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f8=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var U1=Z((YA,q1)=>{"use strict";var c8=fr(),h8=Di();function us(r,e,t){if(!(this instanceof us))return new us(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(c8.toArray(e,t))}q1.exports=us;us.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),h8(e.length<=this.blockSize);for(var t=e.length;t{var pt=z1;pt.utils=fr();pt.common=os();pt.sha=D1();pt.ripemd=F1();pt.hmac=U1();pt.sha1=pt.sha.sha1;pt.sha256=pt.sha.sha256;pt.sha224=pt.sha.sha224;pt.sha384=pt.sha.sha384;pt.sha512=pt.sha.sha512;pt.ripemd160=pt.ripemd.ripemd160});var X1=Z(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var Et=Hn(),Qh=Jt(),_8=20;function x8(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],d=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],C=e[7]<<24|e[6]<<16|e[5]<<8|e[4],P=e[11]<<24|e[10]<<16|e[9]<<8|e[8],U=e[15]<<24|e[14]<<16|e[13]<<8|e[12],B=i,z=n,j=s,H=o,L=f,O=d,W=h,D=b,l=y,w=S,p=I,a=M,u=T,v=C,_=P,m=U,c=0;c<_8;c+=2)B=B+L|0,u^=B,u=u>>>16|u<<16,l=l+u|0,L^=l,L=L>>>20|L<<12,z=z+O|0,v^=z,v=v>>>16|v<<16,w=w+v|0,O^=w,O=O>>>20|O<<12,j=j+W|0,_^=j,_=_>>>16|_<<16,p=p+_|0,W^=p,W=W>>>20|W<<12,H=H+D|0,m^=H,m=m>>>16|m<<16,a=a+m|0,D^=a,D=D>>>20|D<<12,j=j+W|0,_^=j,_=_>>>24|_<<8,p=p+_|0,W^=p,W=W>>>25|W<<7,H=H+D|0,m^=H,m=m>>>24|m<<8,a=a+m|0,D^=a,D=D>>>25|D<<7,z=z+O|0,v^=z,v=v>>>24|v<<8,w=w+v|0,O^=w,O=O>>>25|O<<7,B=B+L|0,u^=B,u=u>>>24|u<<8,l=l+u|0,L^=l,L=L>>>25|L<<7,B=B+O|0,m^=B,m=m>>>16|m<<16,p=p+m|0,O^=p,O=O>>>20|O<<12,z=z+W|0,u^=z,u=u>>>16|u<<16,a=a+u|0,W^=a,W=W>>>20|W<<12,j=j+D|0,v^=j,v=v>>>16|v<<16,l=l+v|0,D^=l,D=D>>>20|D<<12,H=H+L|0,_^=H,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,j=j+D|0,v^=j,v=v>>>24|v<<8,l=l+v|0,D^=l,D=D>>>25|D<<7,H=H+L|0,_^=H,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,z=z+W|0,u^=z,u=u>>>24|u<<8,a=a+u|0,W^=a,W=W>>>25|W<<7,B=B+O|0,m^=B,m=m>>>24|m<<8,p=p+m|0,O^=p,O=O>>>25|O<<7;Et.writeUint32LE(B+i|0,r,0),Et.writeUint32LE(z+n|0,r,4),Et.writeUint32LE(j+s|0,r,8),Et.writeUint32LE(H+o|0,r,12),Et.writeUint32LE(L+f|0,r,16),Et.writeUint32LE(O+d|0,r,20),Et.writeUint32LE(W+h|0,r,24),Et.writeUint32LE(D+b|0,r,28),Et.writeUint32LE(l+y|0,r,32),Et.writeUint32LE(w+S|0,r,36),Et.writeUint32LE(p+I|0,r,40),Et.writeUint32LE(a+M|0,r,44),Et.writeUint32LE(u+T|0,r,48),Et.writeUint32LE(v+C|0,r,52),Et.writeUint32LE(_+P|0,r,56),Et.writeUint32LE(m+U|0,r,60)}function Y1(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var rf=Z(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});function I8(r,e,t){return~(r-1)&e|r-1&t}ls.select=I8;function M8(r,e){return(r|0)-(e|0)-1>>>31&1}ls.lessOrEqual=M8;function Z1(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}ls.compare=Z1;function A8(r,e){return r.length===0||e.length===0?!1:Z1(r,e)!==0}ls.equal=A8});var eg=Z(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var R8=rf(),nf=Jt();pi.DIGEST_LENGTH=16;var Q1=function(){function r(e){this.digestLength=pi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var d=e[12]|e[13]<<8;this._r[7]=(f>>>11|d<<5)&8065;var h=e[14]|e[15]<<8;this._r[8]=(d>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],d=this._h[3],h=this._h[4],b=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],C=this._r[1],P=this._r[2],U=this._r[3],B=this._r[4],z=this._r[5],j=this._r[6],H=this._r[7],L=this._r[8],O=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var D=e[t+2]|e[t+3]<<8;o+=(W>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;d+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;h+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;y+=(p>>>14|a<<2)&8191;var u=e[t+12]|e[t+13]<<8;S+=(a>>>11|u<<5)&8191;var v=e[t+14]|e[t+15]<<8;I+=(u>>>8|v<<8)&8191,M+=v>>>5|n;var _=0,m=_;m+=s*T,m+=o*(5*O),m+=f*(5*L),m+=d*(5*H),m+=h*(5*j),_=m>>>13,m&=8191,m+=b*(5*z),m+=y*(5*B),m+=S*(5*U),m+=I*(5*P),m+=M*(5*C),_+=m>>>13,m&=8191;var c=_;c+=s*C,c+=o*T,c+=f*(5*O),c+=d*(5*L),c+=h*(5*H),_=c>>>13,c&=8191,c+=b*(5*j),c+=y*(5*z),c+=S*(5*B),c+=I*(5*U),c+=M*(5*P),_+=c>>>13,c&=8191;var x=_;x+=s*P,x+=o*C,x+=f*T,x+=d*(5*O),x+=h*(5*L),_=x>>>13,x&=8191,x+=b*(5*H),x+=y*(5*j),x+=S*(5*z),x+=I*(5*B),x+=M*(5*U),_+=x>>>13,x&=8191;var A=_;A+=s*U,A+=o*P,A+=f*C,A+=d*T,A+=h*(5*O),_=A>>>13,A&=8191,A+=b*(5*L),A+=y*(5*H),A+=S*(5*j),A+=I*(5*z),A+=M*(5*B),_+=A>>>13,A&=8191;var g=_;g+=s*B,g+=o*U,g+=f*P,g+=d*C,g+=h*T,_=g>>>13,g&=8191,g+=b*(5*O),g+=y*(5*L),g+=S*(5*H),g+=I*(5*j),g+=M*(5*z),_+=g>>>13,g&=8191;var R=_;R+=s*z,R+=o*B,R+=f*U,R+=d*P,R+=h*C,_=R>>>13,R&=8191,R+=b*T,R+=y*(5*O),R+=S*(5*L),R+=I*(5*H),R+=M*(5*j),_+=R>>>13,R&=8191;var k=_;k+=s*j,k+=o*z,k+=f*B,k+=d*U,k+=h*P,_=k>>>13,k&=8191,k+=b*C,k+=y*T,k+=S*(5*O),k+=I*(5*L),k+=M*(5*H),_+=k>>>13,k&=8191;var E=_;E+=s*H,E+=o*j,E+=f*z,E+=d*B,E+=h*U,_=E>>>13,E&=8191,E+=b*P,E+=y*C,E+=S*T,E+=I*(5*O),E+=M*(5*L),_+=E>>>13,E&=8191;var N=_;N+=s*L,N+=o*H,N+=f*j,N+=d*z,N+=h*B,_=N>>>13,N&=8191,N+=b*U,N+=y*P,N+=S*C,N+=I*T,N+=M*(5*O),_+=N>>>13,N&=8191;var F=_;F+=s*O,F+=o*L,F+=f*H,F+=d*j,F+=h*z,_=F>>>13,F&=8191,F+=b*B,F+=y*U,F+=S*P,F+=I*C,F+=M*T,_+=F>>>13,F&=8191,_=(_<<2)+_|0,_=_+m|0,m=_&8191,_=_>>>13,c+=_,s=m,o=c,f=x,d=A,h=g,b=R,y=k,S=E,I=N,M=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=d,this._h[4]=h,this._h[5]=b,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});var sf=X1(),P8=eg(),po=Jt(),tg=Hn(),N8=rf();gi.KEY_LENGTH=32;gi.NONCE_LENGTH=12;gi.TAG_LENGTH=16;var rg=new Uint8Array(16),C8=function(){function r(e){if(this.nonceLength=gi.NONCE_LENGTH,this.tagLength=gi.TAG_LENGTH,e.length!==gi.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);sf.stream(this._key,s,o,4);var f=t.length+this.tagLength,d;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");d=n}else d=new Uint8Array(f);return sf.streamXOR(this._key,s,t,d,4),this._authenticate(d.subarray(d.length-this.tagLength,d.length),o,d.subarray(0,d.length-this.tagLength),i),po.wipe(s),d},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(rg.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(rg.subarray(i.length%16));var o=new Uint8Array(8);n&&tg.writeUint64LE(n.length,o),s.update(o),tg.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),d=0;d{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});function O8(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}eu.isSerializableHash=O8});var og=Z(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Gr=ng(),L8=rf(),F8=Jt(),sg=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ag=og(),fg=Jt(),U8=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ag.hmac(this._hash,i,t);this._hmac=new ag.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});var af=Hn(),of=Jt();Oi.DIGEST_LENGTH=32;Oi.BLOCK_SIZE=64;var hg=function(){function r(){this.digestLength=Oi.DIGEST_LENGTH,this.blockSize=Oi.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){of.wipe(this._buffer),of.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ru(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ru(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){of.wipe(e.state),e.buffer&&of.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Oi.SHA256=hg;var z8=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ru(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],d=e[3],h=e[4],b=e[5],y=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=af.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],C=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var P=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(C+r[I-7]|0)+(P+r[I-16]|0)}for(var I=0;I<64;I++){var C=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&b^~h&y)|0)+(S+(z8[I]+r[I]|0)|0)|0,P=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=y,y=b,b=h,h=d+C|0,d=f,f=o,o=s,s=C+P|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=d,e[4]+=h,e[5]+=b,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function B8(r){var e=new hg;e.update(r);var t=e.digest();return e.clean(),t}Oi.hash=B8});var gg=Z(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.sharedKey=Qe.generateKeyPair=Qe.generateKeyPairFromSeed=Qe.scalarMultBase=Qe.scalarMult=Qe.SHARED_KEY_LENGTH=Qe.SECRET_KEY_LENGTH=Qe.PUBLIC_KEY_LENGTH=void 0;var k8=Js(),K8=Jt();Qe.PUBLIC_KEY_LENGTH=32;Qe.SECRET_KEY_LENGTH=32;Qe.SHARED_KEY_LENGTH=32;function Wr(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function $8(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ff(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function cf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function bi(r,e,t){let i,n,s=0,o=0,f=0,d=0,h=0,b=0,y=0,S=0,I=0,M=0,T=0,C=0,P=0,U=0,B=0,z=0,j=0,H=0,L=0,O=0,W=0,D=0,l=0,w=0,p=0,a=0,u=0,v=0,_=0,m=0,c=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,d+=i*R,h+=i*k,b+=i*E,y+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,C+=i*$,P+=i*V,U+=i*ee,B+=i*G,z+=i*Y,i=e[1],o+=i*x,f+=i*A,d+=i*g,h+=i*R,b+=i*k,y+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,C+=i*J,P+=i*$,U+=i*V,B+=i*ee,z+=i*G,j+=i*Y,i=e[2],f+=i*x,d+=i*A,h+=i*g,b+=i*R,y+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,C+=i*K,P+=i*J,U+=i*$,B+=i*V,z+=i*ee,j+=i*G,H+=i*Y,i=e[3],d+=i*x,h+=i*A,b+=i*g,y+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,C+=i*q,P+=i*K,U+=i*J,B+=i*$,z+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],h+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,C+=i*F,P+=i*q,U+=i*K,B+=i*J,z+=i*$,j+=i*V,H+=i*ee,L+=i*G,O+=i*Y,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,C+=i*N,P+=i*F,U+=i*q,B+=i*K,z+=i*J,j+=i*$,H+=i*V,L+=i*ee,O+=i*G,W+=i*Y,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,C+=i*E,P+=i*N,U+=i*F,B+=i*q,z+=i*K,j+=i*J,H+=i*$,L+=i*V,O+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,C+=i*k,P+=i*E,U+=i*N,B+=i*F,z+=i*q,j+=i*K,H+=i*J,L+=i*$,O+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,C+=i*R,P+=i*k,U+=i*E,B+=i*N,z+=i*F,j+=i*q,H+=i*K,L+=i*J,O+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,C+=i*g,P+=i*R,U+=i*k,B+=i*E,z+=i*N,j+=i*F,H+=i*q,L+=i*K,O+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,C+=i*A,P+=i*g,U+=i*R,B+=i*k,z+=i*E,j+=i*N,H+=i*F,L+=i*q,O+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],C+=i*x,P+=i*A,U+=i*g,B+=i*R,z+=i*k,j+=i*E,H+=i*N,L+=i*F,O+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,u+=i*Y,i=e[12],P+=i*x,U+=i*A,B+=i*g,z+=i*R,j+=i*k,H+=i*E,L+=i*N,O+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,u+=i*G,v+=i*Y,i=e[13],U+=i*x,B+=i*A,z+=i*g,j+=i*R,H+=i*k,L+=i*E,O+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,u+=i*ee,v+=i*G,_+=i*Y,i=e[14],B+=i*x,z+=i*A,j+=i*g,H+=i*R,L+=i*k,O+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,u+=i*V,v+=i*ee,_+=i*G,m+=i*Y,i=e[15],z+=i*x,j+=i*A,H+=i*g,L+=i*R,O+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,u+=i*$,v+=i*V,_+=i*ee,m+=i*G,c+=i*Y,s+=38*j,o+=38*H,f+=38*L,d+=38*O,h+=38*W,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*u,C+=38*v,P+=38*_,U+=38*m,B+=38*c,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=d,r[4]=h,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=C,r[12]=P,r[13]=U,r[14]=B,r[15]=z}function vo(r,e){bi(r,e,e)}function H8(r,e){let t=Wr();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)vo(t,t),i!==2&&i!==4&&bi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function nu(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=Wr(),s=Wr(),o=Wr(),f=Wr(),d=Wr(),h=Wr();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,$8(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;bo(n,s,M),bo(o,f,M),ff(d,n,o),cf(n,n,o),ff(o,s,f),cf(s,s,f),vo(f,d),vo(h,n),bi(n,o,n),bi(o,s,d),ff(d,n,o),cf(n,n,o),vo(s,n),cf(o,f,h),bi(n,o,j8),ff(n,n,f),bi(o,o,n),bi(n,f,h),bi(f,s,i),vo(s,d),bo(n,s,M),bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),y=i.subarray(16);H8(b,b),bi(y,y,b);let S=new Uint8Array(32);return V8(S,y),S}Qe.scalarMult=nu;function lg(r){return nu(r,dg)}Qe.scalarMultBase=lg;function pg(r){if(r.length!==Qe.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${Qe.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:lg(e),secretKey:e}}Qe.generateKeyPairFromSeed=pg;function G8(r){let e=(0,k8.randomBytes)(32,r),t=pg(e);return(0,K8.wipe)(e),t}Qe.generateKeyPair=G8;function W8(r,e,t=!1){if(r.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=nu(r,e);if(t){let n=0;for(let s=0;s{J8.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var Jr=Z((vg,su)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)v=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[u]|=v<<_&67108863,this.words[u+1]=v>>>26-_&67108863,_+=24,_>=26&&(_-=26,u++);else if(p==="le")for(a=0,u=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,u++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(u-=18,v+=1,this.words[v]|=_>>>26):u+=8;else{var m=l.length-w;for(a=m%2===0?w+1:w;a=18?(u-=18,v+=1,this.words[v]|=_>>>26):u+=8}this.strip()};function d(D,l,w,p){for(var a=0,u=Math.min(D.length,w),v=l;v=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,u=1;u<=67108863;u*=w)a++;a--,u=u/w|0;for(var v=l.length-p,_=v%a,m=Math.min(v,v-_)+p,c=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,u=0,v=0;v>>24-a&16777215,u!==0||v!==this.length-1?p=h[6-m.length]+m+p:p=m+p,a+=2,a>=26&&(a-=26,v--)}for(u!==0&&(p=u.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var c=b[l],x=y[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=h[c-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),u=p||Math.max(1,a);t(a<=u,"byte array longer than desired length"),t(u>0,"Requested array length <= 0"),this.strip();var v=w==="le",_=new l(u),m,c,x=this.clone();if(v){for(c=0;!x.isZero();c++)m=x.andln(255),x.iushrn(8),_[c]=m;for(;c=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var u=0,v=0;v>>26;for(;u!==0&&v>>26;if(this.length=p.length,u!==0)this.words[this.length]=u,this.length++;else if(p!==this)for(;vl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,u;p>0?(a=this,u=l):(a=l,u=this);for(var v=0,_=0;_>26,this.words[_]=w&67108863;for(;v!==0&&_>26,this.words[_]=w&67108863;if(v===0&&_>>26,A=m&67108863,g=Math.min(c,l.length-1),R=Math.max(0,c-D.length+1);R<=g;R++){var k=c-R|0;a=D.words[k]|0,u=l.words[R]|0,v=a*u+A,x+=v/67108864|0,A=v&67108863}w.words[c]=A|0,m=x|0}return m!==0?w.words[c]=m|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,u=w.words,v=p.words,_=0,m,c,x,A=a[0]|0,g=A&8191,R=A>>>13,k=a[1]|0,E=k&8191,N=k>>>13,F=a[2]|0,q=F&8191,K=F>>>13,J=a[3]|0,$=J&8191,V=J>>>13,ee=a[4]|0,G=ee&8191,Y=ee>>>13,_r=a[5]|0,ie=_r&8191,ne=_r>>>13,xr=a[6]|0,se=xr&8191,oe=xr>>>13,Er=a[7]|0,ae=Er&8191,fe=Er>>>13,Sr=a[8]|0,ce=Sr&8191,he=Sr>>>13,Ir=a[9]|0,ue=Ir&8191,de=Ir>>>13,Mr=u[0]|0,le=Mr&8191,pe=Mr>>>13,Ar=u[1]|0,ge=Ar&8191,be=Ar>>>13,Rr=u[2]|0,ve=Rr&8191,me=Rr>>>13,Tr=u[3]|0,ye=Tr&8191,we=Tr>>>13,Dr=u[4]|0,_e=Dr&8191,xe=Dr>>>13,Pr=u[5]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=u[6]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=u[7]|0,Ae=Cr&8191,Re=Cr>>>13,Or=u[8]|0,Te=Or&8191,De=Or>>>13,Lr=u[9]|0,Pe=Lr&8191,Ne=Lr>>>13;p.negative=l.negative^w.negative,p.length=19,m=Math.imul(g,le),c=Math.imul(g,pe),c=c+Math.imul(R,le)|0,x=Math.imul(R,pe);var nr=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(nr>>>26)|0,nr&=67108863,m=Math.imul(E,le),c=Math.imul(E,pe),c=c+Math.imul(N,le)|0,x=Math.imul(N,pe),m=m+Math.imul(g,ge)|0,c=c+Math.imul(g,be)|0,c=c+Math.imul(R,ge)|0,x=x+Math.imul(R,be)|0;var Be=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Be>>>26)|0,Be&=67108863,m=Math.imul(q,le),c=Math.imul(q,pe),c=c+Math.imul(K,le)|0,x=Math.imul(K,pe),m=m+Math.imul(E,ge)|0,c=c+Math.imul(E,be)|0,c=c+Math.imul(N,ge)|0,x=x+Math.imul(N,be)|0,m=m+Math.imul(g,ve)|0,c=c+Math.imul(g,me)|0,c=c+Math.imul(R,ve)|0,x=x+Math.imul(R,me)|0;var ke=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(ke>>>26)|0,ke&=67108863,m=Math.imul($,le),c=Math.imul($,pe),c=c+Math.imul(V,le)|0,x=Math.imul(V,pe),m=m+Math.imul(q,ge)|0,c=c+Math.imul(q,be)|0,c=c+Math.imul(K,ge)|0,x=x+Math.imul(K,be)|0,m=m+Math.imul(E,ve)|0,c=c+Math.imul(E,me)|0,c=c+Math.imul(N,ve)|0,x=x+Math.imul(N,me)|0,m=m+Math.imul(g,ye)|0,c=c+Math.imul(g,we)|0,c=c+Math.imul(R,ye)|0,x=x+Math.imul(R,we)|0;var jt=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(jt>>>26)|0,jt&=67108863,m=Math.imul(G,le),c=Math.imul(G,pe),c=c+Math.imul(Y,le)|0,x=Math.imul(Y,pe),m=m+Math.imul($,ge)|0,c=c+Math.imul($,be)|0,c=c+Math.imul(V,ge)|0,x=x+Math.imul(V,be)|0,m=m+Math.imul(q,ve)|0,c=c+Math.imul(q,me)|0,c=c+Math.imul(K,ve)|0,x=x+Math.imul(K,me)|0,m=m+Math.imul(E,ye)|0,c=c+Math.imul(E,we)|0,c=c+Math.imul(N,ye)|0,x=x+Math.imul(N,we)|0,m=m+Math.imul(g,_e)|0,c=c+Math.imul(g,xe)|0,c=c+Math.imul(R,_e)|0,x=x+Math.imul(R,xe)|0;var Vt=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,m=Math.imul(ie,le),c=Math.imul(ie,pe),c=c+Math.imul(ne,le)|0,x=Math.imul(ne,pe),m=m+Math.imul(G,ge)|0,c=c+Math.imul(G,be)|0,c=c+Math.imul(Y,ge)|0,x=x+Math.imul(Y,be)|0,m=m+Math.imul($,ve)|0,c=c+Math.imul($,me)|0,c=c+Math.imul(V,ve)|0,x=x+Math.imul(V,me)|0,m=m+Math.imul(q,ye)|0,c=c+Math.imul(q,we)|0,c=c+Math.imul(K,ye)|0,x=x+Math.imul(K,we)|0,m=m+Math.imul(E,_e)|0,c=c+Math.imul(E,xe)|0,c=c+Math.imul(N,_e)|0,x=x+Math.imul(N,xe)|0,m=m+Math.imul(g,Ee)|0,c=c+Math.imul(g,Se)|0,c=c+Math.imul(R,Ee)|0,x=x+Math.imul(R,Se)|0;var $t=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+($t>>>26)|0,$t&=67108863,m=Math.imul(se,le),c=Math.imul(se,pe),c=c+Math.imul(oe,le)|0,x=Math.imul(oe,pe),m=m+Math.imul(ie,ge)|0,c=c+Math.imul(ie,be)|0,c=c+Math.imul(ne,ge)|0,x=x+Math.imul(ne,be)|0,m=m+Math.imul(G,ve)|0,c=c+Math.imul(G,me)|0,c=c+Math.imul(Y,ve)|0,x=x+Math.imul(Y,me)|0,m=m+Math.imul($,ye)|0,c=c+Math.imul($,we)|0,c=c+Math.imul(V,ye)|0,x=x+Math.imul(V,we)|0,m=m+Math.imul(q,_e)|0,c=c+Math.imul(q,xe)|0,c=c+Math.imul(K,_e)|0,x=x+Math.imul(K,xe)|0,m=m+Math.imul(E,Ee)|0,c=c+Math.imul(E,Se)|0,c=c+Math.imul(N,Ee)|0,x=x+Math.imul(N,Se)|0,m=m+Math.imul(g,Ie)|0,c=c+Math.imul(g,Me)|0,c=c+Math.imul(R,Ie)|0,x=x+Math.imul(R,Me)|0;var Ht=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,m=Math.imul(ae,le),c=Math.imul(ae,pe),c=c+Math.imul(fe,le)|0,x=Math.imul(fe,pe),m=m+Math.imul(se,ge)|0,c=c+Math.imul(se,be)|0,c=c+Math.imul(oe,ge)|0,x=x+Math.imul(oe,be)|0,m=m+Math.imul(ie,ve)|0,c=c+Math.imul(ie,me)|0,c=c+Math.imul(ne,ve)|0,x=x+Math.imul(ne,me)|0,m=m+Math.imul(G,ye)|0,c=c+Math.imul(G,we)|0,c=c+Math.imul(Y,ye)|0,x=x+Math.imul(Y,we)|0,m=m+Math.imul($,_e)|0,c=c+Math.imul($,xe)|0,c=c+Math.imul(V,_e)|0,x=x+Math.imul(V,xe)|0,m=m+Math.imul(q,Ee)|0,c=c+Math.imul(q,Se)|0,c=c+Math.imul(K,Ee)|0,x=x+Math.imul(K,Se)|0,m=m+Math.imul(E,Ie)|0,c=c+Math.imul(E,Me)|0,c=c+Math.imul(N,Ie)|0,x=x+Math.imul(N,Me)|0,m=m+Math.imul(g,Ae)|0,c=c+Math.imul(g,Re)|0,c=c+Math.imul(R,Ae)|0,x=x+Math.imul(R,Re)|0;var Gt=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,m=Math.imul(ce,le),c=Math.imul(ce,pe),c=c+Math.imul(he,le)|0,x=Math.imul(he,pe),m=m+Math.imul(ae,ge)|0,c=c+Math.imul(ae,be)|0,c=c+Math.imul(fe,ge)|0,x=x+Math.imul(fe,be)|0,m=m+Math.imul(se,ve)|0,c=c+Math.imul(se,me)|0,c=c+Math.imul(oe,ve)|0,x=x+Math.imul(oe,me)|0,m=m+Math.imul(ie,ye)|0,c=c+Math.imul(ie,we)|0,c=c+Math.imul(ne,ye)|0,x=x+Math.imul(ne,we)|0,m=m+Math.imul(G,_e)|0,c=c+Math.imul(G,xe)|0,c=c+Math.imul(Y,_e)|0,x=x+Math.imul(Y,xe)|0,m=m+Math.imul($,Ee)|0,c=c+Math.imul($,Se)|0,c=c+Math.imul(V,Ee)|0,x=x+Math.imul(V,Se)|0,m=m+Math.imul(q,Ie)|0,c=c+Math.imul(q,Me)|0,c=c+Math.imul(K,Ie)|0,x=x+Math.imul(K,Me)|0,m=m+Math.imul(E,Ae)|0,c=c+Math.imul(E,Re)|0,c=c+Math.imul(N,Ae)|0,x=x+Math.imul(N,Re)|0,m=m+Math.imul(g,Te)|0,c=c+Math.imul(g,De)|0,c=c+Math.imul(R,Te)|0,x=x+Math.imul(R,De)|0;var Zi=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,m=Math.imul(ue,le),c=Math.imul(ue,pe),c=c+Math.imul(de,le)|0,x=Math.imul(de,pe),m=m+Math.imul(ce,ge)|0,c=c+Math.imul(ce,be)|0,c=c+Math.imul(he,ge)|0,x=x+Math.imul(he,be)|0,m=m+Math.imul(ae,ve)|0,c=c+Math.imul(ae,me)|0,c=c+Math.imul(fe,ve)|0,x=x+Math.imul(fe,me)|0,m=m+Math.imul(se,ye)|0,c=c+Math.imul(se,we)|0,c=c+Math.imul(oe,ye)|0,x=x+Math.imul(oe,we)|0,m=m+Math.imul(ie,_e)|0,c=c+Math.imul(ie,xe)|0,c=c+Math.imul(ne,_e)|0,x=x+Math.imul(ne,xe)|0,m=m+Math.imul(G,Ee)|0,c=c+Math.imul(G,Se)|0,c=c+Math.imul(Y,Ee)|0,x=x+Math.imul(Y,Se)|0,m=m+Math.imul($,Ie)|0,c=c+Math.imul($,Me)|0,c=c+Math.imul(V,Ie)|0,x=x+Math.imul(V,Me)|0,m=m+Math.imul(q,Ae)|0,c=c+Math.imul(q,Re)|0,c=c+Math.imul(K,Ae)|0,x=x+Math.imul(K,Re)|0,m=m+Math.imul(E,Te)|0,c=c+Math.imul(E,De)|0,c=c+Math.imul(N,Te)|0,x=x+Math.imul(N,De)|0,m=m+Math.imul(g,Pe)|0,c=c+Math.imul(g,Ne)|0,c=c+Math.imul(R,Pe)|0,x=x+Math.imul(R,Ne)|0;var Qi=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,m=Math.imul(ue,ge),c=Math.imul(ue,be),c=c+Math.imul(de,ge)|0,x=Math.imul(de,be),m=m+Math.imul(ce,ve)|0,c=c+Math.imul(ce,me)|0,c=c+Math.imul(he,ve)|0,x=x+Math.imul(he,me)|0,m=m+Math.imul(ae,ye)|0,c=c+Math.imul(ae,we)|0,c=c+Math.imul(fe,ye)|0,x=x+Math.imul(fe,we)|0,m=m+Math.imul(se,_e)|0,c=c+Math.imul(se,xe)|0,c=c+Math.imul(oe,_e)|0,x=x+Math.imul(oe,xe)|0,m=m+Math.imul(ie,Ee)|0,c=c+Math.imul(ie,Se)|0,c=c+Math.imul(ne,Ee)|0,x=x+Math.imul(ne,Se)|0,m=m+Math.imul(G,Ie)|0,c=c+Math.imul(G,Me)|0,c=c+Math.imul(Y,Ie)|0,x=x+Math.imul(Y,Me)|0,m=m+Math.imul($,Ae)|0,c=c+Math.imul($,Re)|0,c=c+Math.imul(V,Ae)|0,x=x+Math.imul(V,Re)|0,m=m+Math.imul(q,Te)|0,c=c+Math.imul(q,De)|0,c=c+Math.imul(K,Te)|0,x=x+Math.imul(K,De)|0,m=m+Math.imul(E,Pe)|0,c=c+Math.imul(E,Ne)|0,c=c+Math.imul(N,Pe)|0,x=x+Math.imul(N,Ne)|0;var en=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(en>>>26)|0,en&=67108863,m=Math.imul(ue,ve),c=Math.imul(ue,me),c=c+Math.imul(de,ve)|0,x=Math.imul(de,me),m=m+Math.imul(ce,ye)|0,c=c+Math.imul(ce,we)|0,c=c+Math.imul(he,ye)|0,x=x+Math.imul(he,we)|0,m=m+Math.imul(ae,_e)|0,c=c+Math.imul(ae,xe)|0,c=c+Math.imul(fe,_e)|0,x=x+Math.imul(fe,xe)|0,m=m+Math.imul(se,Ee)|0,c=c+Math.imul(se,Se)|0,c=c+Math.imul(oe,Ee)|0,x=x+Math.imul(oe,Se)|0,m=m+Math.imul(ie,Ie)|0,c=c+Math.imul(ie,Me)|0,c=c+Math.imul(ne,Ie)|0,x=x+Math.imul(ne,Me)|0,m=m+Math.imul(G,Ae)|0,c=c+Math.imul(G,Re)|0,c=c+Math.imul(Y,Ae)|0,x=x+Math.imul(Y,Re)|0,m=m+Math.imul($,Te)|0,c=c+Math.imul($,De)|0,c=c+Math.imul(V,Te)|0,x=x+Math.imul(V,De)|0,m=m+Math.imul(q,Pe)|0,c=c+Math.imul(q,Ne)|0,c=c+Math.imul(K,Pe)|0,x=x+Math.imul(K,Ne)|0;var tn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(tn>>>26)|0,tn&=67108863,m=Math.imul(ue,ye),c=Math.imul(ue,we),c=c+Math.imul(de,ye)|0,x=Math.imul(de,we),m=m+Math.imul(ce,_e)|0,c=c+Math.imul(ce,xe)|0,c=c+Math.imul(he,_e)|0,x=x+Math.imul(he,xe)|0,m=m+Math.imul(ae,Ee)|0,c=c+Math.imul(ae,Se)|0,c=c+Math.imul(fe,Ee)|0,x=x+Math.imul(fe,Se)|0,m=m+Math.imul(se,Ie)|0,c=c+Math.imul(se,Me)|0,c=c+Math.imul(oe,Ie)|0,x=x+Math.imul(oe,Me)|0,m=m+Math.imul(ie,Ae)|0,c=c+Math.imul(ie,Re)|0,c=c+Math.imul(ne,Ae)|0,x=x+Math.imul(ne,Re)|0,m=m+Math.imul(G,Te)|0,c=c+Math.imul(G,De)|0,c=c+Math.imul(Y,Te)|0,x=x+Math.imul(Y,De)|0,m=m+Math.imul($,Pe)|0,c=c+Math.imul($,Ne)|0,c=c+Math.imul(V,Pe)|0,x=x+Math.imul(V,Ne)|0;var rn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(rn>>>26)|0,rn&=67108863,m=Math.imul(ue,_e),c=Math.imul(ue,xe),c=c+Math.imul(de,_e)|0,x=Math.imul(de,xe),m=m+Math.imul(ce,Ee)|0,c=c+Math.imul(ce,Se)|0,c=c+Math.imul(he,Ee)|0,x=x+Math.imul(he,Se)|0,m=m+Math.imul(ae,Ie)|0,c=c+Math.imul(ae,Me)|0,c=c+Math.imul(fe,Ie)|0,x=x+Math.imul(fe,Me)|0,m=m+Math.imul(se,Ae)|0,c=c+Math.imul(se,Re)|0,c=c+Math.imul(oe,Ae)|0,x=x+Math.imul(oe,Re)|0,m=m+Math.imul(ie,Te)|0,c=c+Math.imul(ie,De)|0,c=c+Math.imul(ne,Te)|0,x=x+Math.imul(ne,De)|0,m=m+Math.imul(G,Pe)|0,c=c+Math.imul(G,Ne)|0,c=c+Math.imul(Y,Pe)|0,x=x+Math.imul(Y,Ne)|0;var nn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(nn>>>26)|0,nn&=67108863,m=Math.imul(ue,Ee),c=Math.imul(ue,Se),c=c+Math.imul(de,Ee)|0,x=Math.imul(de,Se),m=m+Math.imul(ce,Ie)|0,c=c+Math.imul(ce,Me)|0,c=c+Math.imul(he,Ie)|0,x=x+Math.imul(he,Me)|0,m=m+Math.imul(ae,Ae)|0,c=c+Math.imul(ae,Re)|0,c=c+Math.imul(fe,Ae)|0,x=x+Math.imul(fe,Re)|0,m=m+Math.imul(se,Te)|0,c=c+Math.imul(se,De)|0,c=c+Math.imul(oe,Te)|0,x=x+Math.imul(oe,De)|0,m=m+Math.imul(ie,Pe)|0,c=c+Math.imul(ie,Ne)|0,c=c+Math.imul(ne,Pe)|0,x=x+Math.imul(ne,Ne)|0;var sn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(sn>>>26)|0,sn&=67108863,m=Math.imul(ue,Ie),c=Math.imul(ue,Me),c=c+Math.imul(de,Ie)|0,x=Math.imul(de,Me),m=m+Math.imul(ce,Ae)|0,c=c+Math.imul(ce,Re)|0,c=c+Math.imul(he,Ae)|0,x=x+Math.imul(he,Re)|0,m=m+Math.imul(ae,Te)|0,c=c+Math.imul(ae,De)|0,c=c+Math.imul(fe,Te)|0,x=x+Math.imul(fe,De)|0,m=m+Math.imul(se,Pe)|0,c=c+Math.imul(se,Ne)|0,c=c+Math.imul(oe,Pe)|0,x=x+Math.imul(oe,Ne)|0;var on=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(on>>>26)|0,on&=67108863,m=Math.imul(ue,Ae),c=Math.imul(ue,Re),c=c+Math.imul(de,Ae)|0,x=Math.imul(de,Re),m=m+Math.imul(ce,Te)|0,c=c+Math.imul(ce,De)|0,c=c+Math.imul(he,Te)|0,x=x+Math.imul(he,De)|0,m=m+Math.imul(ae,Pe)|0,c=c+Math.imul(ae,Ne)|0,c=c+Math.imul(fe,Pe)|0,x=x+Math.imul(fe,Ne)|0;var an=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(an>>>26)|0,an&=67108863,m=Math.imul(ue,Te),c=Math.imul(ue,De),c=c+Math.imul(de,Te)|0,x=Math.imul(de,De),m=m+Math.imul(ce,Pe)|0,c=c+Math.imul(ce,Ne)|0,c=c+Math.imul(he,Pe)|0,x=x+Math.imul(he,Ne)|0;var fn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(fn>>>26)|0,fn&=67108863,m=Math.imul(ue,Pe),c=Math.imul(ue,Ne),c=c+Math.imul(de,Pe)|0,x=Math.imul(de,Ne);var cn=(_+m|0)+((c&8191)<<13)|0;return _=(x+(c>>>13)|0)+(cn>>>26)|0,cn&=67108863,v[0]=nr,v[1]=Be,v[2]=ke,v[3]=jt,v[4]=Vt,v[5]=$t,v[6]=Ht,v[7]=Gt,v[8]=Zi,v[9]=Qi,v[10]=en,v[11]=tn,v[12]=rn,v[13]=nn,v[14]=sn,v[15]=on,v[16]=an,v[17]=fn,v[18]=cn,_!==0&&(v[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,u=0;u>>26)|0,a+=v>>>26,v&=67108863}w.words[u]=_,p=v,v=a}return p!==0?w.words[u]=p:w.length--,w.strip()}function C(D,l,w){var p=new P;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=C(this,l,w),p};function P(D,l){this.x=D,this.y=l}P.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},P.prototype.permute=function(l,w,p,a,u,v){for(var _=0;_>>1)u++;return 1<>>13,p[2*v+1]=u&8191,u=u>>>13;for(v=2*w;v>=26,w+=a/67108864|0,w+=u>>>26,this.words[p]=u&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,u;if(w!==0){var v=0;for(u=0;u>>26-w}v&&(this.words[u]=v,this.length++)}if(p!==0){for(u=this.length-1;u>=0;u--)this.words[u+p]=this.words[u];for(u=0;u=0);var a;w?a=(w-w%26)/26:a=0;var u=l%26,v=Math.min((l-u)/26,this.length),_=67108863^67108863>>>u<v)for(this.length-=v,c=0;c=0&&(x!==0||c>=a);c--){var A=this.words[c]|0;this.words[c]=x<<26-u|A>>>u,x=A&_}return m&&x!==0&&(m.words[m.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(m/67108864|0),this.words[u+p]=v&67108863}for(;u>26,this.words[u+p]=v&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,u=0;u>26,this.words[u]=v&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),u=l,v=u.words[u.length-1]|0,_=this._countBits(v);p=26-_,p!==0&&(u=u.ushln(p),a.iushln(p),v=u.words[u.length-1]|0);var m=a.length-u.length,c;if(w!=="mod"){c=new n(null),c.length=m+1,c.words=new Array(c.length);for(var x=0;x=0;g--){var R=(a.words[u.length+g]|0)*67108864+(a.words[u.length+g-1]|0);for(R=Math.min(R/v|0,67108863),a._ishlnsubmul(u,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(u,1,g),a.isZero()||(a.negative^=1);c&&(c.words[g]=R)}return c&&c.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:c||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,u,v;return this.negative!==0&&l.negative===0?(v=this.neg().divmod(l,w),w!=="mod"&&(a=v.div.neg()),w!=="div"&&(u=v.mod.neg(),p&&u.negative!==0&&u.iadd(l)),{div:a,mod:u}):this.negative===0&&l.negative!==0?(v=this.divmod(l.neg(),w),w!=="mod"&&(a=v.div.neg()),{div:a,mod:v.mod}):this.negative&l.negative?(v=this.neg().divmod(l.neg(),w),w!=="div"&&(u=v.mod.neg(),p&&u.negative!==0&&u.isub(l)),{div:v.div,mod:u}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),u=l.andln(1),v=p.cmp(a);return v<0||u===1&&v===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),u=new n(0),v=new n(0),_=new n(1),m=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++m;for(var c=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(c),u.isub(x)),a.iushrn(1),u.iushrn(1);for(var R=0,k=1;!(p.words[0]&k)&&R<26;++R,k<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(v.isOdd()||_.isOdd())&&(v.iadd(c),_.isub(x)),v.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(v),u.isub(_)):(p.isub(w),v.isub(a),_.isub(u))}return{a:v,b:_,gcd:p.iushln(m)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),u=new n(0),v=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,m=1;!(w.words[0]&m)&&_<26;++_,m<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(v),a.iushrn(1);for(var c=0,x=1;!(p.words[0]&x)&&c<26;++c,x<<=1);if(c>0)for(p.iushrn(c);c-- >0;)u.isOdd()&&u.iadd(v),u.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(u)):(p.isub(w),u.isub(a))}var A;return w.cmpn(1)===0?A=a:A=u,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var u=w.cmp(p);if(u<0){var v=w;w=p,p=v}else if(u===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[v]=_}return u!==0&&(this.words[v]=u,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,u=l.words[p]|0;if(a!==u){au&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new O(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var U={k256:null,p224:null,p192:null,p25519:null};function B(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}B.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},B.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},B.prototype.split=function(l,w){l.iushrn(this.n,0,w)},B.prototype.imulK=function(l){return l.imul(this.k)};function z(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(z,B),z.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),u=0;u>>22,v=_}v>>>=22,l.words[u-10]=v,v===0&&l.length>10?l.length-=10:l.length-=9},z.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=u,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(U[l])return U[l];var w;if(l==="k256")w=new z;else if(l==="p224")w=new j;else if(l==="p192")w=new H;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return U[l]=w,w};function O(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}O.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},O.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},O.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},O.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},O.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},O.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},O.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},O.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},O.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},O.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},O.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},O.prototype.isqr=function(l){return this.imul(l,l.clone())},O.prototype.sqr=function(l){return this.mul(l,l)},O.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),u=0;!a.isZero()&&a.andln(1)===0;)u++,a.iushrn(1);t(!a.isZero());var v=new n(1).toRed(this),_=v.redNeg(),m=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);this.pow(c,m).cmp(_)!==0;)c.redIAdd(_);for(var x=this.pow(c,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=u;g.cmp(v)!==0;){for(var k=g,E=0;k.cmp(v)!==0;E++)k=k.redSqr();t(E=0;u--){for(var x=w.words[u],A=c-1;A>=0;A--){var g=x>>A&1;if(v!==a[0]&&(v=this.sqr(v)),g===0&&_===0){m=0;continue}_<<=1,_|=g,m++,!(m!==p&&(u!==0||A!==0))&&(v=this.mul(v,a[_]),m=0,_=0)}c=26}return v},O.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},O.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(D){O.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,O),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=p.isub(a).iushrn(this.shift),v=u;return u.cmp(this.m)>=0?v=u.isub(this.m):u.cmpn(0)<0&&(v=u.iadd(this.m)),v._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=p.isub(a).iushrn(this.shift),v=u;return u.cmp(this.m)>=0?v=u.isub(this.m):u.cmpn(0)<0&&(v=u.iadd(this.m)),v._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof su>"u"||su,vg)});var ou=Z(wg=>{"use strict";var hf=wg;function Y8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}hf.toArray=Y8;function mg(r){return r.length===1?"0"+r:r}hf.zero2=mg;function yg(r){for(var e="",t=0;t{"use strict";var dr=_g,X8=Jr(),Z8=Di(),uf=ou();dr.assert=Z8;dr.toArray=uf.toArray;dr.zero2=uf.zero2;dr.toHex=uf.toHex;dr.encode=uf.encode;function Q8(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-d:f=d,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}dr.getNAF=Q8;function e4(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var d;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?d=-o:d=o):d=0,t[0].push(d);var h;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?h=-f:h=f):h=0,t[1].push(h),2*i===d+1&&(i=1-i),2*n===h+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}dr.getJSF=e4;function t4(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}dr.cachedProperty=t4;function r4(r){return typeof r=="string"?dr.toArray(r,"hex"):r}dr.parseBytes=r4;function i4(r){return new X8(r,"hex","le")}dr.intFromLE=i4});var hu=Z((KR,cu)=>{var au;cu.exports=function(e){return au||(au=new Li(null)),au.generate(e)};function Li(r){this.rand=r}cu.exports.Rand=Li;Li.prototype.generate=function(e){return this._rand(e)};Li.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var xn=Jr(),mo=Bt(),df=mo.getNAF,n4=mo.getJSF,lf=mo.assert;function Fi(r,e){this.type=r,this.p=new xn(e.p,16),this.red=e.prime?xn.red(e.prime):xn.mont(this.p),this.zero=new xn(0).toRed(this.red),this.one=new xn(1).toRed(this.red),this.two=new xn(2).toRed(this.red),this.n=e.n&&new xn(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}xg.exports=Fi;Fi.prototype.point=function(){throw new Error("Not implemented")};Fi.prototype.validate=function(){throw new Error("Not implemented")};Fi.prototype._fixedNafMul=function(e,t){lf(e.precomputed);var i=e._getDoubles(),n=df(t,1,this._bitLength),s=(1<=f;h--)d=(d<<1)+n[h];o.push(d)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;d--){for(var h=0;d>=0&&o[d]===0;d--)h++;if(d>=0&&h++,f=f.dblp(h),d<0)break;var b=o[d];lf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};Fi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,d=this._wnafT3,h=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){d[M]=df(i[M],o[M],this._bitLength),d[T]=df(i[T],o[T],this._bitLength),h=Math.max(d[M].length,h),h=Math.max(d[T].length,h);continue}var C=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(C[1]=t[M].add(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].add(t[T].neg())):(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],U=n4(i[M],i[T]);for(h=Math.max(U[0].length,h),d[M]=new Array(h),d[T]=new Array(h),y=0;y=0;b--){for(var L=0;b>=0;){var O=!0;for(y=0;y=0&&L++,j=j.dblp(L),b<0)break;for(y=0;y0?S=f[y][W-1>>1]:W<0&&(S=f[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Qt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var s4=Bt(),et=Jr(),uu=co(),ps=yo(),o4=s4.assert;function er(r){ps.call(this,"short",r),this.a=new et(r.a,16).toRed(this.red),this.b=new et(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}uu(er,ps);Eg.exports=er;er.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new et(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new et(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],o4(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new et(f.a,16),b:new et(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};er.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:et.mont(e),i=new et(2).toRed(t).redInvm(),n=i.redNeg(),s=new et(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};er.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new et(1),o=new et(0),f=new et(0),d=new et(1),h,b,y,S,I,M,T,C=0,P,U;i.cmpn(0)!==0;){var B=n.div(i);P=n.sub(B.mul(i)),U=f.sub(B.mul(s));var z=d.sub(B.mul(o));if(!y&&P.cmp(t)<0)h=T.neg(),b=s,y=P.neg(),S=U;else if(y&&++C===2)break;T=P,n=i,i=P,f=s,s=U,d=o,o=z}I=P.neg(),M=U;var j=y.sqr().add(S.sqr()),H=I.sqr().add(M.sqr());return H.cmp(j)>=0&&(I=h,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};er.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),d=o.mul(n.a),h=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(d),S=h.add(b).neg();return{k1:y,k2:S}};er.prototype.pointFromX=function(e,t){e=new et(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};er.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};er.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ct.prototype.isInfinity=function(){return this.inf};ct.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ct.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ct.prototype.getX=function(){return this.x.fromRed()};ct.prototype.getY=function(){return this.y.fromRed()};ct.prototype.mul=function(e){return e=new et(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ct.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ct.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ct.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ct.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ct.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function bt(r,e,t,i){ps.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new et(0)):(this.x=new et(e,16),this.y=new et(t,16),this.z=new et(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}uu(bt,ps.BasePoint);er.prototype.jpoint=function(e,t,i){return new bt(this,e,t,i)};bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),d=n.redSub(s),h=o.redSub(f);if(d.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=d.redSqr(),y=b.redMul(d),S=n.redMul(b),I=h.redSqr().redIAdd(y).redISub(S).redISub(S),M=h.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(I,M,T)};bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),d=s.redSub(o);if(f.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),b=h.redMul(f),y=i.redMul(h),S=d.redSqr().redIAdd(b).redISub(y).redISub(y),I=d.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};bt.prototype.inspect=function(){return this.isInfinity()?"":""};bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Ag=Z(($R,Mg)=>{"use strict";var gs=Jr(),Ig=co(),pf=yo(),a4=Bt();function bs(r){pf.call(this,"mont",r),this.a=new gs(r.a,16).toRed(this.red),this.b=new gs(r.b,16).toRed(this.red),this.i4=new gs(4).toRed(this.red).redInvm(),this.two=new gs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Ig(bs,pf);Mg.exports=bs;bs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function ht(r,e,t){pf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new gs(e,16),this.z=new gs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Ig(ht,pf.BasePoint);bs.prototype.decodePoint=function(e,t){return this.point(a4.toArray(e,t),1)};bs.prototype.point=function(e,t){return new ht(this,e,t)};bs.prototype.pointFromJSON=function(e){return ht.fromJSON(this,e)};ht.prototype.precompute=function(){};ht.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};ht.fromJSON=function(e,t){return new ht(e,t[0],t[1]||e.one)};ht.prototype.inspect=function(){return this.isInfinity()?"":""};ht.prototype.isInfinity=function(){return this.z.cmpn(0)===0};ht.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};ht.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),d=s.redMul(n),h=t.z.redMul(f.redAdd(d).redSqr()),b=t.x.redMul(f.redISub(d).redSqr());return this.curve.point(h,b)};ht.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};ht.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};ht.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};ht.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Dg=Z((HR,Tg)=>{"use strict";var f4=Bt(),vi=Jr(),Rg=co(),gf=yo(),c4=f4.assert;function Yr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,gf.call(this,"edwards",r),this.a=new vi(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new vi(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new vi(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c4(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Rg(Yr,gf);Tg.exports=Yr;Yr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Yr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Yr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Yr.prototype.pointFromX=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var d=f.fromRed().isOdd();return(t&&!d||!t&&d)&&(f=f.redNeg()),this.point(e,f)};Yr.prototype.pointFromY=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};Yr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ge(r,e,t,i,n){gf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new vi(e,16),this.y=new vi(t,16),this.z=i?new vi(i,16):this.curve.one,this.t=n&&new vi(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Rg(Ge,gf.BasePoint);Yr.prototype.pointFromJSON=function(e){return Ge.fromJSON(this,e)};Yr.prototype.point=function(e,t,i,n){return new Ge(this,e,t,i,n)};Ge.fromJSON=function(e,t){return new Ge(e,t[0],t[1],t[2])};Ge.prototype.inspect=function(){return this.isInfinity()?"":""};Ge.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ge.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),d=n.redSub(t),h=s.redMul(f),b=o.redMul(d),y=s.redMul(d),S=f.redMul(o);return this.curve.point(h,b,S,y)};Ge.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,d,h;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(d=this.z.redSqr(),h=b.redSub(d).redISub(d),n=e.redSub(t).redISub(i).redMul(h),s=b.redMul(f.redSub(i)),o=b.redMul(h))}else f=t.redAdd(i),d=this.curve._mulC(this.z).redSqr(),h=f.redSub(d).redSub(d),n=this.curve._mulC(e.redISub(f)).redMul(h),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(h);return this.curve.point(n,s,o)};Ge.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ge.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),d=s.redAdd(n),h=i.redAdd(t),b=o.redMul(f),y=d.redMul(h),S=o.redMul(h),I=f.redMul(d);return this.curve.point(b,y,I,S)};Ge.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),d=i.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(h),y,S;return this.curve.twisted?(y=t.redMul(d).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(d)):(y=t.redMul(d).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(d)),this.curve.point(b,y,S)};Ge.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ge.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ge.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ge.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ge.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ge.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ge.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ge.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ge.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ge.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ge.prototype.toP=Ge.prototype.normalize;Ge.prototype.mixedAdd=Ge.prototype.add});var du=Z(Pg=>{"use strict";var bf=Pg;bf.base=yo();bf.short=Sg();bf.mont=Ag();bf.edwards=Dg()});var Cg=Z((WR,Ng)=>{Ng.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var vf=Z(Fg=>{"use strict";var pu=Fg,qi=lo(),lu=du(),h4=Bt(),Og=h4.assert;function Lg(r){r.type==="short"?this.curve=new lu.short(r):r.type==="edwards"?this.curve=new lu.edwards(r):this.curve=new lu.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,Og(this.g.validate(),"Invalid curve"),Og(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}pu.PresetCurve=Lg;function Ui(r,e){Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,get:function(){var t=new Lg(e);return Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,value:t}),t}})}Ui("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:qi.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});Ui("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:qi.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});Ui("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:qi.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});Ui("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:qi.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});Ui("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:qi.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});Ui("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:qi.sha256,gRed:!1,g:["9"]});Ui("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:qi.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var gu;try{gu=Cg()}catch{gu=void 0}Ui("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:qi.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",gu]})});var zg=Z((YR,Ug)=>{"use strict";var u4=lo(),En=ou(),qg=Di();function zi(r){if(!(this instanceof zi))return new zi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=En.toArray(r.entropy,r.entropyEnc||"hex"),t=En.toArray(r.nonce,r.nonceEnc||"hex"),i=En.toArray(r.pers,r.persEnc||"hex");qg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}Ug.exports=zi;zi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};zi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=En.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var d4=Jr(),l4=Bt(),bu=l4.assert;function St(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}Bg.exports=St;St.fromPublic=function(e,t,i){return t instanceof St?t:new St(e,{pub:t,pubEnc:i})};St.fromPrivate=function(e,t,i){return t instanceof St?t:new St(e,{priv:t,privEnc:i})};St.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};St.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};St.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};St.prototype._importPrivate=function(e,t){this.priv=new d4(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};St.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?bu(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&bu(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};St.prototype.derive=function(e){return e.validate()||bu(e.validate(),"public point not validated"),e.mul(this.priv).getX()};St.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};St.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};St.prototype.inspect=function(){return""}});var Vg=Z((ZR,jg)=>{"use strict";var mf=Jr(),yu=Bt(),p4=yu.assert;function yf(r,e){if(r instanceof yf)return r;this._importDER(r,e)||(p4(r.r&&r.s,"Signature without r or s"),this.r=new mf(r.r,16),this.s=new mf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}jg.exports=yf;function g4(){this.place=0}function vu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Kg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}yf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Kg(t),i=Kg(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];mu(n,t.length),n=n.concat(t),n.push(2),mu(n,i.length);var s=n.concat(i),o=[48];return mu(o,s.length),o=o.concat(s),yu.encode(o,e)}});var Wg=Z((QR,Gg)=>{"use strict";var Sn=Jr(),$g=zg(),b4=Bt(),wu=vf(),v4=hu(),Hg=b4.assert,_u=kg(),wf=Vg();function tr(r){if(!(this instanceof tr))return new tr(r);typeof r=="string"&&(Hg(Object.prototype.hasOwnProperty.call(wu,r),"Unknown curve "+r),r=wu[r]),r instanceof wu.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}Gg.exports=tr;tr.prototype.keyPair=function(e){return new _u(this,e)};tr.prototype.keyFromPrivate=function(e,t){return _u.fromPrivate(this,e,t)};tr.prototype.keyFromPublic=function(e,t){return _u.fromPublic(this,e,t)};tr.prototype.genKeyPair=function(e){e||(e={});for(var t=new $g({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Sn(2));;){var s=new Sn(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};tr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};tr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Sn(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),d=new $g({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new Sn(1)),b=0;;b++){var y=n.k?n.k(b):new Sn(d.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var C=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),C^=1),new wf({r:M,s:T,recoveryParam:C})}}}}}};tr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Sn(e,16)),i=this.keyFromPublic(i,n),t=new wf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),d=f.mul(e).umod(this.n),h=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};tr.prototype.recoverPubKey=function(r,e,t,i){Hg((3&t)===t,"The recovery param is more than two bits"),e=new wf(e,i);var n=this.n,s=new Sn(r),o=e.r,f=e.s,d=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),d):o=this.curve.pointFromX(o,d);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};tr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new wf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Zg=Z((eT,Xg)=>{"use strict";var wo=Bt(),Yg=wo.assert,Jg=wo.parseBytes,vs=wo.cachedProperty;function ut(r,e){this.eddsa=r,this._secret=Jg(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Jg(e.pub)}ut.fromPublic=function(e,t){return t instanceof ut?t:new ut(e,{pub:t})};ut.fromSecret=function(e,t){return t instanceof ut?t:new ut(e,{secret:t})};ut.prototype.secret=function(){return this._secret};vs(ut,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});vs(ut,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});vs(ut,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});vs(ut,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});vs(ut,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});vs(ut,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});ut.prototype.sign=function(e){return Yg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};ut.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};ut.prototype.getSecret=function(e){return Yg(this._secret,"KeyPair is public only"),wo.encode(this.secret(),e)};ut.prototype.getPublic=function(e){return wo.encode(this.pubBytes(),e)};Xg.exports=ut});var tb=Z((tT,eb)=>{"use strict";var m4=Jr(),_f=Bt(),Qg=_f.assert,xf=_f.cachedProperty,y4=_f.parseBytes;function In(r,e){this.eddsa=r,typeof e!="object"&&(e=y4(e)),Array.isArray(e)&&(Qg(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Qg(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof m4&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}xf(In,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});xf(In,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});xf(In,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});xf(In,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});In.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};In.prototype.toHex=function(){return _f.encode(this.toBytes(),"hex").toUpperCase()};eb.exports=In});var ob=Z((rT,sb)=>{"use strict";var w4=lo(),_4=vf(),ms=Bt(),x4=ms.assert,ib=ms.parseBytes,nb=Zg(),rb=tb();function Lt(r){if(x4(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Lt))return new Lt(r);r=_4[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=w4.sha512}sb.exports=Lt;Lt.prototype.sign=function(e,t){e=ib(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),d=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:d,Rencoded:o})};Lt.prototype.verify=function(e,t,i){if(e=ib(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Lt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Mn=ab;Mn.version=bg().version;Mn.utils=Bt();Mn.rand=hu();Mn.curve=du();Mn.curves=vf();Mn.ec=Wg();Mn.eddsa=ob()});var vv=Z(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0});Vi.isBrowserCryptoAvailable=Vi.getSubtleCrypto=Vi.getBrowerCrypto=void 0;function Wu(){return window?.crypto||window?.msCrypto||{}}Vi.getBrowerCrypto=Wu;function bv(){let r=Wu();return r.subtle||r.webkitSubtle}Vi.getSubtleCrypto=bv;function U_(){return!!Wu()&&!!bv()}Vi.isBrowserCryptoAvailable=U_});var wv=Z($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isBrowser=$i.isNode=$i.isReactNative=void 0;function mv(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}$i.isReactNative=mv;function yv(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}$i.isNode=yv;function z_(){return!mv()&&!yv()}$i.isBrowser=z_});var Ju=Z(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});var _v=(zn(),qs(Un));_v.__exportStar(vv(),Lf);_v.__exportStar(wv(),Lf)});var Rv=Z((UT,Av)=>{"use strict";Av.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var dm=Z((qo,Ns)=>{var X_=200,cd="__lodash_hash_undefined__",Jf=1,jv=2,Vv=9007199254740991,Kf="[object Arguments]",rd="[object Array]",Z_="[object AsyncFunction]",$v="[object Boolean]",Hv="[object Date]",Gv="[object Error]",Wv="[object Function]",Q_="[object GeneratorFunction]",jf="[object Map]",Jv="[object Number]",ex="[object Null]",Ps="[object Object]",Nv="[object Promise]",tx="[object Proxy]",Yv="[object RegExp]",Vf="[object Set]",Xv="[object String]",rx="[object Symbol]",ix="[object Undefined]",id="[object WeakMap]",Zv="[object ArrayBuffer]",$f="[object DataView]",nx="[object Float32Array]",sx="[object Float64Array]",ox="[object Int8Array]",ax="[object Int16Array]",fx="[object Int32Array]",cx="[object Uint8Array]",hx="[object Uint8ClampedArray]",ux="[object Uint16Array]",dx="[object Uint32Array]",lx=/[\\^$.*+?()[\]{}|]/g,px=/^\[object .+?Constructor\]$/,gx=/^(?:0|[1-9]\d*)$/,Je={};Je[nx]=Je[sx]=Je[ox]=Je[ax]=Je[fx]=Je[cx]=Je[hx]=Je[ux]=Je[dx]=!0;Je[Kf]=Je[rd]=Je[Zv]=Je[$v]=Je[$f]=Je[Hv]=Je[Gv]=Je[Wv]=Je[jf]=Je[Jv]=Je[Ps]=Je[Yv]=Je[Vf]=Je[Xv]=Je[id]=!1;var Qv=typeof window=="object"&&window&&window.Object===Object&&window,bx=typeof self=="object"&&self&&self.Object===Object&&self,_i=Qv||bx||Function("return this")(),em=typeof qo=="object"&&qo&&!qo.nodeType&&qo,Cv=em&&typeof Ns=="object"&&Ns&&!Ns.nodeType&&Ns,tm=Cv&&Cv.exports===em,Qu=tm&&Qv.process,Ov=function(){try{return Qu&&Qu.binding&&Qu.binding("util")}catch{}}(),Lv=Ov&&Ov.isTypedArray;function vx(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function Gx(r,e){var t=this.__data__,i=Xf(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}xi.prototype.clear=jx;xi.prototype.delete=Vx;xi.prototype.get=$x;xi.prototype.has=Hx;xi.prototype.set=Gx;function On(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var h=s.get(r);if(h&&s.get(e))return h==e;var b=-1,y=!0,S=t&jv?new Gf:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=Vv}function hm(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function Bo(r){return r!=null&&typeof r=="object"}var um=Lv?_x(Lv):hE;function SE(r){return xE(r)?oE(r):uE(r)}function IE(){return[]}function ME(){return!1}Ns.exports=EE});var Ei=qe(hn());var Pl=qe(hn()),sa=qe(jn());var sr=class{};var mc=class extends sr{constructor(e){super()}},Dl=sa.FIVE_SECONDS,un={pulse:"heartbeat_pulse"},na=class r extends mc{constructor(e){super(e),this.events=new Pl.EventEmitter,this.interval=Dl,this.interval=e?.interval||Dl}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,sa.toMiliseconds)(this.interval))}pulse(){this.events.emit(un.pulse)}};var r2=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,i2=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n2=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function s2(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){o2(r);return}return e}function o2(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Bs(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!n2.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(r2.test(r)||i2.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,s2)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function a2(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ot(r,...e){try{return a2(r(...e))}catch(t){return Promise.reject(t)}}function f2(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function c2(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ks(r){if(f2(r))return String(r);if(c2(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ks(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Nl(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var yc="base64:";function Cl(r){if(typeof r=="string")return r;Nl();let e=Buffer.from(r).toString("base64");return yc+e}function Ol(r){return typeof r!="string"||!r.startsWith(yc)?r:(Nl(),Buffer.from(r.slice(yc.length),"base64"))}function Pt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Ll(...r){return Pt(r.join(":"))}function Ks(r){return r=Pt(r),r?r+":":""}var h2="memory",u2=()=>{let r=new Map;return{name:h2,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Ul(r={}){let e={mounts:{"":r.driver||u2()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=h=>{for(let b of e.mountpoints)if(h.startsWith(b))return{base:b,relativeKey:h.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,b)=>e.mountpoints.filter(y=>y.startsWith(h)||b&&h.startsWith(y)).map(y=>({relativeBase:h.length>y.length?h.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(h,b)=>{if(e.watching){b=Pt(b);for(let y of e.watchListeners)y(h,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let h in e.mounts)e.unwatch[h]=await Fl(e.mounts[h],n,h)}},o=async()=>{if(e.watching){for(let h in e.unwatch)await e.unwatch[h]();e.unwatch={},e.watching=!1}},f=(h,b,y)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of h){let T=typeof M=="string",C=Pt(T?M:M.key),P=T?void 0:M.value,U=T||!M.options?b:{...b,...M.options},B=t(C);I(B).items.push({key:C,value:P,relativeKey:B.relativeKey,options:U})}return Promise.all([...S.values()].map(M=>y(M))).then(M=>M.flat())},d={hasItem(h,b={}){h=Pt(h);let{relativeKey:y,driver:S}=t(h);return ot(S.hasItem,y,b)},getItem(h,b={}){h=Pt(h);let{relativeKey:y,driver:S}=t(h);return ot(S.getItem,y,b).then(I=>Bs(I))},getItems(h,b){return f(h,b,y=>y.driver.getItems?ot(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:Ll(y.base,I.key),value:Bs(I.value)}))):Promise.all(y.items.map(S=>ot(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Bs(I)})))))},getItemRaw(h,b={}){h=Pt(h);let{relativeKey:y,driver:S}=t(h);return S.getItemRaw?ot(S.getItemRaw,y,b):ot(S.getItem,y,b).then(I=>Ol(I))},async setItem(h,b,y={}){if(b===void 0)return d.removeItem(h);h=Pt(h);let{relativeKey:S,driver:I}=t(h);I.setItem&&(await ot(I.setItem,S,ks(b),y),I.watch||n("update",h))},async setItems(h,b){await f(h,b,async y=>{if(y.driver.setItems)return ot(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:ks(S.value),options:S.options})),b);y.driver.setItem&&await Promise.all(y.items.map(S=>ot(y.driver.setItem,S.relativeKey,ks(S.value),S.options)))})},async setItemRaw(h,b,y={}){if(b===void 0)return d.removeItem(h,y);h=Pt(h);let{relativeKey:S,driver:I}=t(h);if(I.setItemRaw)await ot(I.setItemRaw,S,b,y);else if(I.setItem)await ot(I.setItem,S,Cl(b),y);else return;I.watch||n("update",h)},async removeItem(h,b={}){typeof b=="boolean"&&(b={removeMeta:b}),h=Pt(h);let{relativeKey:y,driver:S}=t(h);S.removeItem&&(await ot(S.removeItem,y,b),(b.removeMeta||b.removeMata)&&await ot(S.removeItem,y+"$",b),S.watch||n("remove",h))},async getMeta(h,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),h=Pt(h);let{relativeKey:y,driver:S}=t(h),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ot(S.getMeta,y,b)),!b.nativeOnly){let M=await ot(S.getItem,y+"$",b).then(T=>Bs(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(h,b,y={}){return this.setItem(h+"$",b,y)},removeMeta(h,b={}){return this.removeItem(h+"$",b)},async getKeys(h,b={}){h=Ks(h);let y=i(h,!0),S=[],I=[];for(let M of y){let T=await ot(M.driver.getKeys,M.relativeBase,b);for(let C of T){let P=M.mountpoint+Pt(C);S.some(U=>P.startsWith(U))||I.push(P)}S=[M.mountpoint,...S.filter(C=>!C.startsWith(M.mountpoint))]}return h?I.filter(M=>M.startsWith(h)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(h,b={}){h=Ks(h),await Promise.all(i(h,!1).map(async y=>{if(y.driver.clear)return ot(y.driver.clear,y.relativeBase,b);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",b);return Promise.all(S.map(I=>y.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>ql(h)))},async watch(h){return await s(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,b){if(h=Ks(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[h]=b,e.watching&&Promise.resolve(Fl(b,n,h)).then(y=>{e.unwatch[h]=y}).catch(console.error),d},async unmount(h,b=!0){h=Ks(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),b&&await ql(e.mounts[h]),e.mountpoints=e.mountpoints.filter(y=>y!==h),delete e.mounts[h])},getMount(h=""){h=Pt(h)+":";let b=t(h);return{driver:b.driver,base:b.base}},getMounts(h="",b={}){return h=Pt(h),i(h,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(h,b={})=>d.getKeys(h,b),get:(h,b={})=>d.getItem(h,b),set:(h,b,y={})=>d.setItem(h,b,y),has:(h,b={})=>d.hasItem(h,b),del:(h,b={})=>d.removeItem(h,b),remove:(h,b={})=>d.removeItem(h,b)};return d}function Fl(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ql(r){typeof r.dispose=="function"&&await ot(r.dispose)}function dn(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function _c(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=dn(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var wc;function js(){return wc||(wc=_c("keyval-store","keyval")),wc}function xc(r,e=js()){return e("readonly",t=>dn(t.get(r)))}function zl(r,e,t=js()){return t("readwrite",i=>(i.put(e,r),dn(i.transaction)))}function Bl(r,e=js()){return e("readwrite",t=>(t.delete(r),dn(t.transaction)))}function kl(r=js()){return r("readwrite",e=>(e.clear(),dn(e.transaction)))}function d2(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},dn(r.transaction)}function Kl(r=js()){return r("readonly",e=>{if(e.getAllKeys)return dn(e.getAllKeys());let t=[];return d2(e,i=>t.push(i.key)).then(()=>t)})}var l2=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),p2=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Fr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return p2(r)}catch{return r}}function Wt(r){return typeof r=="string"?r:l2(r)||""}var g2="idb-keyval",b2=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=_c(r.dbName,r.storeName)),{name:g2,options:r,async hasItem(n){return!(typeof await xc(t(n),i)>"u")},async getItem(n){return await xc(t(n),i)??null},setItem(n,s){return zl(t(n),s,i)},removeItem(n){return Bl(t(n),i)},getKeys(){return Kl(i)},clear(){return kl(i)}}},v2="WALLET_CONNECT_V2_INDEXED_DB",m2="keyvaluestorage",Sc=class{constructor(){this.indexedDb=Ul({driver:b2({dbName:v2,storeName:m2})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Wt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},Ec=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},oa={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ec<"u"&&Ec.localStorage?oa.exports=Ec.localStorage:typeof window<"u"&&window.localStorage?oa.exports=window.localStorage:oa.exports=new e})();function y2(r){var e;return[r[0],Fr((e=r[1])!=null?e:"")]}var Ic=class{constructor(){this.localStorage=oa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(y2)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Fr(t)}async setItem(e,t){this.localStorage.setItem(e,Wt(t))}async removeItem(e){this.localStorage.removeItem(e)}},w2="wc_storage_version",jl=1,_2=async(r,e,t)=>{let i=w2,n=await e.getItem(i);if(n&&n>=jl){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let d=f.toLowerCase();if(d.includes("wc@")||d.includes("walletconnect")||d.includes("wc_")||d.includes("wallet_connect")){let h=await r.getItem(f);await e.setItem(f,h),o.push(f)}}await e.setItem(i,jl),t(e),x2(r,o)},x2=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},aa=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new Ic;this.storage=e;try{let t=new Sc;_2(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var ai=qe(Rc()),Hs=qe(Rc());var L2={level:"info"},Gs="custom_context",Nc=1e3*1024,Tc=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ha=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Tc(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},ua=class{constructor(e,t=Nc){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===ai.levels.values.error?console.error(e):t===ai.levels.values.warn?console.warn(e):t===ai.levels.values.debug?console.debug(e):t===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Wt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Wt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Dc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Pc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},F2=Object.defineProperty,q2=Object.defineProperties,U2=Object.getOwnPropertyDescriptors,Yl=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,B2=Object.prototype.propertyIsEnumerable,Xl=(r,e,t)=>e in r?F2(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e)=>{for(var t in e||(e={}))z2.call(e,t)&&Xl(r,t,e[t]);if(Yl)for(var t of Yl(e))B2.call(e,t)&&Xl(r,t,e[t]);return r},la=(r,e)=>q2(r,U2(e));function Ws(r){return la(da({},r),{level:r?.level||L2.level})}function k2(r,e=Gs){return r[e]||""}function K2(r,e,t=Gs){return r[t]=e,r}function yt(r,e=Gs){let t="";return typeof r.bindings>"u"?t=k2(r,e):t=r.bindings().context||"",t}function j2(r,e,t=Gs){let i=yt(r,t);return i.trim()?`${i}/${e}`:e}function lt(r,e,t=Gs){let i=j2(r,e,t),n=r.child({context:i});return K2(n,i,t)}function V2(r){var e,t;let i=new Dc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace",browser:la(da({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function $2(r){var e;let t=new Pc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Zl(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?V2(r):$2(r)}var Ql=qe(hn()),pa=class extends sr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var ga=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},ba=class{constructor(e,t){this.logger=e,this.core=t}},va=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}},ma=class extends sr{constructor(e){super()}},ya=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var wa=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}};var _a=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t}};var xa=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Ea=class{constructor(e,t){this.projectId=e,this.logger=t}},Sa=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Ia=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Ma=class{constructor(e){this.client=e}};var re=qe(jn());var so=qe(T0()),op=qe(Js()),ap=qe(jn());var D0="EdDSA",P0="JWT",Zs=".",Qs="base64url",Xc="utf8",Zc="utf8",N0=":",C0="did",O0="key",Qc="base58btc",L0="z",F0="K36";function eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function bn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var nh={};Dt(nh,{identity:()=>$3});function B3(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,z=new Uint8Array(B);P!==U;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,z[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");C=H,P++}for(var O=B-C;O!==B&&z[O]===0;)O++;for(var W=d.repeat(T);O>>0,B=new Uint8Array(U);M[T];){var z=t[M.charCodeAt(T)];if(z===255)return;for(var j=0,H=U-1;(z!==0||j>>0,B[H]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=U-P;L!==U&&B[L]===0;)L++;for(var O=new Uint8Array(C+(U-L)),W=C;L!==U;)O[W++]=B[L++];return O}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var k3=B3,K3=k3,q0=K3;var FI=new Uint8Array(0);var U0=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var z0=r=>new TextEncoder().encode(r),B0=r=>new TextDecoder().decode(r);var eh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},th=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K0(this,e)}},rh=class{constructor(e){this.decoders=e}or(e){return K0(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},K0=(r,e)=>new rh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ih=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,t,i),this.decoder=new th(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Yn=({name:r,prefix:e,encode:t,decode:i})=>new ih(r,e,t,i),Ri=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=q0(t,e);return Yn({prefix:r,name:e,encode:i,decode:s=>ci(n(s))})},j3=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[h++]=255&d>>f)}if(f>=t||255&d<<8-f)throw new SyntaxError("Unexpected end of data");return o},V3=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Yn({prefix:e,name:r,encode(n){return V3(n,i,t)},decode(n){return j3(n,i,t,r)}});var $3=Yn({prefix:"\0",name:"identity",encode:r=>B0(r),decode:r=>z0(r)});var sh={};Dt(sh,{base2:()=>H3});var H3=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oh={};Dt(oh,{base8:()=>G3});var G3=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah={};Dt(ah,{base10:()=>W3});var W3=Ri({prefix:"9",name:"base10",alphabet:"0123456789"});var fh={};Dt(fh,{base16:()=>J3,base16upper:()=>Y3});var J3=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y3=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ch={};Dt(ch,{base32:()=>Xn,base32hex:()=>e6,base32hexpad:()=>r6,base32hexpadupper:()=>i6,base32hexupper:()=>t6,base32pad:()=>Z3,base32padupper:()=>Q3,base32upper:()=>X3,base32z:()=>n6});var Xn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X3=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z3=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q3=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hh={};Dt(hh,{base36:()=>s6,base36upper:()=>o6});var s6=Ri({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o6=Ri({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uh={};Dt(uh,{base58btc:()=>Ur,base58flickr:()=>a6});var Ur=Ri({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),a6=Ri({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh={};Dt(dh,{base64:()=>f6,base64pad:()=>c6,base64url:()=>h6,base64urlpad:()=>u6});var f6=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),u6=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lh={};Dt(lh,{base256emoji:()=>b6});var j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),d6=j0.reduce((r,e,t)=>(r[t]=e,r),[]),l6=j0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function p6(r){return r.reduce((e,t)=>(e+=d6[t],e),"")}function g6(r){let e=[];for(let t of r){let i=l6[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var b6=Yn({prefix:"\u{1F680}",name:"base256emoji",encode:p6,decode:g6});var vh={};Dt(vh,{sha256:()=>L6,sha512:()=>F6});var v6=H0,V0=128,m6=127,y6=~m6,w6=Math.pow(2,31);function H0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=w6;)e[t++]=r&255|V0,r/=128;for(;r&y6;)e[t++]=r&255|V0,r>>>=7;return e[t]=r|0,H0.bytes=t-i+1,e}var _6=ph,x6=128,$0=127;function ph(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw ph.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&$0)<=x6);return ph.bytes=s-i,t}var E6=Math.pow(2,7),S6=Math.pow(2,14),I6=Math.pow(2,21),M6=Math.pow(2,28),A6=Math.pow(2,35),R6=Math.pow(2,42),T6=Math.pow(2,49),D6=Math.pow(2,56),P6=Math.pow(2,63),N6=function(r){return r[to.decode(r,e),to.decode.bytes],Zn=(r,e,t=0)=>(to.encode(r,e,t),e),Qn=r=>to.encodingLength(r);var vn=(r,e)=>{let t=e.byteLength,i=Qn(r),n=i+Qn(t),s=new Uint8Array(n+t);return Zn(r,s,0),Zn(t,s,i),s.set(e,n),new es(r,t,e,s)},G0=r=>{let e=ci(r),[t,i]=ro(e),[n,s]=ro(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new es(t,n,o,e)},W0=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&U0(r.bytes,e.bytes),es=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var bh=({name:r,code:e,encode:t})=>new gh(r,e,t),gh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?vn(this.code,t):t.then(i=>vn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var Y0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),L6=bh({name:"sha2-256",code:18,encode:Y0("SHA-256")}),F6=bh({name:"sha2-512",code:19,encode:Y0("SHA-512")});var mh={};Dt(mh,{identity:()=>z6});var X0=0,q6="identity",Z0=ci,U6=r=>vn(X0,Z0(r)),z6={code:X0,name:q6,encode:Z0,digest:U6};var iM=new TextEncoder,nM=new TextDecoder;var La=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oa,byteLength:Oa,code:Ca,version:Ca,multihash:Ca,bytes:Ca,_baseCache:Oa,asCID:Oa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==no)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=vn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&W0(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return j6(t,n,e||Ur.encoder);default:return V6(t,n,e||Xn.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return G6(/^0\.0/,W6),!!(e&&(e[ep]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||Q0(t,i,n.bytes))}else if(e!=null&&e[ep]===!0){let{version:t,multihash:i,code:n}=e,s=G0(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==no)throw new Error(`Version 0 CID must use dag-pb (code: ${no}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Q0(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,no,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=ci(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new es(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=ro(e.subarray(t));return t+=S,y},n=i(),s=no;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),d=i(),h=t+d,b=h-o;return{version:n,codec:s,multihashCode:f,digestSize:d,multihashSize:b,size:h}}static parse(e,t){let[i,n]=K6(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},K6=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ur;return[Ur.prefix,t.decode(`${Ur.prefix}${r}`)]}case Ur.prefix:{let t=e||Ur;return[Ur.prefix,t.decode(r)]}case Xn.prefix:{let t=e||Xn;return[Xn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},j6=(r,e,t)=>{let{prefix:i}=t;if(i!==Ur.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},V6=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},no=112,$6=18,Q0=(r,e,t)=>{let i=Qn(r),n=i+Qn(e),s=new Uint8Array(n+t.byteLength);return Zn(r,s,0),Zn(e,s,i),s.set(t,n),s},ep=Symbol.for("@ipld/js-cid/CID"),Ca={writable:!1,configurable:!1,enumerable:!0},Oa={writable:!1,enumerable:!1,configurable:!1},H6="0.0.0-dev",G6=(r,e)=>{if(r.test(H6))console.warn(e);else throw new Error(e)},W6=`CID.isCID(v) is deprecated and will be removed in the next major release. Following code pattern: if (CID.isCID(value)) { @@ -20,18 +20,34 @@ if (cid) { // Make sure to use cid instead of value doSomethingWithCID(cid) } -`});var wd=P(()=>{yd();$n();Ut();nc();pi()});var cc,L3,bd=P(()=>{Hl();Gl();Wl();Jl();Yl();Ya();Xl();Za();Ql();ed();ud();dd();fd();pd();wd();cc={...ja,...$a,...Ha,...Ga,...Wa,...Ja,...Xa,...Qa,...ec,...tc},L3={...oc,...ac}});function _d(i,e,r,t){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:r},decoder:{decode:t}}}var Ed,uc,eb,Jn,hc=P(()=>{bd();Kn();Ed=_d("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),uc=_d("ascii","a",i=>{let e="a";for(let r=0;r{i=i.substring(1);let e=hi(i.length);for(let r=0;r{hc()});function _e(i,e="utf8"){let r=Jn[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(i,"utf8"):r.decoder.decode(`${r.prefix}${i}`)}var dc=P(()=>{hc()});function vd(i){return ut(we(_e(i,ui),Ma))}function Yn(i){return we(_e($e(i),Ma),ui)}function Xn(i){let e=_e(kl,ka),r=Fl+we(ir([e,i]),ka);return[Ul,Ml,r].join(Ll)}function tb(i){return we(i,ui)}function rb(i){return _e(i,ui)}function xd(i){return _e([Yn(i.header),Yn(i.payload)].join(ci),Fa)}function Sd(i){return[Yn(i.header),Yn(i.payload),tb(i.signature)].join(ci)}function Lr(i){let e=i.split(ci),r=vd(e[0]),t=vd(e[1]),s=rb(e[2]),n=_e(e.slice(0,2).join(ci),Fa);return{header:r,payload:t,signature:s,data:n}}var fc=P(()=>{Ba();lc();dc();Sr();Vn()});function pc(i=(0,Id.randomBytes)(32)){return mi.generateKeyPairFromSeed(i)}async function Td(i,e,r,t,s=(0,Dd.fromMiliseconds)(Date.now())){let n={alg:Ol,typ:Pl},o=Xn(t.publicKey),a=s+r,c={iss:o,sub:i,aud:e,iat:s,exp:a},h=xd({header:n,payload:c}),d=mi.sign(t.secretKey,h);return Sd({header:n,payload:c,signature:d})}var mi,Id,Dd,Rd=P(()=>{mi=pe(Al()),Id=pe(ni()),Dd=pe(xr());Vn();fc()});var Cd=P(()=>{});var Qn=P(()=>{Rd();Vn();Cd();fc()});function Ld(i){return i?Pd(i):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ub:typeof navigator<"u"?Pd(navigator.userAgent):gb()}function fb(i){return i!==""&&db.reduce(function(e,r){var t=r[0],s=r[1];if(e)return e;var n=s.exec(i);return!!n&&[t,n]},!1)}function Pd(i){var e=fb(i);if(!e)return null;var r=e[0],t=e[1];if(r==="searchbot")return new cb;var s=t[1]&&t[1].split(".").join("_").split("_").slice(0,3);s?s.length{Nd=function(i,e,r){if(r||arguments.length===2)for(var t=0,s=e.length,n;t{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.getLocalStorage=fe.getLocalStorageOrThrow=fe.getCrypto=fe.getCryptoOrThrow=fe.getLocation=fe.getLocationOrThrow=fe.getNavigator=fe.getNavigatorOrThrow=fe.getDocument=fe.getDocumentOrThrow=fe.getFromWindowOrThrow=fe.getFromWindow=void 0;function nr(i){let e;return typeof window<"u"&&typeof window[i]<"u"&&(e=window[i]),e}fe.getFromWindow=nr;function Ur(i){let e=nr(i);if(!e)throw new Error(`${i} is not defined in Window`);return e}fe.getFromWindowOrThrow=Ur;function yb(){return Ur("document")}fe.getDocumentOrThrow=yb;function wb(){return nr("document")}fe.getDocument=wb;function bb(){return Ur("navigator")}fe.getNavigatorOrThrow=bb;function Eb(){return nr("navigator")}fe.getNavigator=Eb;function _b(){return Ur("location")}fe.getLocationOrThrow=_b;function vb(){return nr("location")}fe.getLocation=vb;function xb(){return Ur("crypto")}fe.getCryptoOrThrow=xb;function Sb(){return nr("crypto")}fe.getCrypto=Sb;function Ib(){return Ur("localStorage")}fe.getLocalStorageOrThrow=Ib;function Db(){return nr("localStorage")}fe.getLocalStorage=Db});var Fd=oe(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.getWindowMetadata=void 0;var Md=Zn();function Tb(){let i,e;try{i=Md.getDocumentOrThrow(),e=Md.getLocationOrThrow()}catch{return null}function r(){let l=i.getElementsByTagName("link"),p=[];for(let f=0;f-1){let b=g.getAttribute("href");if(b)if(b.toLowerCase().indexOf("https:")===-1&&b.toLowerCase().indexOf("http:")===-1&&b.indexOf("//")!==0){let v=e.protocol+"//"+e.host;if(b.indexOf("/")===0)v+=b;else{let x=e.pathname.split("/");x.pop();let I=x.join("/");v+=I+"/"+b}p.push(v)}else if(b.indexOf("//")===0){let v=e.protocol+b;p.push(v)}else p.push(b)}}return p}function t(...l){let p=i.getElementsByTagName("meta");for(let f=0;fg.getAttribute(b)).filter(b=>b?l.includes(b):!1);if(w.length&&w){let b=g.getAttribute("content");if(b)return b}}return""}function s(){let l=t("name","og:site_name","og:title","twitter:title");return l||(l=i.title),l}function n(){return t("description","og:description","twitter:description","keywords")}let o=s(),a=n(),c=e.origin,h=r();return{description:a,url:c,icons:h,name:o}}eo.getWindowMetadata=Tb});function gc(i){let e=new URLSearchParams(i),r={};for(let[t,s]of e.entries())r[t]=s;return r}function mc(i){let e=new URLSearchParams;for(let r in i)i[r]!=null&&e.append(r,i[r]);return e.toString()}var kd=P(()=>{});var Bd=oe((aS,to)=>{(function(){"use strict";var i="input is invalid type",e="finalize already called",r=typeof window=="object",t=r?window:{};t.JS_SHA3_NO_WINDOW&&(r=!1);var s=!r&&typeof self=="object",n=!t.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;n?t=window:s&&(t=self);var o=!t.JS_SHA3_NO_COMMON_JS&&typeof to=="object"&&to.exports,a=typeof define=="function"&&define.amd,c=!t.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),d=[31,7936,2031616,520093696],l=[4,1024,262144,67108864],p=[1,256,65536,16777216],f=[6,1536,393216,100663296],g=[0,8,16,24],w=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],b=[224,256,384,512],v=[128,256],x=["hex","buffer","arrayBuffer","array","digest"],I={128:168,256:136};(t.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(u){return Object.prototype.toString.call(u)==="[object Array]"}),c&&(t.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(u){return typeof u=="object"&&u.buffer&&u.buffer.constructor===ArrayBuffer});for(var S=function(u,E,_){return function(D){return new V(u,E,u).update(D)[_]()}},T=function(u,E,_){return function(D,A){return new V(u,E,A).update(D)[_]()}},L=function(u,E,_){return function(D,A,U,F){return N["cshake"+u].update(D,A,U,F)[_]()}},y=function(u,E,_){return function(D,A,U,F){return N["kmac"+u].update(D,A,U,F)[_]()}},m=function(u,E,_,D){for(var A=0;A>5,this.byteCount=this.blockCount<<2,this.outputBlocks=_>>5,this.extraBytes=(_&31)>>3;for(var D=0;D<50;++D)this.s[D]=0}V.prototype.update=function(u){if(this.finalized)throw new Error(e);var E,_=typeof u;if(_!=="string"){if(_==="object"){if(u===null)throw new Error(i);if(c&&u.constructor===ArrayBuffer)u=new Uint8Array(u);else if(!Array.isArray(u)&&(!c||!ArrayBuffer.isView(u)))throw new Error(i)}else throw new Error(i);E=!0}for(var D=this.blocks,A=this.byteCount,U=u.length,F=this.blockCount,M=0,Q=this.s,z,ee;M>2]|=u[M]<>2]|=ee<>2]|=(192|ee>>6)<>2]|=(128|ee&63)<=57344?(D[z>>2]|=(224|ee>>12)<>2]|=(128|ee>>6&63)<>2]|=(128|ee&63)<>2]|=(240|ee>>18)<>2]|=(128|ee>>12&63)<>2]|=(128|ee>>6&63)<>2]|=(128|ee&63)<=A){for(this.start=z-A,this.block=D[F],z=0;z>8,_=u&255;_>0;)A.unshift(_),u=u>>8,_=u&255,++D;return E?A.push(D):A.unshift(D),this.update(A),A.length},V.prototype.encodeString=function(u){var E,_=typeof u;if(_!=="string"){if(_==="object"){if(u===null)throw new Error(i);if(c&&u.constructor===ArrayBuffer)u=new Uint8Array(u);else if(!Array.isArray(u)&&(!c||!ArrayBuffer.isView(u)))throw new Error(i)}else throw new Error(i);E=!0}var D=0,A=u.length;if(E)D=A;else for(var U=0;U=57344?D+=3:(F=65536+((F&1023)<<10|u.charCodeAt(++U)&1023),D+=4)}return D+=this.encode(D*8),this.update(u),D},V.prototype.bytepad=function(u,E){for(var _=this.encode(E),D=0;D>2]|=this.padding[E&3],this.lastByteIndex===this.byteCount)for(u[0]=u[_],E=1;E<_+1;++E)u[E]=0;for(u[_-1]|=2147483648,E=0;E<_;++E)D[E]^=u[E];X(D)}},V.prototype.toString=V.prototype.hex=function(){this.finalize();for(var u=this.blockCount,E=this.s,_=this.outputBlocks,D=this.extraBytes,A=0,U=0,F="",M;U<_;){for(A=0;A>4&15]+h[M&15]+h[M>>12&15]+h[M>>8&15]+h[M>>20&15]+h[M>>16&15]+h[M>>28&15]+h[M>>24&15];U%u===0&&(X(E),A=0)}return D&&(M=E[A],F+=h[M>>4&15]+h[M&15],D>1&&(F+=h[M>>12&15]+h[M>>8&15]),D>2&&(F+=h[M>>20&15]+h[M>>16&15])),F},V.prototype.arrayBuffer=function(){this.finalize();var u=this.blockCount,E=this.s,_=this.outputBlocks,D=this.extraBytes,A=0,U=0,F=this.outputBits>>3,M;D?M=new ArrayBuffer(_+1<<2):M=new ArrayBuffer(F);for(var Q=new Uint32Array(M);U<_;){for(A=0;A>8&255,F[M+2]=Q>>16&255,F[M+3]=Q>>24&255;U%u===0&&X(E)}return D&&(M=U<<2,Q=E[A],F[M]=Q&255,D>1&&(F[M+1]=Q>>8&255),D>2&&(F[M+2]=Q>>16&255)),F};function J(u,E,_){V.call(this,u,E,_)}J.prototype=new V,J.prototype.finalize=function(){return this.encode(this.outputBits,!0),V.prototype.finalize.call(this)};var X=function(u){var E,_,D,A,U,F,M,Q,z,ee,ns,os,as,cs,us,hs,ls,ds,fs,ps,gs,ms,ys,ws,bs,Es,_s,vs,xs,Ss,Is,Ds,Ts,Rs,Cs,Ns,As,Os,Ps,Ls,Us,Ms,Fs,ks,Bs,qs,zs,Vs,Ks,js,$s,Hs,Gs,Ws,Js,Ys,Xs,Qs,Zs,en,tn,rn,sn;for(D=0;D<48;D+=2)A=u[0]^u[10]^u[20]^u[30]^u[40],U=u[1]^u[11]^u[21]^u[31]^u[41],F=u[2]^u[12]^u[22]^u[32]^u[42],M=u[3]^u[13]^u[23]^u[33]^u[43],Q=u[4]^u[14]^u[24]^u[34]^u[44],z=u[5]^u[15]^u[25]^u[35]^u[45],ee=u[6]^u[16]^u[26]^u[36]^u[46],ns=u[7]^u[17]^u[27]^u[37]^u[47],os=u[8]^u[18]^u[28]^u[38]^u[48],as=u[9]^u[19]^u[29]^u[39]^u[49],E=os^(F<<1|M>>>31),_=as^(M<<1|F>>>31),u[0]^=E,u[1]^=_,u[10]^=E,u[11]^=_,u[20]^=E,u[21]^=_,u[30]^=E,u[31]^=_,u[40]^=E,u[41]^=_,E=A^(Q<<1|z>>>31),_=U^(z<<1|Q>>>31),u[2]^=E,u[3]^=_,u[12]^=E,u[13]^=_,u[22]^=E,u[23]^=_,u[32]^=E,u[33]^=_,u[42]^=E,u[43]^=_,E=F^(ee<<1|ns>>>31),_=M^(ns<<1|ee>>>31),u[4]^=E,u[5]^=_,u[14]^=E,u[15]^=_,u[24]^=E,u[25]^=_,u[34]^=E,u[35]^=_,u[44]^=E,u[45]^=_,E=Q^(os<<1|as>>>31),_=z^(as<<1|os>>>31),u[6]^=E,u[7]^=_,u[16]^=E,u[17]^=_,u[26]^=E,u[27]^=_,u[36]^=E,u[37]^=_,u[46]^=E,u[47]^=_,E=ee^(A<<1|U>>>31),_=ns^(U<<1|A>>>31),u[8]^=E,u[9]^=_,u[18]^=E,u[19]^=_,u[28]^=E,u[29]^=_,u[38]^=E,u[39]^=_,u[48]^=E,u[49]^=_,cs=u[0],us=u[1],qs=u[11]<<4|u[10]>>>28,zs=u[10]<<4|u[11]>>>28,vs=u[20]<<3|u[21]>>>29,xs=u[21]<<3|u[20]>>>29,en=u[31]<<9|u[30]>>>23,tn=u[30]<<9|u[31]>>>23,Ms=u[40]<<18|u[41]>>>14,Fs=u[41]<<18|u[40]>>>14,Rs=u[2]<<1|u[3]>>>31,Cs=u[3]<<1|u[2]>>>31,hs=u[13]<<12|u[12]>>>20,ls=u[12]<<12|u[13]>>>20,Vs=u[22]<<10|u[23]>>>22,Ks=u[23]<<10|u[22]>>>22,Ss=u[33]<<13|u[32]>>>19,Is=u[32]<<13|u[33]>>>19,rn=u[42]<<2|u[43]>>>30,sn=u[43]<<2|u[42]>>>30,Ws=u[5]<<30|u[4]>>>2,Js=u[4]<<30|u[5]>>>2,Ns=u[14]<<6|u[15]>>>26,As=u[15]<<6|u[14]>>>26,ds=u[25]<<11|u[24]>>>21,fs=u[24]<<11|u[25]>>>21,js=u[34]<<15|u[35]>>>17,$s=u[35]<<15|u[34]>>>17,Ds=u[45]<<29|u[44]>>>3,Ts=u[44]<<29|u[45]>>>3,ws=u[6]<<28|u[7]>>>4,bs=u[7]<<28|u[6]>>>4,Ys=u[17]<<23|u[16]>>>9,Xs=u[16]<<23|u[17]>>>9,Os=u[26]<<25|u[27]>>>7,Ps=u[27]<<25|u[26]>>>7,ps=u[36]<<21|u[37]>>>11,gs=u[37]<<21|u[36]>>>11,Hs=u[47]<<24|u[46]>>>8,Gs=u[46]<<24|u[47]>>>8,ks=u[8]<<27|u[9]>>>5,Bs=u[9]<<27|u[8]>>>5,Es=u[18]<<20|u[19]>>>12,_s=u[19]<<20|u[18]>>>12,Qs=u[29]<<7|u[28]>>>25,Zs=u[28]<<7|u[29]>>>25,Ls=u[38]<<8|u[39]>>>24,Us=u[39]<<8|u[38]>>>24,ms=u[48]<<14|u[49]>>>18,ys=u[49]<<14|u[48]>>>18,u[0]=cs^~hs&ds,u[1]=us^~ls&fs,u[10]=ws^~Es&vs,u[11]=bs^~_s&xs,u[20]=Rs^~Ns&Os,u[21]=Cs^~As&Ps,u[30]=ks^~qs&Vs,u[31]=Bs^~zs&Ks,u[40]=Ws^~Ys&Qs,u[41]=Js^~Xs&Zs,u[2]=hs^~ds&ps,u[3]=ls^~fs&gs,u[12]=Es^~vs&Ss,u[13]=_s^~xs&Is,u[22]=Ns^~Os&Ls,u[23]=As^~Ps&Us,u[32]=qs^~Vs&js,u[33]=zs^~Ks&$s,u[42]=Ys^~Qs&en,u[43]=Xs^~Zs&tn,u[4]=ds^~ps&ms,u[5]=fs^~gs&ys,u[14]=vs^~Ss&Ds,u[15]=xs^~Is&Ts,u[24]=Os^~Ls&Ms,u[25]=Ps^~Us&Fs,u[34]=Vs^~js&Hs,u[35]=Ks^~$s&Gs,u[44]=Qs^~en&rn,u[45]=Zs^~tn&sn,u[6]=ps^~ms&cs,u[7]=gs^~ys&us,u[16]=Ss^~Ds&ws,u[17]=Is^~Ts&bs,u[26]=Ls^~Ms&Rs,u[27]=Us^~Fs&Cs,u[36]=js^~Hs&ks,u[37]=$s^~Gs&Bs,u[46]=en^~rn&Ws,u[47]=tn^~sn&Js,u[8]=ms^~cs&hs,u[9]=ys^~us&ls,u[18]=Ds^~ws&Es,u[19]=Ts^~bs&_s,u[28]=Ms^~Rs&Ns,u[29]=Fs^~Cs&As,u[38]=Hs^~ks&qs,u[39]=Gs^~Bs&zs,u[48]=rn^~Ws&Ys,u[49]=sn^~Js&Xs,u[0]^=w[D],u[1]^=w[D+1]};if(o)to.exports=N;else{for(H=0;H{qd="logger/5.7.0"});function Cb(){try{let i=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{i.push(e)}}),i.length)throw new Error("missing "+i.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(i){return i.message}return null}var Vd,Kd,ro,jd,yc,$d,wc,et,Hd,Fe,Mr=P(()=>{"use strict";zd();Vd=!1,Kd=!1,ro={debug:1,default:2,info:2,warning:3,error:4,off:5},jd=ro.default,yc=null;$d=Cb();(function(i){i.DEBUG="DEBUG",i.INFO="INFO",i.WARNING="WARNING",i.ERROR="ERROR",i.OFF="OFF"})(wc||(wc={}));(function(i){i.UNKNOWN_ERROR="UNKNOWN_ERROR",i.NOT_IMPLEMENTED="NOT_IMPLEMENTED",i.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",i.NETWORK_ERROR="NETWORK_ERROR",i.SERVER_ERROR="SERVER_ERROR",i.TIMEOUT="TIMEOUT",i.BUFFER_OVERRUN="BUFFER_OVERRUN",i.NUMERIC_FAULT="NUMERIC_FAULT",i.MISSING_NEW="MISSING_NEW",i.INVALID_ARGUMENT="INVALID_ARGUMENT",i.MISSING_ARGUMENT="MISSING_ARGUMENT",i.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",i.CALL_EXCEPTION="CALL_EXCEPTION",i.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",i.NONCE_EXPIRED="NONCE_EXPIRED",i.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",i.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",i.TRANSACTION_REPLACED="TRANSACTION_REPLACED",i.ACTION_REJECTED="ACTION_REJECTED"})(et||(et={}));Hd="0123456789abcdef",Fe=class i{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,r){let t=e.toLowerCase();ro[t]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(jd>ro[t])&&console.log.apply(console,r)}debug(...e){this._log(i.levels.DEBUG,e)}info(...e){this._log(i.levels.INFO,e)}warn(...e){this._log(i.levels.WARNING,e)}makeError(e,r,t){if(Kd)return this.makeError("censored error",r,{});r||(r=i.errors.UNKNOWN_ERROR),t||(t={});let s=[];Object.keys(t).forEach(c=>{let h=t[c];try{if(h instanceof Uint8Array){let d="";for(let l=0;l>4],d+=Hd[h[l]&15];s.push(c+"=Uint8Array(0x"+d+")")}else s.push(c+"="+JSON.stringify(h))}catch{s.push(c+"="+JSON.stringify(t[c].toString()))}}),s.push(`code=${r}`),s.push(`version=${this.version}`);let n=e,o="";switch(r){case et.NUMERIC_FAULT:{o="NUMERIC_FAULT";let c=e;switch(c){case"overflow":case"underflow":case"division-by-zero":o+="-"+c;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case et.CALL_EXCEPTION:case et.INSUFFICIENT_FUNDS:case et.MISSING_NEW:case et.NONCE_EXPIRED:case et.REPLACEMENT_UNDERPRICED:case et.TRANSACTION_REPLACED:case et.UNPREDICTABLE_GAS_LIMIT:o=r;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),s.length&&(e+=" ("+s.join(", ")+")");let a=new Error(e);return a.reason=n,a.code=r,Object.keys(t).forEach(function(c){a[c]=t[c]}),a}throwError(e,r,t){throw this.makeError(e,r,t)}throwArgumentError(e,r,t){return this.throwError(e,i.errors.INVALID_ARGUMENT,{argument:r,value:t})}assert(e,r,t,s){e||this.throwError(r,t,s)}assertArgument(e,r,t,s){e||this.throwArgumentError(r,t,s)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),$d&&this.throwError("platform missing String.prototype.normalize",i.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:$d})}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,i.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,i.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,r,t){t?t=": "+t:t="",er&&this.throwError("too many arguments"+t,i.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r})}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",i.errors.MISSING_NEW,{name:r.name})}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",i.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",i.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return yc||(yc=new i(qd)),yc}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",i.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Vd){if(!e)return;this.globalLogger().throwError("error censorship permanent",i.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Kd=!!e,Vd=!!r}static setLogLevel(e){let r=ro[e.toLowerCase()];if(r==null){i.globalLogger().warn("invalid log level - "+e);return}jd=r}static from(e){return new i(e)}};Fe.errors=et;Fe.levels=wc});var Gd,Wd=P(()=>{Gd="bytes/5.7.0"});function Yd(i){return!!i.toHexString}function yi(i){return i.slice||(i.slice=function(){let e=Array.prototype.slice.call(arguments);return yi(new Uint8Array(Array.prototype.slice.apply(i,e)))}),i}function Jd(i){return typeof i=="number"&&i==i&&i%1===0}function Xd(i){if(i==null)return!1;if(i.constructor===Uint8Array)return!0;if(typeof i=="string"||!Jd(i.length)||i.length<0)return!1;for(let e=0;e=256)return!1}return!0}function ke(i,e){if(e||(e={}),typeof i=="number"){or.checkSafeUint53(i,"invalid arrayify value");let r=[];for(;i;)r.unshift(i&255),i=parseInt(String(i/256));return r.length===0&&r.push(0),yi(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof i=="string"&&i.substring(0,2)!=="0x"&&(i="0x"+i),Yd(i)&&(i=i.toHexString()),wi(i)){let r=i.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":or.throwArgumentError("hex data is odd-length","value",i));let t=[];for(let s=0;ske(s)),r=e.reduce((s,n)=>s+n.length,0),t=new Uint8Array(r);return e.reduce((s,n)=>(t.set(n,s),s+n.length),0),yi(t)}function wi(i,e){return!(typeof i!="string"||!i.match(/^0x[0-9A-Fa-f]*$/)||e&&i.length!==2+2*e)}function bi(i,e){if(e||(e={}),typeof i=="number"){or.checkSafeUint53(i,"invalid hexlify value");let r="";for(;i;)r=bc[i&15]+r,i=Math.floor(i/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof i=="bigint")return i=i.toString(16),i.length%2?"0x0"+i:"0x"+i;if(e.allowMissingPrefix&&typeof i=="string"&&i.substring(0,2)!=="0x"&&(i="0x"+i),Yd(i))return i.toHexString();if(wi(i))return i.length%2&&(e.hexPad==="left"?i="0x0"+i.substring(2):e.hexPad==="right"?i+="0":or.throwArgumentError("hex data is odd-length","value",i)),i.toLowerCase();if(Xd(i)){let r="0x";for(let t=0;t>4]+bc[s&15]}return r}return or.throwArgumentError("invalid hexlify value","value",i)}function io(i,e,r){return typeof i!="string"?i=bi(i):(!wi(i)||i.length%2)&&or.throwArgumentError("invalid hexData","value",i),e=2+2*e,r!=null?"0x"+i.substring(e,2+2*r):"0x"+i.substring(e)}var or,bc,ar=P(()=>{"use strict";Mr();Wd();or=new Fe(Gd);bc="0123456789abcdef"});function Fr(i){return"0x"+Qd.default.keccak_256(ke(i))}var Qd,so=P(()=>{"use strict";Qd=pe(Bd());ar()});var _c,Zd,ef=P(()=>{_c=class{constructor(e){this.value=BigInt(e)}toString(e=10){return this.value.toString(e)}toNumber(){return Number(this.value)}},Zd=_c});var tf,rf=P(()=>{tf="bignumber/5.7.0"});function vc(i){return new Nb(i,36).toString(16)}var Nb,vS,sf=P(()=>{"use strict";ef();Mr();rf();Nb=Zd.BN,vS=new Fe(tf)});var nf=P(()=>{sf()});var of,af=P(()=>{of="strings/5.7.0"});function Ob(i,e,r,t,s){return cf.throwArgumentError(`invalid codepoint at offset ${e}; ${i}`,"bytes",r)}function uf(i,e,r,t,s){if(i===cr.BAD_PREFIX||i===cr.UNEXPECTED_CONTINUE){let n=0;for(let o=e+1;o>6===2;o++)n++;return n}return i===cr.OVERRUN?r.length-e-1:0}function Pb(i,e,r,t,s){return i===cr.OVERLONG?(t.push(s),0):(t.push(65533),uf(i,e,r,t,s))}function _i(i,e=Ei.current){e!=Ei.current&&(cf.checkNormalize(),i=i.normalize(e));let r=[];for(let t=0;t>6|192),r.push(s&63|128);else if((s&64512)==55296){t++;let n=i.charCodeAt(t);if(t>=i.length||(n&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((s&1023)<<10)+(n&1023);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(o&63|128)}else r.push(s>>12|224),r.push(s>>6&63|128),r.push(s&63|128)}return ke(r)}var cf,Ei,cr,Lb,hf=P(()=>{"use strict";ar();Mr();af();cf=new Fe(of);(function(i){i.current="",i.NFC="NFC",i.NFD="NFD",i.NFKC="NFKC",i.NFKD="NFKD"})(Ei||(Ei={}));(function(i){i.UNEXPECTED_CONTINUE="unexpected continuation byte",i.BAD_PREFIX="bad codepoint prefix",i.OVERRUN="string overrun",i.MISSING_CONTINUE="missing continuation byte",i.OUT_OF_RANGE="out of UTF-8 range",i.UTF16_SURROGATE="UTF-16 surrogate",i.OVERLONG="overlong representation"})(cr||(cr={}));Lb=Object.freeze({error:Ob,ignore:uf,replace:Pb})});var lf=P(()=>{"use strict";hf()});function no(i){return typeof i=="string"&&(i=_i(i)),Fr(Ec([_i(df),_i(String(i.length)),i]))}var df,ff=P(()=>{ar();so();lf();df=`Ethereum Signed Message: -`});var pf,gf=P(()=>{pf="address/5.7.0"});function mf(i){wi(i,20)||vi.throwArgumentError("invalid address","address",i),i=i.toLowerCase();let e=i.substring(2).split(""),r=new Uint8Array(40);for(let s=0;s<40;s++)r[s]=e[s].charCodeAt(0);let t=ke(Fr(r));for(let s=0;s<40;s+=2)t[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(t[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}function kb(i){return Math.log10?Math.log10(i):Math.log(i)/Math.LN10}function Bb(i){i=i.toUpperCase(),i=i.substring(4)+i.substring(0,2)+"00";let e=i.split("").map(t=>xc[t]).join("");for(;e.length>=yf;){let t=e.substring(0,yf);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function wf(i){let e=null;if(typeof i!="string"&&vi.throwArgumentError("invalid address","address",i),i.match(/^(0x)?[0-9a-fA-F]{40}$/))i.substring(0,2)!=="0x"&&(i="0x"+i),e=mf(i),i.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==i&&vi.throwArgumentError("bad address checksum","address",i);else if(i.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(i.substring(2,4)!==Bb(i)&&vi.throwArgumentError("bad icap checksum","address",i),e=vc(i.substring(4));e.length<40;)e="0"+e;e=mf("0x"+e)}else vi.throwArgumentError("invalid address","address",i);return e}var vi,Fb,xc,yf,bf=P(()=>{"use strict";ar();nf();so();Mr();gf();vi=new Fe(pf);Fb=9007199254740991;xc={};for(let i=0;i<10;i++)xc[String(i)]=String(i);for(let i=0;i<26;i++)xc[String.fromCharCode(65+i)]=String(10+i);yf=Math.floor(kb(Fb))});var Ef=P(()=>{"use strict";ff()});var Tc,Ft,Be,Df,Tf,Rf,Ge,_f,ge,lo,Cf,Sc,co,qb,Ic,Si,hr,W,vf,We,kt,oo,Nf,Rc,Ii,Di,uo,Cc,xi,xf,fo,zb,Dc,Af,po,ho,Vb,Of,Sf,ao,Kb,Pf,Lf,Uf,Ti,ur,jb,If,$b,Nc=P(()=>{Tc=2n**256n,Ft=Tc-0x1000003d1n,Be=Tc-0x14551231950b75fc4402da1732fc9bebfn,Df=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Tf=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,Rf={p:Ft,n:Be,a:0n,b:7n,Gx:Df,Gy:Tf},Ge=32,_f=i=>W(W(i*i)*i+Rf.b),ge=(i="")=>{throw new Error(i)},lo=i=>typeof i=="bigint",Cf=i=>typeof i=="string",Sc=i=>lo(i)&&0nlo(i)&&0ni instanceof Uint8Array||i!=null&&typeof i=="object"&&i.constructor.name==="Uint8Array",Ic=(i,e)=>!qb(i)||typeof e=="number"&&e>0&&i.length!==e?ge("Uint8Array expected"):i,Si=i=>new Uint8Array(i),hr=(i,e)=>Ic(Cf(i)?Ii(i):Si(Ic(i)),e),W=(i,e=Ft)=>{let r=i%e;return r>=0n?r:e+r},vf=i=>i instanceof We?i:ge("Point expected"),We=class i{constructor(e,r,t){this.px=e,this.py=r,this.pz=t}static fromAffine(e){return e.x===0n&&e.y===0n?i.ZERO:new i(e.x,e.y,1n)}static fromHex(e){e=hr(e);let r,t=e[0],s=e.subarray(1),n=uo(s,0,Ge),o=e.length;if(o===33&&[2,3].includes(t)){Sc(n)||ge("Point hex invalid: x not FE");let a=zb(_f(n)),c=(a&1n)===1n;(t&1)===1!==c&&(a=W(-a)),r=new i(n,a,1n)}return o===65&&t===4&&(r=new i(n,uo(s,Ge,2*Ge),1n)),r?r.ok():ge("Point is not on curve")}static fromPrivateKey(e){return kt.mul(Dc(e))}get x(){return this.aff().x}get y(){return this.aff().y}equals(e){let{px:r,py:t,pz:s}=this,{px:n,py:o,pz:a}=vf(e),c=W(r*a),h=W(n*s),d=W(t*a),l=W(o*s);return c===h&&d===l}negate(){return new i(this.px,W(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:t,pz:s}=this,{px:n,py:o,pz:a}=vf(e),{a:c,b:h}=Rf,d=0n,l=0n,p=0n,f=W(h*3n),g=W(r*n),w=W(t*o),b=W(s*a),v=W(r+t),x=W(n+o);v=W(v*x),x=W(g+w),v=W(v-x),x=W(r+s);let I=W(n+a);return x=W(x*I),I=W(g+b),x=W(x-I),I=W(t+s),d=W(o+a),I=W(I*d),d=W(w+b),I=W(I-d),p=W(c*x),d=W(f*b),p=W(d+p),d=W(w-p),p=W(w+p),l=W(d*p),w=W(g+g),w=W(w+g),b=W(c*b),x=W(f*x),w=W(w+b),b=W(g-b),b=W(c*b),x=W(x+b),g=W(w*x),l=W(l+g),g=W(I*x),d=W(v*d),d=W(d-g),g=W(v*w),p=W(I*p),p=W(p+g),new i(d,l,p)}mul(e,r=!0){if(!r&&e===0n)return oo;if(co(e)||ge("invalid scalar"),this.equals(kt))return $b(e).p;let t=oo,s=kt;for(let n=this;e>0n;n=n.double(),e>>=1n)e&1n?t=t.add(n):r&&(s=s.add(n));return t}mulAddQUns(e,r,t){return this.mul(r,!1).add(e.mul(t,!1)).ok()}toAffine(){let{px:e,py:r,pz:t}=this;if(this.equals(oo))return{x:0n,y:0n};if(t===1n)return{x:e,y:r};let s=fo(t);return W(t*s)!==1n&&ge("invalid inverse"),{x:W(e*s),y:W(r*s)}}assertValidity(){let{x:e,y:r}=this.aff();return(!Sc(e)||!Sc(r))&&ge("Point invalid: x or y"),W(r*r)===_f(e)?this:ge("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:t}=this.aff();return(e?(t&1n)===0n?"02":"03":"04")+xi(r)+(e?"":xi(t))}toRawBytes(e=!0){return Ii(this.toHex(e))}};We.BASE=new We(Df,Tf,1n);We.ZERO=new We(0n,1n,0n);({BASE:kt,ZERO:oo}=We),Nf=(i,e)=>i.toString(16).padStart(e,"0"),Rc=i=>Array.from(i).map(e=>Nf(e,2)).join(""),Ii=i=>{let e=i.length;(!Cf(i)||e%2)&&ge("hex invalid 1");let r=Si(e/2);for(let t=0;tBigInt("0x"+(Rc(i)||"0")),uo=(i,e,r)=>Di(i.slice(e,r)),Cc=i=>lo(i)&&i>=0n&&iRc(Cc(i)),xf=(...i)=>{let e=Si(i.reduce((t,s)=>t+Ic(s).length,0)),r=0;return i.forEach(t=>{e.set(t,r),r+=t.length}),e},fo=(i,e=Ft)=>{(i===0n||e<=0n)&&ge("no inverse n="+i+" mod="+e);let r=W(i,e),t=e,s=0n,n=1n,o=1n,a=0n;for(;r!==0n;){let c=t/r,h=t%r,d=s-o*c,l=n-a*c;t=r,r=h,s=o,n=a,o=d,a=l}return t===1n?W(s,e):ge("no inverse")},zb=i=>{let e=1n;for(let r=i,t=(Ft+1n)/4n;t>0n;t>>=1n)t&1n&&(e=e*r%Ft),r=r*r%Ft;return W(e*e)===i?e:ge("sqrt invalid")},Dc=i=>(lo(i)||(i=Di(hr(i,Ge))),co(i)?i:ge("private key out of range")),Af=i=>i>Be>>1n,po=(i,e=!0)=>We.fromPrivateKey(i).toRawBytes(e),ho=class i{constructor(e,r,t){this.r=e,this.s=r,this.recovery=t,this.assertValidity()}static fromCompact(e){return e=hr(e,64),new i(uo(e,0,Ge),uo(e,Ge,2*Ge))}assertValidity(){return co(this.r)&&co(this.s)?this:ge()}addRecoveryBit(e){return new i(this.r,this.s,e)}hasHighS(){return Af(this.s)}normalizeS(){return this.hasHighS()?new i(this.r,W(this.s,Be),this.recovery):this}recoverPublicKey(e){let{r,s:t,recovery:s}=this;[0,1,2,3].includes(s)||ge("recovery id invalid");let n=Of(hr(e,Ge)),o=s===2||s===3?r+Be:r;o>=Ft&&ge("q.x invalid");let a=s&1?"03":"02",c=We.fromHex(a+xi(o)),h=fo(o,Be),d=W(-n*h,Be),l=W(t*h,Be);return kt.mulAddQUns(c,d,l)}toCompactRawBytes(){return Ii(this.toCompactHex())}toCompactHex(){return xi(this.r)+xi(this.s)}},Vb=i=>{let e=i.length*8-256,r=Di(i);return e>0?r>>BigInt(e):r},Of=i=>W(Vb(i),Be),Sf=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,Kb={lowS:!0},Pf=(i,e,r,t=Kb)=>{let{lowS:s}=t;s==null&&(s=!0),"strict"in t&&ge("verify() legacy options not supported");let n,o,a,c=i&&typeof i=="object"&&"r"in i;!c&&hr(i).length!==2*Ge&&ge("signature must be 64 bytes");try{n=c?new ho(i.r,i.s).assertValidity():ho.fromCompact(i),o=Of(hr(e)),a=r instanceof We?r.ok():We.fromHex(r)}catch{return!1}if(!n)return!1;let{r:h,s:d}=n;if(s&&Af(d))return!1;let l;try{let f=fo(d,Be),g=W(o*f,Be),w=W(h*f,Be);l=kt.mulAddQUns(a,g,w).aff()}catch{return!1}return l?W(l.x,Be)===h:!1},Lf=i=>{i=hr(i);let e=Ge+8;(i.length1024)&&ge("expected proper params");let r=W(Di(i),Be-1n)+1n;return Cc(r)},Uf={hexToBytes:Ii,bytesToHex:Rc,concatBytes:xf,bytesToNumberBE:Di,numberToBytesBE:Cc,mod:W,invert:fo,hmacSha256Async:async(i,...e)=>{let r=Sf(),t=r&&r.subtle;if(!t)return ge("etc.hmacSha256Async not set");let s=await t.importKey("raw",i,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Si(await t.sign("HMAC",s,xf(...e)))},hmacSha256Sync:ao,hashToPrivateKey:Lf,randomBytes:(i=32)=>{let e=Sf();return(!e||!e.getRandomValues)&&ge("crypto.getRandomValues must be defined"),e.getRandomValues(Si(i))}},Ti={normPrivateKeyToScalar:Dc,isValidPrivateKey:i=>{try{return!!Dc(i)}catch{return!1}},randomPrivateKey:()=>Lf(Uf.randomBytes(Ge+16)),precompute(i=8,e=kt){return e.multiply(3n),e}};Object.defineProperties(Uf,{hmacSha256Sync:{configurable:!1,get(){return ao},set(i){ao||(ao=i)}}});ur=8,jb=()=>{let i=[],e=256/ur+1,r=kt,t=r;for(let s=0;s{let e=If||(If=jb()),r=(d,l)=>{let p=l.negate();return d?p:l},t=oo,s=kt,n=1+256/ur,o=2**(ur-1),a=BigInt(2**ur-1),c=2**ur,h=BigInt(ur);for(let d=0;d>=h,p>o&&(p-=c,i+=1n);let f=l,g=l+Math.abs(p)-1,w=d%2!==0,b=p<0;p===0?s=s.add(r(w,e[f])):t=t.add(r(b,e[g]))}return{p:t,f:s}}});function Mf(i,e=!1){let r=po(ke(i),e);return bi(r)}function Ff(i,e,r){let t=new Uint8Array(64);t.set(ke(e.r),0),t.set(ke(e.s),32);let s=Ti.recoverPublicKey(ke(i),t,r,!1);return bi(s)}var kf=P(()=>{Nc();ar()});var Bf,qf=P(()=>{Bf="transactions/5.7.0"});function Gb(i){let e=Mf(i);return wf(io(Fr(io(e,1)),12))}function Vf(i,e){return Gb(Ff(ke(i),e))}var lI,zf,Kf=P(()=>{"use strict";bf();ar();so();kf();Mr();qf();lI=new Fe(Bf);(function(i){i[i.legacy=0]="legacy",i[i.eip2930=1]="eip2930",i[i.eip1559=2]="eip1559"})(zf||(zf={}))});var $f=oe(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Ne=Ir(),Ac=He(),Wb=20;function Jb(i,e,r){for(var t=1634760805,s=857760878,n=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],c=r[7]<<24|r[6]<<16|r[5]<<8|r[4],h=r[11]<<24|r[10]<<16|r[9]<<8|r[8],d=r[15]<<24|r[14]<<16|r[13]<<8|r[12],l=r[19]<<24|r[18]<<16|r[17]<<8|r[16],p=r[23]<<24|r[22]<<16|r[21]<<8|r[20],f=r[27]<<24|r[26]<<16|r[25]<<8|r[24],g=r[31]<<24|r[30]<<16|r[29]<<8|r[28],w=e[3]<<24|e[2]<<16|e[1]<<8|e[0],b=e[7]<<24|e[6]<<16|e[5]<<8|e[4],v=e[11]<<24|e[10]<<16|e[9]<<8|e[8],x=e[15]<<24|e[14]<<16|e[13]<<8|e[12],I=t,S=s,T=n,L=o,y=a,m=c,k=h,$=d,O=l,C=p,R=f,N=g,G=w,H=b,q=v,j=x,re=0;re>>16|G<<16,O=O+G|0,y^=O,y=y>>>20|y<<12,S=S+m|0,H^=S,H=H>>>16|H<<16,C=C+H|0,m^=C,m=m>>>20|m<<12,T=T+k|0,q^=T,q=q>>>16|q<<16,R=R+q|0,k^=R,k=k>>>20|k<<12,L=L+$|0,j^=L,j=j>>>16|j<<16,N=N+j|0,$^=N,$=$>>>20|$<<12,T=T+k|0,q^=T,q=q>>>24|q<<8,R=R+q|0,k^=R,k=k>>>25|k<<7,L=L+$|0,j^=L,j=j>>>24|j<<8,N=N+j|0,$^=N,$=$>>>25|$<<7,S=S+m|0,H^=S,H=H>>>24|H<<8,C=C+H|0,m^=C,m=m>>>25|m<<7,I=I+y|0,G^=I,G=G>>>24|G<<8,O=O+G|0,y^=O,y=y>>>25|y<<7,I=I+m|0,j^=I,j=j>>>16|j<<16,R=R+j|0,m^=R,m=m>>>20|m<<12,S=S+k|0,G^=S,G=G>>>16|G<<16,N=N+G|0,k^=N,k=k>>>20|k<<12,T=T+$|0,H^=T,H=H>>>16|H<<16,O=O+H|0,$^=O,$=$>>>20|$<<12,L=L+y|0,q^=L,q=q>>>16|q<<16,C=C+q|0,y^=C,y=y>>>20|y<<12,T=T+$|0,H^=T,H=H>>>24|H<<8,O=O+H|0,$^=O,$=$>>>25|$<<7,L=L+y|0,q^=L,q=q>>>24|q<<8,C=C+q|0,y^=C,y=y>>>25|y<<7,S=S+k|0,G^=S,G=G>>>24|G<<8,N=N+G|0,k^=N,k=k>>>25|k<<7,I=I+m|0,j^=I,j=j>>>24|j<<8,R=R+j|0,m^=R,m=m>>>25|m<<7;Ne.writeUint32LE(I+t|0,i,0),Ne.writeUint32LE(S+s|0,i,4),Ne.writeUint32LE(T+n|0,i,8),Ne.writeUint32LE(L+o|0,i,12),Ne.writeUint32LE(y+a|0,i,16),Ne.writeUint32LE(m+c|0,i,20),Ne.writeUint32LE(k+h|0,i,24),Ne.writeUint32LE($+d|0,i,28),Ne.writeUint32LE(O+l|0,i,32),Ne.writeUint32LE(C+p|0,i,36),Ne.writeUint32LE(R+f|0,i,40),Ne.writeUint32LE(N+g|0,i,44),Ne.writeUint32LE(G+w|0,i,48),Ne.writeUint32LE(H+b|0,i,52),Ne.writeUint32LE(q+v|0,i,56),Ne.writeUint32LE(j+x|0,i,60)}function jf(i,e,r,t,s){if(s===void 0&&(s=0),i.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(t.length>>=8,e++;if(t>0)throw new Error("ChaCha: counter overflow")}});var mo=oe(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});function Qb(i,e,r){return~(i-1)&e|i-1&r}kr.select=Qb;function Zb(i,e){return(i|0)-(e|0)-1>>>31&1}kr.lessOrEqual=Zb;function Hf(i,e){if(i.length!==e.length)return 0;for(var r=0,t=0;t>>8}kr.compare=Hf;function e1(i,e){return i.length===0||e.length===0?!1:Hf(i,e)!==0}kr.equal=e1});var Wf=oe(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});var t1=mo(),yo=He();xt.DIGEST_LENGTH=16;var Gf=function(){function i(e){this.digestLength=xt.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=e[0]|e[1]<<8;this._r[0]=r&8191;var t=e[2]|e[3]<<8;this._r[1]=(r>>>13|t<<3)&8191;var s=e[4]|e[5]<<8;this._r[2]=(t>>>10|s<<6)&7939;var n=e[6]|e[7]<<8;this._r[3]=(s>>>7|n<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(n>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=(o>>>14|a<<2)&8191;var c=e[12]|e[13]<<8;this._r[7]=(a>>>11|c<<5)&8065;var h=e[14]|e[15]<<8;this._r[8]=(c>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return i.prototype._blocks=function(e,r,t){for(var s=this._fin?0:2048,n=this._h[0],o=this._h[1],a=this._h[2],c=this._h[3],h=this._h[4],d=this._h[5],l=this._h[6],p=this._h[7],f=this._h[8],g=this._h[9],w=this._r[0],b=this._r[1],v=this._r[2],x=this._r[3],I=this._r[4],S=this._r[5],T=this._r[6],L=this._r[7],y=this._r[8],m=this._r[9];t>=16;){var k=e[r+0]|e[r+1]<<8;n+=k&8191;var $=e[r+2]|e[r+3]<<8;o+=(k>>>13|$<<3)&8191;var O=e[r+4]|e[r+5]<<8;a+=($>>>10|O<<6)&8191;var C=e[r+6]|e[r+7]<<8;c+=(O>>>7|C<<9)&8191;var R=e[r+8]|e[r+9]<<8;h+=(C>>>4|R<<12)&8191,d+=R>>>1&8191;var N=e[r+10]|e[r+11]<<8;l+=(R>>>14|N<<2)&8191;var G=e[r+12]|e[r+13]<<8;p+=(N>>>11|G<<5)&8191;var H=e[r+14]|e[r+15]<<8;f+=(G>>>8|H<<8)&8191,g+=H>>>5|s;var q=0,j=q;j+=n*w,j+=o*(5*m),j+=a*(5*y),j+=c*(5*L),j+=h*(5*T),q=j>>>13,j&=8191,j+=d*(5*S),j+=l*(5*I),j+=p*(5*x),j+=f*(5*v),j+=g*(5*b),q+=j>>>13,j&=8191;var re=q;re+=n*b,re+=o*w,re+=a*(5*m),re+=c*(5*y),re+=h*(5*L),q=re>>>13,re&=8191,re+=d*(5*T),re+=l*(5*S),re+=p*(5*I),re+=f*(5*x),re+=g*(5*v),q+=re>>>13,re&=8191;var Y=q;Y+=n*v,Y+=o*b,Y+=a*w,Y+=c*(5*m),Y+=h*(5*y),q=Y>>>13,Y&=8191,Y+=d*(5*L),Y+=l*(5*T),Y+=p*(5*S),Y+=f*(5*I),Y+=g*(5*x),q+=Y>>>13,Y&=8191;var Z=q;Z+=n*x,Z+=o*v,Z+=a*b,Z+=c*w,Z+=h*(5*m),q=Z>>>13,Z&=8191,Z+=d*(5*y),Z+=l*(5*L),Z+=p*(5*T),Z+=f*(5*S),Z+=g*(5*I),q+=Z>>>13,Z&=8191;var V=q;V+=n*I,V+=o*x,V+=a*v,V+=c*b,V+=h*w,q=V>>>13,V&=8191,V+=d*(5*m),V+=l*(5*y),V+=p*(5*L),V+=f*(5*T),V+=g*(5*S),q+=V>>>13,V&=8191;var J=q;J+=n*S,J+=o*I,J+=a*x,J+=c*v,J+=h*b,q=J>>>13,J&=8191,J+=d*w,J+=l*(5*m),J+=p*(5*y),J+=f*(5*L),J+=g*(5*T),q+=J>>>13,J&=8191;var X=q;X+=n*T,X+=o*S,X+=a*I,X+=c*x,X+=h*v,q=X>>>13,X&=8191,X+=d*b,X+=l*w,X+=p*(5*m),X+=f*(5*y),X+=g*(5*L),q+=X>>>13,X&=8191;var u=q;u+=n*L,u+=o*T,u+=a*S,u+=c*I,u+=h*x,q=u>>>13,u&=8191,u+=d*v,u+=l*b,u+=p*w,u+=f*(5*m),u+=g*(5*y),q+=u>>>13,u&=8191;var E=q;E+=n*y,E+=o*L,E+=a*T,E+=c*S,E+=h*I,q=E>>>13,E&=8191,E+=d*x,E+=l*v,E+=p*b,E+=f*w,E+=g*(5*m),q+=E>>>13,E&=8191;var _=q;_+=n*m,_+=o*y,_+=a*L,_+=c*T,_+=h*S,q=_>>>13,_&=8191,_+=d*I,_+=l*x,_+=p*v,_+=f*b,_+=g*w,q+=_>>>13,_&=8191,q=(q<<2)+q|0,q=q+j|0,j=q&8191,q=q>>>13,re+=q,n=j,o=re,a=Y,c=Z,h=V,d=J,l=X,p=u,f=E,g=_,r+=16,t-=16}this._h[0]=n,this._h[1]=o,this._h[2]=a,this._h[3]=c,this._h[4]=h,this._h[5]=d,this._h[6]=l,this._h[7]=p,this._h[8]=f,this._h[9]=g},i.prototype.finish=function(e,r){r===void 0&&(r=0);var t=new Uint16Array(10),s,n,o,a;if(this._leftover){for(a=this._leftover,this._buffer[a++]=1;a<16;a++)this._buffer[a]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(s=this._h[1]>>>13,this._h[1]&=8191,a=2;a<10;a++)this._h[a]+=s,s=this._h[a]>>>13,this._h[a]&=8191;for(this._h[0]+=s*5,s=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=s,s=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=s,t[0]=this._h[0]+5,s=t[0]>>>13,t[0]&=8191,a=1;a<10;a++)t[a]=this._h[a]+s,s=t[a]>>>13,t[a]&=8191;for(t[9]-=8192,n=(s^1)-1,a=0;a<10;a++)t[a]&=n;for(n=~n,a=0;a<10;a++)this._h[a]=this._h[a]&n|t[a];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,a=1;a<8;a++)o=(this._h[a]+this._pad[a]|0)+(o>>>16)|0,this._h[a]=o&65535;return e[r+0]=this._h[0]>>>0,e[r+1]=this._h[0]>>>8,e[r+2]=this._h[1]>>>0,e[r+3]=this._h[1]>>>8,e[r+4]=this._h[2]>>>0,e[r+5]=this._h[2]>>>8,e[r+6]=this._h[3]>>>0,e[r+7]=this._h[3]>>>8,e[r+8]=this._h[4]>>>0,e[r+9]=this._h[4]>>>8,e[r+10]=this._h[5]>>>0,e[r+11]=this._h[5]>>>8,e[r+12]=this._h[6]>>>0,e[r+13]=this._h[6]>>>8,e[r+14]=this._h[7]>>>0,e[r+15]=this._h[7]>>>8,this._finished=!0,this},i.prototype.update=function(e){var r=0,t=e.length,s;if(this._leftover){s=16-this._leftover,s>t&&(s=t);for(var n=0;n=16&&(s=t-t%16,this._blocks(e,r,s),r+=s,t-=s),t){for(var n=0;n{"use strict";Object.defineProperty(St,"__esModule",{value:!0});var wo=$f(),s1=Wf(),Ri=He(),Jf=Ir(),n1=mo();St.KEY_LENGTH=32;St.NONCE_LENGTH=12;St.TAG_LENGTH=16;var Yf=new Uint8Array(16),o1=function(){function i(e){if(this.nonceLength=St.NONCE_LENGTH,this.tagLength=St.TAG_LENGTH,e.length!==St.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return i.prototype.seal=function(e,r,t,s){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var n=new Uint8Array(16);n.set(e,n.length-e.length);var o=new Uint8Array(32);wo.stream(this._key,n,o,4);var a=r.length+this.tagLength,c;if(s){if(s.length!==a)throw new Error("ChaCha20Poly1305: incorrect destination length");c=s}else c=new Uint8Array(a);return wo.streamXOR(this._key,n,r,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),o,c.subarray(0,c.length-this.tagLength),t),Ri.wipe(n),c},i.prototype.open=function(e,r,t,s){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(r.length0&&n.update(Yf.subarray(s.length%16))),n.update(t),t.length%16>0&&n.update(Yf.subarray(t.length%16));var o=new Uint8Array(8);s&&Jf.writeUint64LE(s.length,o),n.update(o),Jf.writeUint64LE(t.length,o),n.update(o);for(var a=n.digest(),c=0;c{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function a1(i){return typeof i.saveState<"u"&&typeof i.restoreState<"u"&&typeof i.cleanSavedState<"u"}Oc.isSerializableHash=a1});var ep=oe(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});var lt=Qf(),c1=mo(),u1=He(),Zf=function(){function i(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var t=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(t).clean():t.set(r);for(var s=0;s{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var tp=ep(),rp=He(),l1=function(){function i(e,r,t,s){t===void 0&&(t=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=s;var n=tp.hmac(this._hash,t,r);this._hmac=new tp.HMAC(e,n),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return i.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},i.prototype.expand=function(e){for(var r=new Uint8Array(e),t=0;t{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});var Eo=Ir(),bo=He();Bt.DIGEST_LENGTH=32;Bt.BLOCK_SIZE=64;var sp=function(){function i(){this.digestLength=Bt.DIGEST_LENGTH,this.blockSize=Bt.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return i.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},i.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},i.prototype.clean=function(){bo.wipe(this._buffer),bo.wipe(this._temp),this.reset()},i.prototype.update=function(e,r){if(r===void 0&&(r=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var t=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[t++],r--;this._bufferLength===this.blockSize&&(Lc(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(t=Lc(this._temp,this._state,e,t,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=e[t++],r--;return this},i.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,t=this._bufferLength,s=r/536870912|0,n=r<<3,o=r%64<56?64:128;this._buffer[t]=128;for(var a=t+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},i.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},i.prototype.cleanSavedState=function(e){bo.wipe(e.state),e.buffer&&bo.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},i}();Bt.SHA256=sp;var d1=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Lc(i,e,r,t,s){for(;s>=64;){for(var n=e[0],o=e[1],a=e[2],c=e[3],h=e[4],d=e[5],l=e[6],p=e[7],f=0;f<16;f++){var g=t+f*4;i[f]=Eo.readUint32BE(r,g)}for(var f=16;f<64;f++){var w=i[f-2],b=(w>>>17|w<<15)^(w>>>19|w<<13)^w>>>10;w=i[f-15];var v=(w>>>7|w<<25)^(w>>>18|w<<14)^w>>>3;i[f]=(b+i[f-7]|0)+(v+i[f-16]|0)}for(var f=0;f<64;f++){var b=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&d^~h&l)|0)+(p+(d1[f]+i[f]|0)|0)|0,v=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&o^n&a^o&a)|0;p=l,l=d,d=h,h=c+b|0,c=a,a=o,o=n,n=b+v|0}e[0]+=n,e[1]+=o,e[2]+=a,e[3]+=c,e[4]+=h,e[5]+=d,e[6]+=l,e[7]+=p,t+=64,s-=64}return t}function f1(i){var e=new sp;e.update(i);var r=e.digest();return e.clean(),r}Bt.hash=f1});var up=oe(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.sharedKey=be.generateKeyPair=be.generateKeyPairFromSeed=be.scalarMultBase=be.scalarMult=be.SHARED_KEY_LENGTH=be.SECRET_KEY_LENGTH=be.PUBLIC_KEY_LENGTH=void 0;var p1=ni(),g1=He();be.PUBLIC_KEY_LENGTH=32;be.SECRET_KEY_LENGTH=32;be.SHARED_KEY_LENGTH=32;function dt(i){let e=new Float64Array(16);if(i)for(let r=0;r>16&1),r[o-1]&=65535;r[15]=t[15]-32767-(r[14]>>16&1);let n=r[15]>>16&1;r[14]&=65535,Ni(t,r,1-n)}for(let s=0;s<16;s++)i[2*s]=t[s]&255,i[2*s+1]=t[s]>>8}function w1(i,e){for(let r=0;r<16;r++)i[r]=e[2*r]+(e[2*r+1]<<8);i[15]&=32767}function _o(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]+r[t]}function vo(i,e,r){for(let t=0;t<16;t++)i[t]=e[t]-r[t]}function It(i,e,r){let t,s,n=0,o=0,a=0,c=0,h=0,d=0,l=0,p=0,f=0,g=0,w=0,b=0,v=0,x=0,I=0,S=0,T=0,L=0,y=0,m=0,k=0,$=0,O=0,C=0,R=0,N=0,G=0,H=0,q=0,j=0,re=0,Y=r[0],Z=r[1],V=r[2],J=r[3],X=r[4],u=r[5],E=r[6],_=r[7],D=r[8],A=r[9],U=r[10],F=r[11],M=r[12],Q=r[13],z=r[14],ee=r[15];t=e[0],n+=t*Y,o+=t*Z,a+=t*V,c+=t*J,h+=t*X,d+=t*u,l+=t*E,p+=t*_,f+=t*D,g+=t*A,w+=t*U,b+=t*F,v+=t*M,x+=t*Q,I+=t*z,S+=t*ee,t=e[1],o+=t*Y,a+=t*Z,c+=t*V,h+=t*J,d+=t*X,l+=t*u,p+=t*E,f+=t*_,g+=t*D,w+=t*A,b+=t*U,v+=t*F,x+=t*M,I+=t*Q,S+=t*z,T+=t*ee,t=e[2],a+=t*Y,c+=t*Z,h+=t*V,d+=t*J,l+=t*X,p+=t*u,f+=t*E,g+=t*_,w+=t*D,b+=t*A,v+=t*U,x+=t*F,I+=t*M,S+=t*Q,T+=t*z,L+=t*ee,t=e[3],c+=t*Y,h+=t*Z,d+=t*V,l+=t*J,p+=t*X,f+=t*u,g+=t*E,w+=t*_,b+=t*D,v+=t*A,x+=t*U,I+=t*F,S+=t*M,T+=t*Q,L+=t*z,y+=t*ee,t=e[4],h+=t*Y,d+=t*Z,l+=t*V,p+=t*J,f+=t*X,g+=t*u,w+=t*E,b+=t*_,v+=t*D,x+=t*A,I+=t*U,S+=t*F,T+=t*M,L+=t*Q,y+=t*z,m+=t*ee,t=e[5],d+=t*Y,l+=t*Z,p+=t*V,f+=t*J,g+=t*X,w+=t*u,b+=t*E,v+=t*_,x+=t*D,I+=t*A,S+=t*U,T+=t*F,L+=t*M,y+=t*Q,m+=t*z,k+=t*ee,t=e[6],l+=t*Y,p+=t*Z,f+=t*V,g+=t*J,w+=t*X,b+=t*u,v+=t*E,x+=t*_,I+=t*D,S+=t*A,T+=t*U,L+=t*F,y+=t*M,m+=t*Q,k+=t*z,$+=t*ee,t=e[7],p+=t*Y,f+=t*Z,g+=t*V,w+=t*J,b+=t*X,v+=t*u,x+=t*E,I+=t*_,S+=t*D,T+=t*A,L+=t*U,y+=t*F,m+=t*M,k+=t*Q,$+=t*z,O+=t*ee,t=e[8],f+=t*Y,g+=t*Z,w+=t*V,b+=t*J,v+=t*X,x+=t*u,I+=t*E,S+=t*_,T+=t*D,L+=t*A,y+=t*U,m+=t*F,k+=t*M,$+=t*Q,O+=t*z,C+=t*ee,t=e[9],g+=t*Y,w+=t*Z,b+=t*V,v+=t*J,x+=t*X,I+=t*u,S+=t*E,T+=t*_,L+=t*D,y+=t*A,m+=t*U,k+=t*F,$+=t*M,O+=t*Q,C+=t*z,R+=t*ee,t=e[10],w+=t*Y,b+=t*Z,v+=t*V,x+=t*J,I+=t*X,S+=t*u,T+=t*E,L+=t*_,y+=t*D,m+=t*A,k+=t*U,$+=t*F,O+=t*M,C+=t*Q,R+=t*z,N+=t*ee,t=e[11],b+=t*Y,v+=t*Z,x+=t*V,I+=t*J,S+=t*X,T+=t*u,L+=t*E,y+=t*_,m+=t*D,k+=t*A,$+=t*U,O+=t*F,C+=t*M,R+=t*Q,N+=t*z,G+=t*ee,t=e[12],v+=t*Y,x+=t*Z,I+=t*V,S+=t*J,T+=t*X,L+=t*u,y+=t*E,m+=t*_,k+=t*D,$+=t*A,O+=t*U,C+=t*F,R+=t*M,N+=t*Q,G+=t*z,H+=t*ee,t=e[13],x+=t*Y,I+=t*Z,S+=t*V,T+=t*J,L+=t*X,y+=t*u,m+=t*E,k+=t*_,$+=t*D,O+=t*A,C+=t*U,R+=t*F,N+=t*M,G+=t*Q,H+=t*z,q+=t*ee,t=e[14],I+=t*Y,S+=t*Z,T+=t*V,L+=t*J,y+=t*X,m+=t*u,k+=t*E,$+=t*_,O+=t*D,C+=t*A,R+=t*U,N+=t*F,G+=t*M,H+=t*Q,q+=t*z,j+=t*ee,t=e[15],S+=t*Y,T+=t*Z,L+=t*V,y+=t*J,m+=t*X,k+=t*u,$+=t*E,O+=t*_,C+=t*D,R+=t*A,N+=t*U,G+=t*F,H+=t*M,q+=t*Q,j+=t*z,re+=t*ee,n+=38*T,o+=38*L,a+=38*y,c+=38*m,h+=38*k,d+=38*$,l+=38*O,p+=38*C,f+=38*R,g+=38*N,w+=38*G,b+=38*H,v+=38*q,x+=38*j,I+=38*re,s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),s=1,t=n+s+65535,s=Math.floor(t/65536),n=t-s*65536,t=o+s+65535,s=Math.floor(t/65536),o=t-s*65536,t=a+s+65535,s=Math.floor(t/65536),a=t-s*65536,t=c+s+65535,s=Math.floor(t/65536),c=t-s*65536,t=h+s+65535,s=Math.floor(t/65536),h=t-s*65536,t=d+s+65535,s=Math.floor(t/65536),d=t-s*65536,t=l+s+65535,s=Math.floor(t/65536),l=t-s*65536,t=p+s+65535,s=Math.floor(t/65536),p=t-s*65536,t=f+s+65535,s=Math.floor(t/65536),f=t-s*65536,t=g+s+65535,s=Math.floor(t/65536),g=t-s*65536,t=w+s+65535,s=Math.floor(t/65536),w=t-s*65536,t=b+s+65535,s=Math.floor(t/65536),b=t-s*65536,t=v+s+65535,s=Math.floor(t/65536),v=t-s*65536,t=x+s+65535,s=Math.floor(t/65536),x=t-s*65536,t=I+s+65535,s=Math.floor(t/65536),I=t-s*65536,t=S+s+65535,s=Math.floor(t/65536),S=t-s*65536,n+=s-1+37*(s-1),i[0]=n,i[1]=o,i[2]=a,i[3]=c,i[4]=h,i[5]=d,i[6]=l,i[7]=p,i[8]=f,i[9]=g,i[10]=w,i[11]=b,i[12]=v,i[13]=x,i[14]=I,i[15]=S}function Ai(i,e){It(i,e,e)}function b1(i,e){let r=dt();for(let t=0;t<16;t++)r[t]=e[t];for(let t=253;t>=0;t--)Ai(r,r),t!==2&&t!==4&&It(r,r,e);for(let t=0;t<16;t++)i[t]=r[t]}function Mc(i,e){let r=new Uint8Array(32),t=new Float64Array(80),s=dt(),n=dt(),o=dt(),a=dt(),c=dt(),h=dt();for(let f=0;f<31;f++)r[f]=i[f];r[31]=i[31]&127|64,r[0]&=248,w1(t,e);for(let f=0;f<16;f++)n[f]=t[f];s[0]=a[0]=1;for(let f=254;f>=0;--f){let g=r[f>>>3]>>>(f&7)&1;Ni(s,n,g),Ni(o,a,g),_o(c,s,o),vo(s,s,o),_o(o,n,a),vo(n,n,a),Ai(a,c),Ai(h,s),It(s,o,s),It(o,n,c),_o(c,s,o),vo(s,s,o),Ai(n,s),vo(o,a,h),It(s,o,m1),_o(s,s,a),It(o,o,s),It(s,a,h),It(a,n,t),Ai(n,c),Ni(s,n,g),Ni(o,a,g)}for(let f=0;f<16;f++)t[f+16]=s[f],t[f+32]=o[f],t[f+48]=n[f],t[f+64]=a[f];let d=t.subarray(32),l=t.subarray(16);b1(d,d),It(l,l,d);let p=new Uint8Array(32);return y1(p,l),p}be.scalarMult=Mc;function ap(i){return Mc(i,op)}be.scalarMultBase=ap;function cp(i){if(i.length!==be.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${be.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(i);return{publicKey:ap(e),secretKey:e}}be.generateKeyPairFromSeed=cp;function E1(i){let e=(0,p1.randomBytes)(32,i),r=cp(e);return(0,g1.wipe)(e),r}be.generateKeyPair=E1;function _1(i,e,r=!1){if(i.length!==be.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==be.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let t=Mc(i,e);if(r){let s=0;for(let n=0;n{});var lp=P(()=>{});var dp=P(()=>{Kn()});var Fc=P(()=>{hp();Ba();lp();dc();lc();dp()});var kc,fp,pp=P(()=>{Nc();kc=class{constructor(e){if(e!=="secp256k1")throw new Error("Only secp256k1 is supported")}keyFromPrivate(e){let r=typeof e=="string"?Ti.hexToBytes(e.replace("0x","")):e;return{getPublic:(t=!1)=>{let s=po(r);return{encode:n=>s}}}}keyFromPublic(e){let r=typeof e=="string"?Ti.hexToBytes(e.replace("0x","")):e;return{verify:async(t,s)=>Pf(s,t,r)}}},fp=kc});var gp,mp=P(()=>{gp={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}}});function Ui(i){let[e,r]=i.split(v1);return{namespace:e,reference:r}}function Np(i,e){return i.includes(":")?[i]:e.chains||[]}function Mi(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function fr(){return!(0,Tt.getDocument)()&&!!(0,Tt.getNavigator)()&&navigator.product===D1}function qr(){return!Mi()&&!!(0,Tt.getNavigator)()&&!!(0,Tt.getDocument)()}function Fi(){return fr()?qe.reactNative:Mi()?qe.node:qr()?qe.browser:qe.unknown}function Ap(){var i;try{return fr()&&typeof window<"u"&&typeof window?.Application<"u"?(i=window.Application)==null?void 0:i.applicationId:void 0}catch{return}}function R1(i,e){let r=gc(i);return r=bp(bp({},r),e),i=mc(r),i}function zr(){return(0,Rp.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function C1(){if(Fi()===qe.reactNative&&typeof window<"u"&&typeof window?.Platform<"u"){let{OS:r,Version:t}=window.Platform;return[r,t].join("-")}let i=Ld();if(i===null)return"unknown";let e=i.os?i.os.replace(" ","").toLowerCase():"unknown";return i.type==="browser"?[e,i.name,i.version].join("-"):[e,i.version].join("-")}function N1(){var i;let e=Fi();return e===qe.browser?[e,((i=(0,Tt.getLocation)())==null?void 0:i.host)||"unknown"].join(":"):e}function zc(i,e,r){let t=C1(),s=N1();return[[i,e].join("-"),[T1,r].join("-"),t,s].join("/")}function Op({protocol:i,version:e,relayUrl:r,sdkVersion:t,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a}){let c=r.split("?"),h=zc(i,e,t),d={auth:s,ua:h,projectId:n,useOnCloseEvent:o||void 0,origin:a||void 0},l=R1(c[1]||"",d);return c[0]+"?"+l}function lr(i,e){return i.filter(r=>e.includes(r)).length===i.length}function Vc(i){return Object.fromEntries(i.entries())}function Kc(i){return new Map(Object.entries(i))}function Rt(i=Dt.FIVE_MINUTES,e){let r=(0,Dt.toMiliseconds)(i||Dt.FIVE_MINUTES),t,s,n;return{resolve:o=>{n&&t&&(clearTimeout(n),t(o))},reject:o=>{n&&s&&(clearTimeout(n),s(o))},done:()=>new Promise((o,a)=>{n=setTimeout(()=>{a(new Error(e))},r),t=o,s=a})}}function pr(i,e,r){return new Promise(async(t,s)=>{let n=setTimeout(()=>s(new Error(r)),e);try{let o=await i;t(o)}catch(o){s(o)}clearTimeout(n)})}function Pp(i,e){if(typeof e=="string"&&e.startsWith(`${i}:`))return e;if(i.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(i.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${i}`)}function Lp(i){return Pp("topic",i)}function Up(i){return Pp("id",i)}function Io(i){let[e,r]=i.split(":"),t={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")t.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))t.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return t}function ve(i,e){return(0,Dt.fromMiliseconds)((e||Date.now())+(0,Dt.toMiliseconds)(i))}function ft(i){return Date.now()>=(0,Dt.toMiliseconds)(i)}function se(i,e){return`${i}${e?`:${e}`:""}`}function A1(i=[],e=[]){return[...new Set([...i,...e])]}async function Mp({id:i,topic:e,wcDeepLink:r}){var t;try{if(!r)return;let s=typeof r=="string"?JSON.parse(r):r,n=s?.href;if(typeof n!="string")return;let o=O1(n,i,e),a=Fi();if(a===qe.browser){if(!((t=(0,Tt.getDocument)())!=null&&t.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,P1()?"_blank":"_self","noreferrer noopener")}else a===qe.reactNative&&typeof window?.Linking<"u"&&await window.Linking.openURL(o)}catch(s){console.error(s)}}function O1(i,e,r){let t=`requestId=${e}&sessionTopic=${r}`;i.endsWith("/")&&(i=i.slice(0,-1));let s=`${i}`;if(i.startsWith("https://t.me")){let n=i.includes("?")?"&startapp=":"?startapp=";s=`${s}${n}${L1(t,!0)}`}else s=`${s}/wc?${t}`;return s}async function Fp(i,e){let r="";try{if(qr()&&(r=localStorage.getItem(e),r))return r;r=await i.getItem(e)}catch(t){console.error(t)}return r}function jc(i,e){if(!i.includes(e))return null;let r=i.split(/([&,?,=])/),t=r.indexOf(e);return r[t+2]}function $c(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,i=>{let e=Math.random()*16|0;return(i==="x"?e:e&3|8).toString(16)})}function ki(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function P1(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function L1(i,e=!1){let r=Buffer.from(i).toString("base64");return e?r.replace(/[=]/g,""):r}function kp(i){return Buffer.from(i,"base64").toString("utf-8")}async function M1(i,e,r,t,s,n){switch(r.t){case"eip191":return F1(i,e,r.s);case"eip1271":return await k1(i,e,r.s,t,s,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function F1(i,e,r){return Vf(no(e),r).toLowerCase()===i.toLowerCase()}async function k1(i,e,r,t,s,n){let o=Ui(t);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${t}`);try{let a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",d=r.substring(2),l=no(e).substring(2),p=a+l+c+h+d,f=await fetch(`${n||U1}/?chainId=${t}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:B1(),jsonrpc:"2.0",method:"eth_call",params:[{to:i,data:p},"latest"]})}),{result:g}=await f.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function B1(){return Date.now()+Math.floor(Math.random()*1e3)}async function Gc(i){let{cacao:e,projectId:r}=i,{s:t,p:s}=e,n=Wc(s,s.iss),o=Bi(s.iss);return await M1(o,n,t,Do(s.iss),r)}function J1(i){return Buffer.from(JSON.stringify(i)).toString("base64")}function Y1(i){return JSON.parse(Buffer.from(i,"base64").toString("utf-8"))}function dr(i){if(!i)throw new Error("No recap provided, value is undefined");if(!i.att)throw new Error("No `att` property found");let e=Object.keys(i.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(r=>{let t=i.att[r];if(Array.isArray(t))throw new Error(`Resource must be an object: ${r}`);if(typeof t!="object")throw new Error(`Resource must be an object: ${r}`);if(!Object.keys(t).length)throw new Error(`Resource object is empty: ${r}`);Object.keys(t).forEach(s=>{let n=t[s];if(!Array.isArray(n))throw new Error(`Ability limits ${s} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${s} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${s}) must be an array of objects, found: ${o}`)})})})}function X1(i,e,r,t={}){return r?.sort((s,n)=>s.localeCompare(n)),{att:{[i]:Q1(e,r,t)}}}function Q1(i,e,r={}){e=e?.sort((s,n)=>s.localeCompare(n));let t=e.map(s=>({[`${i}/${s}`]:[r]}));return Object.assign({},...t)}function Bp(i){return dr(i),`urn:recap:${J1(i).replace(/=/g,"")}`}function Pi(i){let e=Y1(i.replace("urn:recap:",""));return dr(e),e}function qp(i,e,r){let t=X1(i,e,r);return Bp(t)}function Z1(i){return i&&i.includes("urn:recap:")}function zp(i,e){let r=Pi(i),t=Pi(e),s=eE(r,t);return Bp(s)}function eE(i,e){dr(i),dr(e);let r=Object.keys(i.att).concat(Object.keys(e.att)).sort((s,n)=>s.localeCompare(n)),t={att:{}};return r.forEach(s=>{var n,o;Object.keys(((n=i.att)==null?void 0:n[s])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[s])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,h;t.att[s]=H1($1({},t.att[s]),{[a]:((c=i.att[s])==null?void 0:c[a])||((h=e.att[s])==null?void 0:h[a])})})}),t}function tE(i="",e){dr(e);let r="I further authorize the stated URI to perform the following actions on my behalf: ";if(i.includes(r))return i;let t=[],s=0;Object.keys(e.att).forEach(a=>{let c=Object.keys(e.att[a]).map(l=>({ability:l.split("/")[0],action:l.split("/")[1]}));c.sort((l,p)=>l.action.localeCompare(p.action));let h={};c.forEach(l=>{h[l.ability]||(h[l.ability]=[]),h[l.ability].push(l.action)});let d=Object.keys(h).map(l=>(s++,`(${s}) '${l}': '${h[l].join("', '")}' for '${a}'.`));t.push(d.join(", ").replace(".,","."))});let n=t.join(" "),o=`${r}${n}`;return`${i?i+" ":""}${o}`}function Jc(i){var e;let r=Pi(i);dr(r);let t=(e=r.att)==null?void 0:e.eip155;return t?Object.keys(t).map(s=>s.split("/")[1]):[]}function Yc(i){let e=Pi(i);dr(e);let r=[];return Object.values(e.att).forEach(t=>{Object.values(t).forEach(s=>{var n;(n=s?.[0])!=null&&n.chains&&r.push(s[0].chains)})}),[...new Set(r.flat())]}function qi(i){if(!i)return;let e=i?.[i.length-1];return Z1(e)?e:void 0}function jp(){let i=So.generateKeyPair();return{privateKey:we(i.secretKey,Ae),publicKey:we(i.publicKey,Ae)}}function To(){let i=(0,Li.randomBytes)(Xc);return we(i,Ae)}function $p(i,e){let r=So.sharedKey(_e(i,Ae),_e(e,Ae),!0),t=new Cp.HKDF(Br.SHA256,r).expand(Xc);return we(t,Ae)}function jr(i){let e=(0,Br.hash)(_e(i,Ae));return we(e,Ae)}function rt(i){let e=(0,Br.hash)(_e(i,zi));return we(e,Ae)}function Hp(i){return _e(`${i}`,Vp)}function qt(i){return Number(we(i,Vp))}function Gp(i){let e=Hp(typeof i.type<"u"?i.type:Kp);if(qt(e)===tt&&typeof i.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let r=typeof i.senderPublicKey<"u"?_e(i.senderPublicKey,Ae):void 0,t=typeof i.iv<"u"?_e(i.iv,Ae):(0,Li.randomBytes)(Oi),s=new qc.ChaCha20Poly1305(_e(i.symKey,Ae)).seal(t,_e(i.message,zi));return Xp({type:e,sealed:s,iv:t,senderPublicKey:r,encoding:i.encoding})}function Wp(i,e){let r=Hp(Kr),t=(0,Li.randomBytes)(Oi),s=_e(i,zi);return Xp({type:r,sealed:s,iv:t,encoding:e})}function Jp(i){let e=new qc.ChaCha20Poly1305(_e(i.symKey,Ae)),{sealed:r,iv:t}=$r({encoded:i.encoded,encoding:i?.encoding}),s=e.open(t,r);if(s===null)throw new Error("Failed to decrypt");return we(s,zi)}function Yp(i,e){let{sealed:r}=$r({encoded:i,encoding:e});return we(r,zi)}function Xp(i){let{encoding:e=pt}=i;if(qt(i.type)===Kr)return we(ir([i.type,i.sealed]),e);if(qt(i.type)===tt){if(typeof i.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return we(ir([i.type,i.senderPublicKey,i.iv,i.sealed]),e)}return we(ir([i.type,i.iv,i.sealed]),e)}function $r(i){let{encoded:e,encoding:r=pt}=i,t=_e(e,r),s=t.slice(rE,vp),n=vp;if(qt(s)===tt){let h=n+Xc,d=h+Oi,l=t.slice(n,h),p=t.slice(h,d),f=t.slice(d);return{type:s,sealed:f,iv:p,senderPublicKey:l}}if(qt(s)===Kr){let h=t.slice(n),d=(0,Li.randomBytes)(Oi);return{type:s,sealed:h,iv:d}}let o=n+Oi,a=t.slice(n,o),c=t.slice(o);return{type:s,sealed:c,iv:a}}function Qp(i,e){let r=$r({encoded:i,encoding:e?.encoding});return Qc({type:qt(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?we(r.senderPublicKey,Ae):void 0,receiverPublicKey:e?.receiverPublicKey})}function Qc(i){let e=i?.type||Kp;if(e===tt){if(typeof i?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof i?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:i?.senderPublicKey,receiverPublicKey:i?.receiverPublicKey}}function Zc(i){return i.type===tt&&typeof i.senderPublicKey=="string"&&typeof i.receiverPublicKey=="string"}function eu(i){return i.type===Kr}function iE(i){return new fp("p256").keyFromPublic({x:Buffer.from(i.x,"base64").toString("hex"),y:Buffer.from(i.y,"base64").toString("hex")},"hex")}function sE(i){let e=i.replace(/-/g,"+").replace(/_/g,"/"),r=e.length%4;return r>0&&(e+="=".repeat(4-r)),e}function nE(i){return Buffer.from(sE(i),"base64")}function Zp(i,e){let[r,t,s]=i.split("."),n=nE(s);if(n.length!==64)throw new Error("Invalid signature length");let o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),c=`${r}.${t}`,h=new Br.SHA256().update(Buffer.from(c)).digest(),d=iE(e),l=Buffer.from(h).toString("hex");if(!d.verify(l,{r:o,s:a}))throw new Error("Invalid signature");return Lr(i).payload}function Ro(i){return i?.relay||{protocol:oE}}function Hr(i){let e=gp[i];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${i}`);return e}function fE(i,e="-"){let r={},t="relay"+e;return Object.keys(i).forEach(s=>{if(s.startsWith(t)){let n=s.replace(t,""),o=i[s];r[n]=o}}),r}function tu(i){if(!i.includes("wc:")){let c=kp(i);c!=null&&c.includes("wc:")&&(i=c)}i=i.includes("wc://")?i.replace("wc://",""):i,i=i.includes("wc:")?i.replace("wc:",""):i;let e=i.indexOf(":"),r=i.indexOf("?")!==-1?i.indexOf("?"):void 0,t=i.substring(0,e),s=i.substring(e+1,r).split("@"),n=typeof r<"u"?i.substring(r):"",o=gc(n),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:t,topic:pE(s[0]),version:parseInt(s[1],10),symKey:o.symKey,relay:fE(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function pE(i){return i.startsWith("//")?i.substring(2):i}function gE(i,e="-"){let r="relay",t={};return Object.keys(i).forEach(s=>{let n=r+e+s;i[s]&&(t[n]=i[s])}),t}function ru(i){return`${i.protocol}:${i.topic}@${i.version}?`+mc(Ip(dE(Ip({symKey:i.symKey},gE(i.relay)),{expiryTimestamp:i.expiryTimestamp}),i.methods?{methods:i.methods.join(",")}:{}))}function Vi(i,e,r){return`${i}?wc_ev=${r}&topic=${e}`}function Gr(i){let e=[];return i.forEach(r=>{let[t,s]=r.split(":");e.push(`${t}:${s}`)}),e}function mE(i){let e=[];return Object.values(i).forEach(r=>{e.push(...Gr(r.accounts))}),e}function yE(i,e){let r=[];return Object.values(i).forEach(t=>{Gr(t.accounts).includes(e)&&r.push(...t.methods)}),r}function wE(i,e){let r=[];return Object.values(i).forEach(t=>{Gr(t.accounts).includes(e)&&r.push(...t.events)}),r}function bE(i){let e={};return i?.forEach(r=>{let[t,s]=r.split(":");e[t]||(e[t]={accounts:[],chains:[],events:[]}),e[t].accounts.push(r),e[t].chains.push(`${t}:${s}`)}),e}function iu(i,e){e=e.map(t=>t.replace("did:pkh:",""));let r=bE(e);for(let[t,s]of Object.entries(r))s.methods?s.methods=A1(s.methods,i):s.methods=i,s.events=["chainChanged","accountsChanged"];return r}function B(i,e){let{message:r,code:t}=_E[i];return{message:e?`${r} ${e}`:r,code:t}}function ce(i,e){let{message:r,code:t}=EE[i];return{message:e?`${r} ${e}`:r,code:t}}function Vt(i,e){return Array.isArray(i)?typeof e<"u"&&i.length?i.every(e):!0:!1}function Ki(i){return Object.getPrototypeOf(i)===Object.prototype&&Object.keys(i).length}function De(i){return typeof i>"u"}function me(i,e){return e&&De(i)?!0:typeof i=="string"&&!!i.trim().length}function su(i,e){return e&&De(i)?!0:typeof i=="number"&&!isNaN(i)}function eg(i,e){let{requiredNamespaces:r}=e,t=Object.keys(i.namespaces),s=Object.keys(r),n=!0;return lr(s,t)?(t.forEach(o=>{let{accounts:a,methods:c,events:h}=i.namespaces[o],d=Gr(a),l=r[o];(!lr(Np(o,l),d)||!lr(l.methods,c)||!lr(l.events,h))&&(n=!1)}),n):!1}function xo(i){return me(i,!1)&&i.includes(":")?i.split(":").length===2:!1}function vE(i){if(me(i,!1)&&i.includes(":")){let e=i.split(":");if(e.length===3){let r=e[0]+":"+e[1];return!!e[2]&&xo(r)}}return!1}function tg(i){function e(r){try{return typeof new URL(r)<"u"}catch{return!1}}try{if(me(i,!1)){if(e(i))return!0;let r=kp(i);return e(r)}}catch{}return!1}function rg(i){var e;return(e=i?.proposer)==null?void 0:e.publicKey}function ig(i){return i?.topic}function sg(i,e){let r=null;return me(i?.publicKey,!1)||(r=B("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Dp(i){let e=!0;return Vt(i)?i.length&&(e=i.every(r=>me(r,!1))):e=!1,e}function xE(i,e,r){let t=null;return Vt(e)&&e.length?e.forEach(s=>{t||xo(s)||(t=ce("UNSUPPORTED_CHAINS",`${r}, chain ${s} should be a string and conform to "namespace:chainId" format`))}):xo(i)||(t=ce("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),t}function SE(i,e,r){let t=null;return Object.entries(i).forEach(([s,n])=>{if(t)return;let o=xE(s,Np(s,n),`${e} ${r}`);o&&(t=o)}),t}function IE(i,e){let r=null;return Vt(i)?i.forEach(t=>{r||vE(t)||(r=ce("UNSUPPORTED_ACCOUNTS",`${e}, account ${t} should be a string and conform to "namespace:chainId:address" format`))}):r=ce("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function DE(i,e){let r=null;return Object.values(i).forEach(t=>{if(r)return;let s=IE(t?.accounts,`${e} namespace`);s&&(r=s)}),r}function TE(i,e){let r=null;return Dp(i?.methods)?Dp(i?.events)||(r=ce("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=ce("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function ng(i,e){let r=null;return Object.values(i).forEach(t=>{if(r)return;let s=TE(t,`${e}, namespace`);s&&(r=s)}),r}function og(i,e,r){let t=null;if(i&&Ki(i)){let s=ng(i,e);s&&(t=s);let n=SE(i,e,r);n&&(t=n)}else t=B("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return t}function Co(i,e){let r=null;if(i&&Ki(i)){let t=ng(i,e);t&&(r=t);let s=DE(i,e);s&&(r=s)}else r=B("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function nu(i){return me(i.protocol,!0)}function ag(i,e){let r=!1;return e&&!i?r=!0:i&&Vt(i)&&i.length&&i.forEach(t=>{r=nu(t)}),r}function cg(i){return typeof i=="number"}function Oe(i){return typeof i<"u"&&typeof i!==null}function ug(i){return!(!i||typeof i!="object"||!i.code||!su(i.code,!1)||!i.message||!me(i.message,!1))}function hg(i){return!(De(i)||!me(i.method,!1))}function lg(i){return!(De(i)||De(i.result)&&De(i.error)||!su(i.id,!1)||!me(i.jsonrpc,!1))}function dg(i){return!(De(i)||!me(i.name,!1))}function ou(i,e){return!(!xo(e)||!mE(i).includes(e))}function fg(i,e,r){return me(r,!1)?yE(i,e).includes(r):!1}function pg(i,e,r){return me(r,!1)?wE(i,e).includes(r):!1}function au(i,e,r){let t=null,s=RE(i),n=CE(e),o=Object.keys(s),a=Object.keys(n),c=Tp(Object.keys(i)),h=Tp(Object.keys(e)),d=c.filter(l=>!h.includes(l));return d.length&&(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces. - Required: ${d.toString()} - Received: ${Object.keys(e).toString()}`)),lr(o,a)||(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces. +`;var yh={...nh,...sh,...oh,...ah,...fh,...ch,...hh,...uh,...dh,...lh},dM={...vh,...mh};function rp(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var tp=rp("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),wh=rp("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=eo(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new nw:typeof navigator<"u"?dp(navigator.userAgent):hw()}function fw(r){return r!==""&&aw.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function dp(r){var e=fw(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new iw;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var Bp=Nw(),Ih;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(Ih||(Ih={}));var or;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(or||(or={}));var kp="0123456789abcdef",at=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();Ka[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(zp>Ka[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(Up)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(d=>{let h=i[d];try{if(h instanceof Uint8Array){let b="";for(let y=0;y>4],b+=kp[h[y]&15];n.push(d+"=Uint8Array(0x"+b+")")}else n.push(d+"="+JSON.stringify(h))}catch{n.push(d+"="+JSON.stringify(i[d].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case or.NUMERIC_FAULT:{o="NUMERIC_FAULT";let d=e;switch(d){case"overflow":case"underflow":case"division-by-zero":o+="-"+d;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case or.CALL_EXCEPTION:case or.INSUFFICIENT_FUNDS:case or.MISSING_NEW:case or.NONCE_EXPIRED:case or.REPLACEMENT_UNDERPRICED:case or.TRANSACTION_REPLACED:case or.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(d){f[d]=i[d]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),Bp&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bp})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Sh||(Sh=new r(Fp)),Sh}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qp){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Up=!!e,qp=!!t}static setLogLevel(e){let t=Ka[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}zp=t}static from(e){return new r(e)}};at.errors=or;at.levels=Ih;var Kp="bytes/5.7.0";var nt=new at(Kp);function Vp(r){return!!r.toHexString}function is(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return is(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function $p(r){return ar(r)&&!(r.length%2)||Ah(r)}function jp(r){return typeof r=="number"&&r==r&&r%1===0}function Ah(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!jp(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function We(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),is(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r)&&(r=r.toHexString()),ar(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":nt.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nWe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),is(i)}function Cw(r,e){r=We(r),r.length>e&&nt.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),is(t)}function ar(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var Mh="0123456789abcdef";function _t(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Mh[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r))return r.toHexString();if(ar(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":nt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Ah(r)){let t="0x";for(let i=0;i>4]+Mh[n&15]}return t}return nt.throwArgumentError("invalid hexlify value","value",r)}function ja(r){if(typeof r!="string")r=_t(r);else if(!ar(r)||r.length%2)return null;return(r.length-2)/2}function Va(r,e,t){return typeof r!="string"?r=_t(r):(!ar(r)||r.length%2)&&nt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Ti(r,e){for(typeof r!="string"?r=_t(r):ar(r)||nt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&nt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function $a(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if($p(r)){let t=We(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64))):t.length===65?(e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64)),e.v=t[64]):nt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:nt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=_t(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=Cw(We(e._vs),32);e._vs=_t(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&nt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=_t(n);e.s==null?e.s=o:e.s!==o&&nt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?nt.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&nt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!ar(e.r)?nt.throwArgumentError("signature missing or invalid r","signature",r):e.r=Ti(e.r,32),e.s==null||!ar(e.s)?nt.throwArgumentError("signature missing or invalid s","signature",r):e.s=Ti(e.s,32);let t=We(e.s);t[0]>=128&&nt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=_t(t);e._vs&&(ar(e._vs)||nt.throwArgumentError("signature invalid _vs","signature",r),e._vs=Ti(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&nt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function ns(r){return"0x"+Hp.default.keccak_256(We(r))}var Jp=qe(Ph());var Wp="bignumber/5.7.0";var Ow=Jp.default.BN,sA=new at(Wp);function Nh(r){return new Ow(r,36).toString(16)}var Yp="strings/5.7.0";var Xp=new at(Yp),oo;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(oo||(oo={}));var yn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(yn||(yn={}));function Fw(r,e,t,i,n){return Xp.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function Zp(r,e,t,i,n){if(r===yn.BAD_PREFIX||r===yn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===yn.OVERRUN?t.length-e-1:0}function qw(r,e,t,i,n){return r===yn.OVERLONG?(i.push(n),0):(i.push(65533),Zp(r,e,t,i,n))}var Uw=Object.freeze({error:Fw,ignore:Zp,replace:qw});function ao(r,e=oo.current){e!=oo.current&&(Xp.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return We(t)}var Qp=`Ethereum Signed Message: +`;function Ha(r){return typeof r=="string"&&(r=ao(r)),ns(Rh([ao(Qp),ao(String(r.length)),r]))}var e1="address/5.7.0";var fo=new at(e1);function t1(r){ar(r,20)||fo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=We(ns(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var Bw=9007199254740991;function kw(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var Ch={};for(let r=0;r<10;r++)Ch[String(r)]=String(r);for(let r=0;r<26;r++)Ch[String.fromCharCode(65+r)]=String(10+r);var r1=Math.floor(kw(Bw));function Kw(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Ch[i]).join("");for(;e.length>=r1;){let i=e.substring(0,r1);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function i1(r){let e=null;if(typeof r!="string"&&fo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=t1(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&fo.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Kw(r)&&fo.throwArgumentError("bad icap checksum","address",r),e=Nh(r.substring(4));e.length<40;)e="0"+e;e=t1("0x"+e)}else fo.throwArgumentError("invalid address","address",r);return e}var n1="properties/5.7.0";var OA=new at(n1);function ss(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Ce=qe(Ph()),$r=qe(lo());function ds(r,e,t){return t={path:e,exports:{},require:function(i,n){return u8(i,n??t.path)}},r(t,t.exports),t.exports}function u8(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Hh=k1;function k1(r,e){if(!r)throw new Error(e||"Assertion failed")}k1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var ur=ds(function(r,e){"use strict";var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var d=[];if(typeof o!="string"){for(var h=0;h>8,S=b&255;y?d.push(y,S):d.push(S)}return d}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",d=0;d(S>>1)-1?T=(S>>1)-C:T=C,I.isubn(T)):T=0,y[M]=T,I.iushrn(1)}return y}t.getNAF=i;function n(d,h){var b=[[],[]];d=d.clone(),h=h.clone();for(var y=0,S=0,I;d.cmpn(-y)>0||h.cmpn(-S)>0;){var M=d.andln(3)+y&3,T=h.andln(3)+S&3;M===3&&(M=-1),T===3&&(T=-1);var C;M&1?(I=d.andln(7)+y&7,(I===3||I===5)&&T===2?C=-M:C=M):C=0,b[0].push(C);var P;T&1?(I=h.andln(7)+S&7,(I===3||I===5)&&M===2?P=-T:P=T):P=0,b[1].push(P),2*y===C+1&&(y=1-y),2*S===P+1&&(S=1-S),d.iushrn(1),h.iushrn(1)}return b}t.getJSF=n;function s(d,h,b){var y="_"+h;d.prototype[h]=function(){return this[y]!==void 0?this[y]:this[y]=b.call(this)}}t.cachedProperty=s;function o(d){return typeof d=="string"?t.toArray(d,"hex"):d}t.parseBytes=o;function f(d){return new Ce.default(d,"hex","le")}t.intFromLE=f}),Xa=zt.getNAF,d8=zt.getJSF,Za=zt.assert;function Ci(r,e){this.type=r,this.p=new Ce.default(e.p,16),this.red=e.prime?Ce.default.red(e.prime):Ce.default.mont(this.p),this.zero=new Ce.default(0).toRed(this.red),this.one=new Ce.default(1).toRed(this.red),this.two=new Ce.default(2).toRed(this.red),this.n=e.n&&new Ce.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var _n=Ci;Ci.prototype.point=function(){throw new Error("Not implemented")};Ci.prototype.validate=function(){throw new Error("Not implemented")};Ci.prototype._fixedNafMul=function(e,t){Za(e.precomputed);var i=e._getDoubles(),n=Xa(t,1,this._bitLength),s=(1<=f;h--)d=(d<<1)+n[h];o.push(d)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;d--){for(var h=0;d>=0&&o[d]===0;d--)h++;if(d>=0&&h++,f=f.dblp(h),d<0)break;var b=o[d];Za(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};Ci.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,d=this._wnafT3,h=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){d[M]=Xa(i[M],o[M],this._bitLength),d[T]=Xa(i[T],o[T],this._bitLength),h=Math.max(d[M].length,h),h=Math.max(d[T].length,h);continue}var C=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(C[1]=t[M].add(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].add(t[T].neg())):(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],U=d8(i[M],i[T]);for(h=Math.max(U[0].length,h),d[M]=new Array(h),d[T]=new Array(h),y=0;y=0;b--){for(var L=0;b>=0;){var O=!0;for(y=0;y=0&&L++,j=j.dblp(L),b<0)break;for(y=0;y0?S=f[y][W-1>>1]:W<0&&(S=f[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Xt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=h,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};Zt.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),d=o.mul(n.a),h=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(d),S=h.add(b).neg();return{k1:y,k2:S}};Zt.prototype.pointFromX=function(e,t){e=new Ce.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};Zt.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};Zt.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ft.prototype.isInfinity=function(){return this.inf};ft.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ft.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ft.prototype.getX=function(){return this.x.fromRed()};ft.prototype.getY=function(){return this.y.fromRed()};ft.prototype.mul=function(e){return e=new Ce.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ft.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ft.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ft.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ft.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ft.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function gt(r,e,t,i){_n.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ce.default(0)):(this.x=new Ce.default(e,16),this.y=new Ce.default(t,16),this.z=new Ce.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Gh(gt,_n.BasePoint);Zt.prototype.jpoint=function(e,t,i){return new gt(this,e,t,i)};gt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};gt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};gt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),d=n.redSub(s),h=o.redSub(f);if(d.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=d.redSqr(),y=b.redMul(d),S=n.redMul(b),I=h.redSqr().redIAdd(y).redISub(S).redISub(S),M=h.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(I,M,T)};gt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),d=s.redSub(o);if(f.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),b=h.redMul(f),y=i.redMul(h),S=d.redSqr().redIAdd(b).redISub(y).redISub(y),I=d.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};gt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};gt.prototype.inspect=function(){return this.isInfinity()?"":""};gt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ja=ds(function(r,e){"use strict";var t=e;t.base=_n,t.short=p8,t.mont=null,t.edwards=null}),Ya=ds(function(r,e){"use strict";var t=e,i=zt.assert;function n(f){f.type==="short"?this.curve=new Ja.short(f):f.type==="edwards"?this.curve=new Ja.edwards(f):this.curve=new Ja.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,d){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var h=new n(d);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:h}),h}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:$r.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:$r.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:$r.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:$r.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:$r.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:$r.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Ni(r){if(!(this instanceof Ni))return new Ni(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ur.toArray(r.entropy,r.entropyEnc||"hex"),t=ur.toArray(r.nonce,r.nonceEnc||"hex"),i=ur.toArray(r.pers,r.persEnc||"hex");Hh(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var K1=Ni;Ni.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Ni.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ur.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var g8=zt.assert;function Qa(r,e){if(r instanceof Qa)return r;this._importDER(r,e)||(g8(r.r&&r.s,"Signature without r or s"),this.r=new Ce.default(r.r,16),this.s=new Ce.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ef=Qa;function b8(){this.place=0}function jh(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function B1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Qa.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=B1(t),i=B1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Vh(n,t.length),n=n.concat(t),n.push(2),Vh(n,i.length);var s=n.concat(i),o=[48];return Vh(o,s.length),o=o.concat(s),zt.encode(o,e)};var v8=function(){throw new Error("unsupported")},j1=zt.assert;function Yt(r){if(!(this instanceof Yt))return new Yt(r);typeof r=="string"&&(j1(Object.prototype.hasOwnProperty.call(Ya,r),"Unknown curve "+r),r=Ya[r]),r instanceof Ya.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var m8=Yt;Yt.prototype.keyPair=function(e){return new Wh(this,e)};Yt.prototype.keyFromPrivate=function(e,t){return Wh.fromPrivate(this,e,t)};Yt.prototype.keyFromPublic=function(e,t){return Wh.fromPublic(this,e,t)};Yt.prototype.genKeyPair=function(e){e||(e={});for(var t=new K1({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v8(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Ce.default(2));;){var s=new Ce.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Yt.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Yt.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Ce.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),d=new K1({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new Ce.default(1)),b=0;;b++){var y=n.k?n.k(b):new Ce.default(d.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var C=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),C^=1),new ef({r:M,s:T,recoveryParam:C})}}}}}};Yt.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Ce.default(e,16)),i=this.keyFromPublic(i,n),t=new ef(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),d=f.mul(e).umod(this.n),h=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};Yt.prototype.recoverPubKey=function(r,e,t,i){j1((3&t)===t,"The recovery param is more than two bits"),e=new ef(e,i);var n=this.n,s=new Ce.default(r),o=e.r,f=e.s,d=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),d):o=this.curve.pointFromX(o,d);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};Yt.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ef(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var y8=ds(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=zt,t.rand=function(){throw new Error("unsupported")},t.curve=Ja,t.curves=Ya,t.ec=m8,t.eddsa=null}),V1=y8.ec;var $1="signing-key/5.7.0";var Yh=new at($1),Jh=null;function Hr(){return Jh||(Jh=new V1("secp256k1")),Jh}var Xh=class{constructor(e){ss(this,"curve","secp256k1"),ss(this,"privateKey",_t(e)),ja(this.privateKey)!==32&&Yh.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Hr().keyFromPrivate(We(this.privateKey));ss(this,"publicKey","0x"+t.getPublic(!1,"hex")),ss(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),ss(this,"_isSigningKey",!0)}_addPoint(e){let t=Hr().keyFromPublic(We(this.publicKey)),i=Hr().keyFromPublic(We(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=We(e);i.length!==32&&Yh.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return $a({recoveryParam:n.recoveryParam,r:Ti("0x"+n.r.toString(16),32),s:Ti("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=Hr().keyFromPublic(We(Zh(e)));return Ti("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function H1(r,e){let t=$a(e),i={r:We(t.r),s:We(t.s)};return"0x"+Hr().recoverPubKey(We(r),i,t.recoveryParam).encode("hex",!1)}function Zh(r,e){let t=We(r);if(t.length===32){let i=new Xh(t);return e?"0x"+Hr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?_t(t):"0x"+Hr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Hr().keyFromPublic(t).getPublic(!0,"hex"):_t(t)}return Yh.throwArgumentError("invalid public or private key","key","[REDACTED]")}var G1="transactions/5.7.0";var pR=new at(G1),W1;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(W1||(W1={}));function w8(r){let e=Zh(r);return i1(Va(ns(Va(e,1)),12))}function J1(r,e){return w8(H1(We(r),e))}var Eu=qe(ig()),xb=qe(cg()),Eo=qe(Js()),ws=qe(ug()),Sf=qe(gg());var Eb=qe(fb());var cb={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var E4=":";function So(r){let[e,t]=r.split(E4);return{namespace:e,reference:t}}function Sb(r,e){return r.includes(":")?[r]:e.chains||[]}var S4=Object.defineProperty,hb=Object.getOwnPropertySymbols,I4=Object.prototype.hasOwnProperty,M4=Object.prototype.propertyIsEnumerable,ub=(r,e,t)=>e in r?S4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,db=(r,e)=>{for(var t in e||(e={}))I4.call(e,t)&&ub(r,t,e[t]);if(hb)for(var t of hb(e))M4.call(e,t)&&ub(r,t,e[t]);return r},A4="ReactNative",Ft={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var R4="js";function Io(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Tn(){return!(0,yi.getDocument)()&&!!(0,yi.getNavigator)()&&navigator.product===A4}function _s(){return!Io()&&!!(0,yi.getNavigator)()&&!!(0,yi.getDocument)()}function Mo(){return Tn()?Ft.reactNative:Io()?Ft.node:_s()?Ft.browser:Ft.unknown}function Ib(){var r;try{return Tn()&&typeof window<"u"&&typeof window?.Application<"u"?(r=window.Application)==null?void 0:r.applicationId:void 0}catch{return}}function T4(r,e){let t=ys.parse(r);return t=db(db({},t),e),r=ys.stringify(t),r}function xs(){return(0,_b.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function D4(){if(Mo()===Ft.reactNative&&typeof window<"u"&&typeof window?.Platform<"u"){let{OS:t,Version:i}=window.Platform;return[t,i].join("-")}let r=lp();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function P4(){var r;let e=Mo();return e===Ft.browser?[e,((r=(0,yi.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function Su(r,e,t){let i=D4(),n=P4();return[[r,e].join("-"),[R4,t].join("-"),i,n].join("/")}function Mb({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){let d=t.split("?"),h=Su(r,e,i),b={auth:n,ua:h,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},y=T4(d[1]||"",b);return d[0]+"?"+y}function An(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Iu(r){return Object.fromEntries(r.entries())}function Mu(r){return new Map(Object.entries(r))}function wi(r=mi.FIVE_MINUTES,e){let t=(0,mi.toMiliseconds)(r||mi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Dn(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Ab(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Rb(r){return Ab("topic",r)}function Tb(r){return Ab("id",r)}function If(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function st(r,e){return(0,mi.fromMiliseconds)((e||Date.now())+(0,mi.toMiliseconds)(r))}function Xr(r){return Date.now()>=(0,mi.toMiliseconds)(r)}function Oe(r,e){return`${r}${e?`:${e}`:""}`}function N4(r=[],e=[]){return[...new Set([...r,...e])]}async function Db({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=C4(s,r,e),f=Mo();if(f===Ft.browser){if(!((i=(0,yi.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,O4()?"_blank":"_self","noreferrer noopener")}else f===Ft.reactNative&&typeof window?.Linking<"u"&&await window.Linking.openURL(o)}catch(n){console.error(n)}}function C4(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${L4(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Pb(r,e){let t="";try{if(_s()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Au(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ru(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Ao(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function O4(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function L4(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Nb(r){return Buffer.from(r,"base64").toString("utf-8")}var F4="https://rpc.walletconnect.org/v1";async function q4(r,e,t,i,n,s){switch(t.t){case"eip191":return U4(r,e,t.s);case"eip1271":return await z4(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function U4(r,e,t){return J1(Ha(e),t).toLowerCase()===r.toLowerCase()}async function z4(r,e,t,i,n,s){let o=So(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let f="0x1626ba7e",d="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),y=Ha(e).substring(2),S=f+y+d+h+b,I=await fetch(`${s||F4}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:B4(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:M}=await I.json();return M?M.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function B4(){return Date.now()+Math.floor(Math.random()*1e3)}var k4=Object.defineProperty,K4=Object.defineProperties,j4=Object.getOwnPropertyDescriptors,lb=Object.getOwnPropertySymbols,V4=Object.prototype.hasOwnProperty,$4=Object.prototype.propertyIsEnumerable,pb=(r,e,t)=>e in r?k4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,H4=(r,e)=>{for(var t in e||(e={}))V4.call(e,t)&&pb(r,t,e[t]);if(lb)for(var t of lb(e))$4.call(e,t)&&pb(r,t,e[t]);return r},G4=(r,e)=>K4(r,j4(e)),W4="did:pkh:",Tu=r=>r?.split(":"),J4=r=>{let e=r&&Tu(r);if(e)return r.includes(W4)?e[3]:e[1]},Mf=r=>{let e=r&&Tu(r);if(e)return e[2]+":"+e[3]},Ro=r=>{let e=r&&Tu(r);if(e)return e.pop()};async function Du(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Pu(n,n.iss),o=Ro(n.iss);return await q4(o,s,i,Mf(n.iss),t)}var Pu=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ro(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${J4(e)}`,d=`Nonce: ${r.nonce}`,h=`Issued At: ${r.iat}`,b=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(T=>` +- ${T}`).join("")}`:void 0,M=To(r.resources);if(M){let T=xo(M);n=r_(n,T)}return[t,i,"",n,"",s,o,f,d,h,b,y,S,I].filter(T=>T!=null).join(` +`)};function Y4(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function X4(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Rn(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Z4(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Q4(e,t,i)}}}function Q4(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function Cb(r){return Rn(r),`urn:recap:${Y4(r).replace(/=/g,"")}`}function xo(r){let e=X4(r.replace("urn:recap:",""));return Rn(e),e}function Ob(r,e,t){let i=Z4(r,e,t);return Cb(i)}function e_(r){return r&&r.includes("urn:recap:")}function Lb(r,e){let t=xo(r),i=xo(e),n=t_(t,i);return Cb(n)}function t_(r,e){Rn(r),Rn(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,d)=>f.localeCompare(d)).forEach(f=>{var d,h;i.att[n]=G4(H4({},i.att[n]),{[f]:((d=r.att[n])==null?void 0:d[f])||((h=e.att[n])==null?void 0:h[f])})})}),i}function r_(r="",e){Rn(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(f=>{let d=Object.keys(e.att[f]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));d.sort((y,S)=>y.action.localeCompare(S.action));let h={};d.forEach(y=>{h[y.ability]||(h[y.ability]=[]),h[y.ability].push(y.action)});let b=Object.keys(h).map(y=>(n++,`(${n}) '${y}': '${h[y].join("', '")}' for '${f}'.`));i.push(b.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Nu(r){var e;let t=xo(r);Rn(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Cu(r){let e=xo(r);Rn(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function To(r){if(!r)return;let e=r?.[r.length-1];return e_(e)?e:void 0}var Fb="base10",It="base16",Zr="base64pad",Es="base64url",Do="utf8",qb=0,lr=1,Ss=2,i_=0,gb=1,_o=12,Ou=32;function Ub(){let r=Sf.generateKeyPair();return{privateKey:Ze(r.secretKey,It),publicKey:Ze(r.publicKey,It)}}function Af(){let r=(0,Eo.randomBytes)(Ou);return Ze(r,It)}function zb(r,e){let t=Sf.sharedKey(rt(r,It),rt(e,It),!0),i=new xb.HKDF(ws.SHA256,t).expand(Ou);return Ze(i,It)}function Is(r){let e=(0,ws.hash)(rt(r,It));return Ze(e,It)}function pr(r){let e=(0,ws.hash)(rt(r,Do));return Ze(e,It)}function Bb(r){return rt(`${r}`,Fb)}function Bi(r){return Number(Ze(r,Fb))}function kb(r){let e=Bb(typeof r.type<"u"?r.type:qb);if(Bi(e)===lr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?rt(r.senderPublicKey,It):void 0,i=typeof r.iv<"u"?rt(r.iv,It):(0,Eo.randomBytes)(_o),n=new Eu.ChaCha20Poly1305(rt(r.symKey,It)).seal(i,rt(r.message,Do));return $b({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Kb(r,e){let t=Bb(Ss),i=(0,Eo.randomBytes)(_o),n=rt(r,Do);return $b({type:t,sealed:n,iv:i,encoding:e})}function jb(r){let e=new Eu.ChaCha20Poly1305(rt(r.symKey,It)),{sealed:t,iv:i}=Ms({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Ze(n,Do)}function Vb(r,e){let{sealed:t}=Ms({encoded:r,encoding:e});return Ze(t,Do)}function $b(r){let{encoding:e=Zr}=r;if(Bi(r.type)===Ss)return Ze(bn([r.type,r.sealed]),e);if(Bi(r.type)===lr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Ze(bn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Ze(bn([r.type,r.iv,r.sealed]),e)}function Ms(r){let{encoded:e,encoding:t=Zr}=r,i=rt(e,t),n=i.slice(i_,gb),s=gb;if(Bi(n)===lr){let h=s+Ou,b=h+_o,y=i.slice(s,h),S=i.slice(h,b),I=i.slice(b);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(Bi(n)===Ss){let h=i.slice(s),b=(0,Eo.randomBytes)(_o);return{type:n,sealed:h,iv:b}}let o=s+_o,f=i.slice(s,o),d=i.slice(o);return{type:n,sealed:d,iv:f}}function Hb(r,e){let t=Ms({encoded:r,encoding:e?.encoding});return Lu({type:Bi(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Ze(t.senderPublicKey,It):void 0,receiverPublicKey:e?.receiverPublicKey})}function Lu(r){let e=r?.type||qb;if(e===lr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Fu(r){return r.type===lr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function qu(r){return r.type===Ss}function n_(r){return new Eb.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function s_(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function o_(r){return Buffer.from(s_(r),"base64")}function Gb(r,e){let[t,i,n]=r.split("."),s=o_(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),d=`${t}.${i}`,h=new ws.SHA256().update(Buffer.from(d)).digest(),b=n_(e),y=Buffer.from(h).toString("hex");if(!b.verify(y,{r:o,s:f}))throw new Error("Invalid signature");return ts(r).payload}var a_="irn";function Rf(r){return r?.relay||{protocol:a_}}function As(r){let e=cb[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var f_=Object.defineProperty,c_=Object.defineProperties,h_=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertySymbols,u_=Object.prototype.hasOwnProperty,d_=Object.prototype.propertyIsEnumerable,vb=(r,e,t)=>e in r?f_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mb=(r,e)=>{for(var t in e||(e={}))u_.call(e,t)&&vb(r,t,e[t]);if(bb)for(var t of bb(e))d_.call(e,t)&&vb(r,t,e[t]);return r},l_=(r,e)=>c_(r,h_(e));function p_(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Uu(r){if(!r.includes("wc:")){let d=Nb(r);d!=null&&d.includes("wc:")&&(r=d)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=ys.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:g_(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:p_(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function g_(r){return r.startsWith("//")?r.substring(2):r}function b_(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function zu(r){return`${r.protocol}:${r.topic}@${r.version}?`+ys.stringify(mb(l_(mb({symKey:r.symKey},b_(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Po(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Rs(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function v_(r){let e=[];return Object.values(r).forEach(t=>{e.push(...Rs(t.accounts))}),e}function m_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.methods)}),t}function y_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.events)}),t}function w_(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Bu(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=w_(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=N4(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var __={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},x_={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function X(r,e){let{message:t,code:i}=x_[r];return{message:e?`${t} ${e}`:t,code:i}}function Ue(r,e){let{message:t,code:i}=__[r];return{message:e?`${t} ${e}`:t,code:i}}function Ki(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function No(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function vt(r){return typeof r>"u"}function Ye(r,e){return e&&vt(r)?!0:typeof r=="string"&&!!r.trim().length}function ku(r,e){return e&&vt(r)?!0:typeof r=="number"&&!isNaN(r)}function Wb(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return An(n,i)?(i.forEach(o=>{let{accounts:f,methods:d,events:h}=r.namespaces[o],b=Rs(f),y=t[o];(!An(Sb(o,y),b)||!An(y.methods,d)||!An(y.events,h))&&(s=!1)}),s):!1}function Ef(r){return Ye(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function E_(r){if(Ye(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&Ef(t)}}return!1}function Jb(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Ye(r,!1)){if(e(r))return!0;let t=Nb(r);return e(t)}}catch{}return!1}function Yb(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function Xb(r){return r?.topic}function Zb(r,e){let t=null;return Ye(r?.publicKey,!1)||(t=X("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function yb(r){let e=!0;return Ki(r)?r.length&&(e=r.every(t=>Ye(t,!1))):e=!1,e}function S_(r,e,t){let i=null;return Ki(e)&&e.length?e.forEach(n=>{i||Ef(n)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Ef(r)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function I_(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=S_(n,Sb(n,s),`${e} ${t}`);o&&(i=o)}),i}function M_(r,e){let t=null;return Ki(r)?r.forEach(i=>{t||E_(i)||(t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function A_(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=M_(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function R_(r,e){let t=null;return yb(r?.methods)?yb(r?.events)||(t=Ue("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Ue("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Qb(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=R_(i,`${e}, namespace`);n&&(t=n)}),t}function ev(r,e,t){let i=null;if(r&&No(r)){let n=Qb(r,e);n&&(i=n);let s=I_(r,e,t);s&&(i=s)}else i=X("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Tf(r,e){let t=null;if(r&&No(r)){let i=Qb(r,e);i&&(t=i);let n=A_(r,e);n&&(t=n)}else t=X("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ku(r){return Ye(r.protocol,!0)}function tv(r,e){let t=!1;return e&&!r?t=!0:r&&Ki(r)&&r.length&&r.forEach(i=>{t=Ku(i)}),t}function rv(r){return typeof r=="number"}function Mt(r){return typeof r<"u"&&typeof r!==null}function iv(r){return!(!r||typeof r!="object"||!r.code||!ku(r.code,!1)||!r.message||!Ye(r.message,!1))}function nv(r){return!(vt(r)||!Ye(r.method,!1))}function sv(r){return!(vt(r)||vt(r.result)&&vt(r.error)||!ku(r.id,!1)||!Ye(r.jsonrpc,!1))}function ov(r){return!(vt(r)||!Ye(r.name,!1))}function ju(r,e){return!(!Ef(e)||!v_(r).includes(e))}function av(r,e,t){return Ye(t,!1)?m_(r,e).includes(t):!1}function fv(r,e,t){return Ye(t,!1)?y_(r,e).includes(t):!1}function Vu(r,e,t){let i=null,n=T_(r),s=D_(e),o=Object.keys(n),f=Object.keys(s),d=wb(Object.keys(r)),h=wb(Object.keys(e)),b=d.filter(y=>!h.includes(y));return b.length&&(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. + Required: ${b.toString()} + Received: ${Object.keys(e).toString()}`)),An(o,f)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. Required: ${o.toString()} - Approved: ${a.toString()}`)),Object.keys(e).forEach(l=>{if(!l.includes(":")||t)return;let p=Gr(e[l].accounts);p.includes(l)||(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${l} - Required: ${l} - Approved: ${p.toString()}`))}),o.forEach(l=>{t||(lr(s[l].methods,n[l].methods)?lr(s[l].events,n[l].events)||(t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${l}`)):t=B("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${l}`))}),t}function RE(i){let e={};return Object.keys(i).forEach(r=>{var t;r.includes(":")?e[r]=i[r]:(t=i[r].chains)==null||t.forEach(s=>{e[s]={methods:i[r].methods,events:i[r].events}})}),e}function Tp(i){return[...new Set(i.map(e=>e.includes(":")?e.split(":")[0]:e))]}function CE(i){let e={};return Object.keys(i).forEach(r=>{r.includes(":")?e[r]=i[r]:Gr(i[r].accounts)?.forEach(s=>{e[s]={accounts:i[r].accounts.filter(n=>n.includes(`${s}:`)),methods:i[r].methods,events:i[r].events}})}),e}function gg(i,e){return su(i,!1)&&i<=e.max&&i>=e.min}function cu(){let i=Fi();return new Promise(e=>{switch(i){case qe.browser:e(NE());break;case qe.reactNative:e(AE());break;case qe.node:e(OE());break;default:e(!0)}})}function NE(){return qr()&&navigator?.onLine}async function AE(){return fr()&&typeof window<"u"&&window!=null&&window.NetInfo?(await window?.NetInfo.fetch())?.isConnected:!0}function OE(){return!0}function mg(i){switch(Fi()){case qe.browser:PE(i);break;case qe.reactNative:LE(i);break;case qe.node:break}}function PE(i){!fr()&&qr()&&(window.addEventListener("online",()=>i(!0)),window.addEventListener("offline",()=>i(!1)))}function LE(i){fr()&&typeof window<"u"&&window!=null&&window.NetInfo&&window?.NetInfo.addEventListener(e=>i(e?.isConnected))}var Dt,Tt,Rp,qc,Cp,Li,Br,So,v1,x1,yp,S1,I1,wp,bp,D1,qe,T1,U1,q1,z1,V1,Ep,K1,j1,_p,$1,H1,G1,Hc,W1,Do,Bi,Wc,Vp,Ae,pt,Vr,zi,Kp,tt,Kr,rE,vp,Oi,Xc,oE,aE,cE,uE,xp,hE,lE,Sp,Ip,dE,EE,_E,Bc,zt,ji=P(()=>{Ud();Dt=pe(xr()),Tt=pe(Zn()),Rp=pe(Fd());kd();Ef();Kf();qc=pe(Xf()),Cp=pe(ip()),Li=pe(ni()),Br=pe(np()),So=pe(up());Fc();pp();Qn();mp();v1=":";x1=Object.defineProperty,yp=Object.getOwnPropertySymbols,S1=Object.prototype.hasOwnProperty,I1=Object.prototype.propertyIsEnumerable,wp=(i,e,r)=>e in i?x1(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,bp=(i,e)=>{for(var r in e||(e={}))S1.call(e,r)&&wp(i,r,e[r]);if(yp)for(var r of yp(e))I1.call(e,r)&&wp(i,r,e[r]);return i},D1="ReactNative",qe={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},T1="js";U1="https://rpc.walletconnect.org/v1";q1=Object.defineProperty,z1=Object.defineProperties,V1=Object.getOwnPropertyDescriptors,Ep=Object.getOwnPropertySymbols,K1=Object.prototype.hasOwnProperty,j1=Object.prototype.propertyIsEnumerable,_p=(i,e,r)=>e in i?q1(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,$1=(i,e)=>{for(var r in e||(e={}))K1.call(e,r)&&_p(i,r,e[r]);if(Ep)for(var r of Ep(e))j1.call(e,r)&&_p(i,r,e[r]);return i},H1=(i,e)=>z1(i,V1(e)),G1="did:pkh:",Hc=i=>i?.split(":"),W1=i=>{let e=i&&Hc(i);if(e)return i.includes(G1)?e[3]:e[1]},Do=i=>{let e=i&&Hc(i);if(e)return e[2]+":"+e[3]},Bi=i=>{let e=i&&Hc(i);if(e)return e.pop()};Wc=(i,e)=>{let r=`${i.domain} wants you to sign in with your Ethereum account:`,t=Bi(e);if(!i.aud&&!i.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=i.statement||void 0,n=`URI: ${i.aud||i.uri}`,o=`Version: ${i.version}`,a=`Chain ID: ${W1(e)}`,c=`Nonce: ${i.nonce}`,h=`Issued At: ${i.iat}`,d=i.exp?`Expiration Time: ${i.exp}`:void 0,l=i.nbf?`Not Before: ${i.nbf}`:void 0,p=i.requestId?`Request ID: ${i.requestId}`:void 0,f=i.resources?`Resources:${i.resources.map(w=>` -- ${w}`).join("")}`:void 0,g=qi(i.resources);if(g){let w=Pi(g);s=tE(s,w)}return[r,t,"",s,"",n,o,a,c,h,d,l,p,f].filter(w=>w!=null).join(` -`)};Vp="base10",Ae="base16",pt="base64pad",Vr="base64url",zi="utf8",Kp=0,tt=1,Kr=2,rE=0,vp=1,Oi=12,Xc=32;oE="irn";aE=Object.defineProperty,cE=Object.defineProperties,uE=Object.getOwnPropertyDescriptors,xp=Object.getOwnPropertySymbols,hE=Object.prototype.hasOwnProperty,lE=Object.prototype.propertyIsEnumerable,Sp=(i,e,r)=>e in i?aE(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Ip=(i,e)=>{for(var r in e||(e={}))hE.call(e,r)&&Sp(i,r,e[r]);if(xp)for(var r of xp(e))lE.call(e,r)&&Sp(i,r,e[r]);return i},dE=(i,e)=>cE(i,uE(e));EE={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},_E={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};Bc={},zt=class{static get(e){return Bc[e]}static set(e,r){Bc[e]=r}static delete(e){delete Bc[e]}}});var yg,wg,bg,Eg,No,$i,uu,Ao,Kt,Hi,Oo=P(()=>{yg="PARSE_ERROR",wg="INVALID_REQUEST",bg="METHOD_NOT_FOUND",Eg="INVALID_PARAMS",No="INTERNAL_ERROR",$i="SERVER_ERROR",uu=[-32700,-32600,-32601,-32602,-32603],Ao=[-32e3,-32099],Kt={[yg]:{code:-32700,message:"Parse error"},[wg]:{code:-32600,message:"Invalid Request"},[bg]:{code:-32601,message:"Method not found"},[Eg]:{code:-32602,message:"Invalid params"},[No]:{code:-32603,message:"Internal error"},[$i]:{code:-32e3,message:"Server error"}},Hi=$i});function UE(i){return i<=Ao[0]&&i>=Ao[1]}function Po(i){return uu.includes(i)}function _g(i){return typeof i=="number"}function Lo(i){return Object.keys(Kt).includes(i)?Kt[i]:Kt[Hi]}function Uo(i){let e=Object.values(Kt).find(r=>r.code===i);return e||Kt[Hi]}function ME(i){if(typeof i.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof i.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!_g(i.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${i.error.code}`};if(Po(i.error.code)){let e=Uo(i.error.code);if(e.message!==Kt[Hi].message&&i.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${i.error.code}`}}return{valid:!0}}function hu(i,e,r){return i.message.includes("getaddrinfo ENOTFOUND")||i.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):i}var lu=P(()=>{Oo()});var xg=oe(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.isBrowserCryptoAvailable=jt.getSubtleCrypto=jt.getBrowerCrypto=void 0;function du(){return window?.crypto||window?.msCrypto||{}}jt.getBrowerCrypto=du;function vg(){let i=du();return i.subtle||i.webkitSubtle}jt.getSubtleCrypto=vg;function FE(){return!!du()&&!!vg()}jt.isBrowserCryptoAvailable=FE});var Dg=oe($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.isBrowser=$t.isNode=$t.isReactNative=void 0;function Sg(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}$t.isReactNative=Sg;function Ig(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}$t.isNode=Ig;function kE(){return!Sg()&&!Ig()}$t.isBrowser=kE});var fu=oe(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});var Tg=(br(),ei(wr));Tg.__exportStar(xg(),Mo);Tg.__exportStar(Dg(),Mo)});var Pe={};Se(Pe,{isNodeJs:()=>Cg});var Rg,Cg,Ng=P(()=>{Rg=pe(fu());Me(Pe,pe(fu()));Cg=Rg.isNode});function gt(i=3){let e=Date.now()*Math.pow(10,i),r=Math.floor(Math.random()*Math.pow(10,i));return e+r}function it(i=6){return BigInt(gt(i))}function st(i,e,r){return{id:r||gt(),jsonrpc:"2.0",method:i,params:e}}function Wr(i,e){return{id:i,jsonrpc:"2.0",result:e}}function gr(i,e,r){return{id:i,jsonrpc:"2.0",error:Ag(e,r)}}function Ag(i,e){return typeof i>"u"?Lo(No):(typeof i=="string"&&(i=Object.assign(Object.assign({},Lo($i)),{message:i})),typeof e<"u"&&(i.data=e),Po(i.code)&&(i=Uo(i.code)),i)}var Og=P(()=>{lu();Oo()});function BE(i){return i.includes("*")?ko(i):!/\W/g.test(i)}function Fo(i){return i==="*"}function ko(i){return Fo(i)?!0:!(!i.includes("*")||i.split("*").length!==2||i.split("*").filter(e=>e.trim()==="").length!==1)}function qE(i){return!Fo(i)&&ko(i)&&!i.split("*")[0].trim()}function zE(i){return!Fo(i)&&ko(i)&&!i.split("*")[1].trim()}var Pg=P(()=>{});var Gi,pu,Bo,Wi,Lg=P(()=>{Gi=class{},pu=class extends Gi{constructor(e){super()}},Bo=class extends Gi{constructor(){super()}},Wi=class extends Bo{constructor(e){super()}}});var Ug=P(()=>{Lg()});function jE(i){let e=i.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Mg(i,e){let r=jE(i);return typeof r>"u"?!1:new RegExp(e).test(r)}function $E(i){return Mg(i,VE)}function qo(i){return Mg(i,KE)}function gu(i){return new RegExp("wss?://localhost(:d{2,5})?").test(i)}var VE,KE,Fg=P(()=>{VE="^https?:",KE="^wss?:"});function mu(i){return typeof i=="object"&&"id"in i&&"jsonrpc"in i&&i.jsonrpc==="2.0"}function Jr(i){return mu(i)&&"method"in i}function Ht(i){return mu(i)&&(Ve(i)||Le(i))}function Ve(i){return"result"in i}function Le(i){return"error"in i}function HE(i){return"error"in i&&i.valid===!1}var kg=P(()=>{});var Ke={};Se(Ke,{DEFAULT_ERROR:()=>Hi,IBaseJsonRpcProvider:()=>Bo,IEvents:()=>Gi,IJsonRpcConnection:()=>pu,IJsonRpcProvider:()=>Wi,INTERNAL_ERROR:()=>No,INVALID_PARAMS:()=>Eg,INVALID_REQUEST:()=>wg,METHOD_NOT_FOUND:()=>bg,PARSE_ERROR:()=>yg,RESERVED_ERROR_CODES:()=>uu,SERVER_ERROR:()=>$i,SERVER_ERROR_CODE_RANGE:()=>Ao,STANDARD_ERROR_MAP:()=>Kt,formatErrorMessage:()=>Ag,formatJsonRpcError:()=>gr,formatJsonRpcRequest:()=>st,formatJsonRpcResult:()=>Wr,getBigIntRpcId:()=>it,getError:()=>Lo,getErrorByCode:()=>Uo,isHttpUrl:()=>$E,isJsonRpcError:()=>Le,isJsonRpcPayload:()=>mu,isJsonRpcRequest:()=>Jr,isJsonRpcResponse:()=>Ht,isJsonRpcResult:()=>Ve,isJsonRpcValidationInvalid:()=>HE,isLocalhostUrl:()=>gu,isNodeJs:()=>Cg,isReservedErrorCode:()=>Po,isServerErrorCode:()=>UE,isValidDefaultRoute:()=>Fo,isValidErrorCode:()=>_g,isValidLeadingWildcardRoute:()=>qE,isValidRoute:()=>BE,isValidTrailingWildcardRoute:()=>zE,isValidWildcardRoute:()=>ko,isWsUrl:()=>qo,parseConnectionError:()=>hu,payloadId:()=>gt,validateJsonRpcError:()=>ME});var Ji=P(()=>{Oo();lu();Ng();Me(Ke,Pe);Og();Pg();Ug();Fg();kg()});var Bg,zo,qg=P(()=>{Bg=pe(Yt());Ji();zo=class extends Wi{constructor(e){super(e),this.events=new Bg.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(st(e.method,e.params||[],e.id||it().toString()),r)}async requestStrict(e,r){return new Promise(async(t,s)=>{if(!this.connection.connected)try{await this.open()}catch(n){s(n)}this.events.on(`${e.id}`,n=>{Le(n)?s(n.error):t(n.result)});try{await this.connection.send(e,r)}catch(n){s(n)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Ht(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}});var Vg=oe((w6,zg)=>{"use strict";zg.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var $g,GE,WE,Kg,jg,JE,Vo,Hg=P(()=>{$g=pe(Yt());Sr();Ji();GE=()=>typeof WebSocket<"u"?WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Vg(),WE=()=>typeof WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Kg=i=>i.split("?")[0],jg=10,JE=GE(),Vo=class{constructor(e){if(this.url=e,this.events=new $g.EventEmitter,this.registering=!1,!qo(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send($e(e))}catch(r){this.onError(e.id,r)}}register(e=this.url){if(!qo(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((t,s)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),s(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return s(new Error("WebSocket connection is missing or invalid"));t(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,t)=>{let s=new URLSearchParams(e).get("origin"),n=(0,Ke.isReactNative)()?{headers:{origin:s}}:{rejectUnauthorized:!gu(e)},o=new JE(e,[],n);WE()?o.onerror=a=>{let c=a;t(this.emitError(c.error))}:o.on("error",a=>{t(this.emitError(a))}),o.onopen=()=>{this.onOpen(o),r(o)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let r=typeof e.data=="string"?ut(e.data):e.data;this.events.emit("payload",r)}onError(e,r){let t=this.parseError(r),s=t.message||t.toString(),n=gr(e,s);this.events.emit("payload",n)}parseError(e,r=this.url){return hu(e,Kg(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>jg&&this.events.setMaxListeners(jg)}emitError(e){let r=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Kg(this.url)}`));return this.events.emit("register_error",r),r}}});function Yi(i,e){if(i===e)return!0;if(i&&e&&typeof i=="object"&&typeof e=="object"){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let t=0;t{});function A_(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),t=0;t>>0,S=new Uint8Array(I);v!==x;){for(var T=g[v],L=0,y=I-1;(T!==0||L>>0,S[y]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");b=L,v++}for(var m=I-b;m!==I&&S[m]===0;)m++;for(var k=c.repeat(w);m>>0,I=new Uint8Array(x);g[w];){var S=r[g.charCodeAt(w)];if(S===255)return;for(var T=0,L=x-1;(S!==0||T>>0,I[L]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");v=T,w++}if(g[w]!==" "){for(var y=x-v;y!==x&&I[y]===0;)y++;for(var m=new Uint8Array(b+(x-y)),k=b;y!==x;)m[k++]=I[y++];return m}}}function f(g){var w=p(g);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:f}}function wv(i){return i.reduce((e,r)=>(e+=mv[r],e),"")}function bv(i){let e=[];for(let r of i){let t=yv[r.codePointAt(0)];if(t===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(t)}return new Uint8Array(e)}function x0(i,e,r){e=e||[],r=r||0;for(var t=r;i>=Iv;)e[r++]=i&255|Yg,i/=128;for(;i&Sv;)e[r++]=i&255|Yg,i>>>=7;return e[r]=i|0,x0.bytes=r-t+1,e}function Su(i,t){var r=0,t=t||0,s=0,n=t,o,a=i.length;do{if(n>=a)throw Su.bytes=0,new RangeError("Could not decode varint");o=i[n++],r+=s<28?(o&Xg)<=Tv);return Su.bytes=n-t,r}function Hv(i=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(i):new Uint8Array(i)}function C0(i,e,r,t){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:r},decoder:{decode:t}}}function Wv(i,e="utf8"){let r=Gv[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(i,"utf8"):r.decoder.decode(`${r.prefix}${i}`)}var Ct,ie,g0,m0,y0,Vu,wt,YE,XE,QE,Wg,ZE,e_,t_,r_,i_,s_,n_,Ku,o_,w0,a_,Ue,c_,Je,u_,bu,de,h_,l_,Jg,mt,d_,f_,p_,g_,m_,Xi,Gt,nt,y_,w_,b_,je,E_,__,v_,b0,Yr,x_,S_,I_,D_,ot,yt,Ye,Wt,Jt,Xr,T_,R_,C_,N_,O_,P_,E0,L_,U_,Eu,_u,vu,_0,xu,Ko,es,M_,F_,Te,k_,B_,q_,z_,V_,K_,j_,$_,H_,G_,W_,J_,Y_,X_,Q_,Z_,ev,tv,rv,iv,sv,nv,ov,av,cv,uv,hv,lv,dv,fv,pv,gv,v0,mv,yv,Ev,_v,vv,Yg,xv,Sv,Iv,Dv,Tv,Xg,Rv,Cv,Nv,Av,Ov,Pv,Lv,Uv,Mv,Fv,kv,S0,Qg,Zg,Iu,Du,I0,Tu,D0,Bv,qv,zv,T0,Vv,R0,Kv,jv,$v,e0,t0,yu,Gv,Ru,Cu,Nu,Au,Ou,Jv,Yv,Xv,r0,Qv,Zv,i0,Qi,wu,Pu,ex,s0,tx,rx,n0,o0,Lu,ix,a0,sx,nx,c0,u0,bt,Uu,Mu,Fu,ku,Bu,ox,h0,ax,cx,l0,Zi,qu,ux,d0,hx,lx,f0,p0,zu,N0,A0=P(()=>{Ct=pe(Yt());qh();Jh();ya();wa();ie=pe(xr());Sr();Qn();Qn();ji();Fc();qg();Ji();Hg();Gg();g0=pe(Zn()),m0="wc",y0=2,Vu="core",wt=`${m0}@2:${Vu}:`,YE={name:Vu,logger:"error"},XE={database:":memory:"},QE="crypto",Wg="client_ed25519_seed",ZE=ie.ONE_DAY,e_="keychain",t_="0.3",r_="messages",i_="0.3",s_=ie.SIX_HOURS,n_="publisher",Ku="irn",o_="error",w0="wss://relay.walletconnect.org",a_="relayer",Ue={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},c_="_subscription",Je={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},u_=.1,bu="2.17.1",de={link_mode:"link_mode",relay:"relay"},h_="0.3",l_="WALLETCONNECT_CLIENT_ID",Jg="WALLETCONNECT_LINK_MODE_APPS",mt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},d_="subscription",f_="0.3",p_=ie.FIVE_SECONDS*1e3,g_="pairing",m_="0.3",Xi={wc_pairingDelete:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ie.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ie.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ie.ONE_DAY,prompt:!1,tag:0},res:{ttl:ie.ONE_DAY,prompt:!1,tag:0}}},Gt={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},nt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},y_="history",w_="0.3",b_="expirer",je={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},E_="0.3",__="verify-api",v_="https://verify.walletconnect.com",b0="https://verify.walletconnect.org",Yr=b0,x_=`${Yr}/v3`,S_=[v_,b0],I_="echo",D_="https://echo.walletconnect.com",ot={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},yt={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Ye={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Wt={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Jt={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Xr={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},T_=.1,R_="event-client",C_=86400,N_="https://pulse.walletconnect.org/batch";O_=A_,P_=O_,E0=i=>{if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")},L_=i=>new TextEncoder().encode(i),U_=i=>new TextDecoder().decode(i),Eu=class{constructor(e,r,t){this.name=e,this.prefix=r,this.baseEncode=t}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},_u=class{constructor(e,r,t){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=t}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return _0(this,e)}},vu=class{constructor(e){this.decoders=e}or(e){return _0(this,e)}decode(e){let r=e[0],t=this.decoders[r];if(t)return t.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},_0=(i,e)=>new vu({...i.decoders||{[i.prefix]:i},...e.decoders||{[e.prefix]:e}}),xu=class{constructor(e,r,t,s){this.name=e,this.prefix=r,this.baseEncode=t,this.baseDecode=s,this.encoder=new Eu(e,r,t),this.decoder=new _u(e,r,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ko=({name:i,prefix:e,encode:r,decode:t})=>new xu(i,e,r,t),es=({prefix:i,name:e,alphabet:r})=>{let{encode:t,decode:s}=P_(r,e);return Ko({prefix:i,name:e,encode:t,decode:n=>E0(s(n))})},M_=(i,e,r,t)=>{let s={};for(let d=0;d=8&&(a-=8,o[h++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},F_=(i,e,r)=>{let t=e[e.length-1]==="=",s=(1<r;)o-=r,n+=e[s&a>>o];if(o&&(n+=e[s&a<Ko({prefix:e,name:i,encode(s){return F_(s,t,r)},decode(s){return M_(s,t,r,i)}}),k_=Ko({prefix:"\0",name:"identity",encode:i=>U_(i),decode:i=>L_(i)}),B_=Object.freeze({__proto__:null,identity:k_}),q_=Te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),z_=Object.freeze({__proto__:null,base2:q_}),V_=Te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),K_=Object.freeze({__proto__:null,base8:V_}),j_=es({prefix:"9",name:"base10",alphabet:"0123456789"}),$_=Object.freeze({__proto__:null,base10:j_}),H_=Te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),G_=Te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),W_=Object.freeze({__proto__:null,base16:H_,base16upper:G_}),J_=Te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Y_=Te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),X_=Te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q_=Te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Z_=Te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ev=Te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tv=Te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rv=Te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),iv=Te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),sv=Object.freeze({__proto__:null,base32:J_,base32upper:Y_,base32pad:X_,base32padupper:Q_,base32hex:Z_,base32hexupper:ev,base32hexpad:tv,base32hexpadupper:rv,base32z:iv}),nv=es({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ov=es({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),av=Object.freeze({__proto__:null,base36:nv,base36upper:ov}),cv=es({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),uv=es({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),hv=Object.freeze({__proto__:null,base58btc:cv,base58flickr:uv}),lv=Te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),dv=Te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fv=Te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),pv=Te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),gv=Object.freeze({__proto__:null,base64:lv,base64pad:dv,base64url:fv,base64urlpad:pv}),v0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),mv=v0.reduce((i,e,r)=>(i[r]=e,i),[]),yv=v0.reduce((i,e,r)=>(i[e.codePointAt(0)]=r,i),[]);Ev=Ko({prefix:"\u{1F680}",name:"base256emoji",encode:wv,decode:bv}),_v=Object.freeze({__proto__:null,base256emoji:Ev}),vv=x0,Yg=128,xv=127,Sv=~xv,Iv=Math.pow(2,31);Dv=Su,Tv=128,Xg=127;Rv=Math.pow(2,7),Cv=Math.pow(2,14),Nv=Math.pow(2,21),Av=Math.pow(2,28),Ov=Math.pow(2,35),Pv=Math.pow(2,42),Lv=Math.pow(2,49),Uv=Math.pow(2,56),Mv=Math.pow(2,63),Fv=function(i){return i(S0.encode(i,e,r),e),Zg=i=>S0.encodingLength(i),Iu=(i,e)=>{let r=e.byteLength,t=Zg(i),s=t+Zg(r),n=new Uint8Array(s+r);return Qg(i,n,0),Qg(r,n,t),n.set(e,s),new Du(i,r,e,n)},Du=class{constructor(e,r,t,s){this.code=e,this.size=r,this.digest=t,this.bytes=s}},I0=({name:i,code:e,encode:r})=>new Tu(i,e,r),Tu=class{constructor(e,r,t){this.name=e,this.code=r,this.encode=t}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Iu(this.code,r):r.then(t=>Iu(this.code,t))}else throw Error("Unknown type, must be binary type")}},D0=i=>async e=>new Uint8Array(await crypto.subtle.digest(i,e)),Bv=I0({name:"sha2-256",code:18,encode:D0("SHA-256")}),qv=I0({name:"sha2-512",code:19,encode:D0("SHA-512")}),zv=Object.freeze({__proto__:null,sha256:Bv,sha512:qv}),T0=0,Vv="identity",R0=E0,Kv=i=>Iu(T0,R0(i)),jv={code:T0,name:Vv,encode:R0,digest:Kv},$v=Object.freeze({__proto__:null,identity:jv});new TextEncoder,new TextDecoder;e0={...B_,...z_,...K_,...$_,...W_,...sv,...av,...hv,...gv,..._v};({...zv,...$v});t0=C0("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),yu=C0("ascii","a",i=>{let e="a";for(let r=0;r{i=i.substring(1);let e=Hv(i.length);for(let r=0;r{if(!this.initialized){let t=await this.getKeyChain();typeof t<"u"&&(this.keychain=t),this.initialized=!0}},this.has=t=>(this.isInitialized(),this.keychain.has(t)),this.set=async(t,s)=>{this.isInitialized(),this.keychain.set(t,s),await this.persist()},this.get=t=>{this.isInitialized();let s=this.keychain.get(t);if(typeof s>"u"){let{message:n}=B("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return s},this.del=async t=>{this.isInitialized(),this.keychain.delete(t),await this.persist()},this.core=e,this.logger=Ie(r,this.name)}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Vc(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Kc(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Cu=class{constructor(e,r,t){this.core=e,this.logger=r,this.name=QE,this.randomSessionIdentifier=To(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=s=>(this.isInitialized(),this.keychain.has(s)),this.getClientId=async()=>{this.isInitialized();let s=await this.getClientSeed(),n=pc(s);return Xn(n.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let s=jp();return this.setPrivateKey(s.publicKey,s.privateKey)},this.signJWT=async s=>{this.isInitialized();let n=await this.getClientSeed(),o=pc(n),a=this.randomSessionIdentifier;return await Td(a,s,ZE,o)},this.generateSharedKey=(s,n,o)=>{this.isInitialized();let a=this.getPrivateKey(s),c=$p(a,n);return this.setSymKey(c,o)},this.setSymKey=async(s,n)=>{this.isInitialized();let o=n||jr(s);return await this.keychain.set(o,s),o},this.deleteKeyPair=async s=>{this.isInitialized(),await this.keychain.del(s)},this.deleteSymKey=async s=>{this.isInitialized(),await this.keychain.del(s)},this.encode=async(s,n,o)=>{this.isInitialized();let a=Qc(o),c=$e(n);if(eu(a))return Wp(c,o?.encoding);if(Zc(a)){let p=a.senderPublicKey,f=a.receiverPublicKey;s=await this.generateSharedKey(p,f)}let h=this.getSymKey(s),{type:d,senderPublicKey:l}=a;return Gp({type:d,symKey:h,message:c,senderPublicKey:l,encoding:o?.encoding})},this.decode=async(s,n,o)=>{this.isInitialized();let a=Qp(n,o);if(eu(a)){let c=Yp(n,o?.encoding);return ut(c)}if(Zc(a)){let c=a.receiverPublicKey,h=a.senderPublicKey;s=await this.generateSharedKey(c,h)}try{let c=this.getSymKey(s),h=Jp({symKey:c,encoded:n,encoding:o?.encoding});return ut(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${s}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}},this.getPayloadType=(s,n=pt)=>{let o=$r({encoded:s,encoding:n});return qt(o.type)},this.getPayloadSenderPublicKey=(s,n=pt)=>{let o=$r({encoded:s,encoding:n});return o.senderPublicKey?we(o.senderPublicKey,Ae):void 0},this.core=e,this.logger=Ie(r,this.name),this.keychain=t||new Ru(this.core,this.logger)}get context(){return Re(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Wg)}catch{e=To(),await this.keychain.set(Wg,e)}return Wv(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Nu=class extends Dn{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=r_,this.version=i_,this.initialized=!1,this.storagePrefix=wt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let t=await this.getRelayerMessages();typeof t<"u"&&(this.messages=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}finally{this.initialized=!0}}},this.set=async(t,s)=>{this.isInitialized();let n=rt(s),o=this.messages.get(t);return typeof o>"u"&&(o={}),typeof o[n]<"u"||(o[n]=s,this.messages.set(t,o),await this.persist()),n},this.get=t=>{this.isInitialized();let s=this.messages.get(t);return typeof s>"u"&&(s={}),s},this.has=(t,s)=>{this.isInitialized();let n=this.get(t),o=rt(s);return typeof n[o]<"u"},this.del=async t=>{this.isInitialized(),this.messages.delete(t),await this.persist()},this.logger=Ie(e,this.name),this.core=r}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Vc(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Kc(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Au=class extends Tn{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new Ct.EventEmitter,this.name=n_,this.queue=new Map,this.publishTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.failedPublishTimeout=(0,ie.toMiliseconds)(ie.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(t,s,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:t,message:s,opts:n}});let a=n?.ttl||s_,c=Ro(n),h=n?.prompt||!1,d=n?.tag||0,l=n?.id||it().toString(),p={topic:t,message:s,opts:{ttl:a,relay:c,prompt:h,tag:d,id:l,attestation:n?.attestation}},f=`Failed to publish payload, please try again. id:${l} tag:${d}`,g=Date.now(),w,b=1;try{for(;w===void 0;){if(Date.now()-g>this.publishTimeout)throw new Error(f);this.logger.trace({id:l,attempts:b},`publisher.publish - attempt ${b}`),w=await await pr(this.rpcPublish(t,s,a,c,h,d,l,n?.attestation).catch(v=>this.logger.warn(v)),this.publishTimeout,f),b++,w||await new Promise(v=>setTimeout(v,this.failedPublishTimeout))}this.relayer.events.emit(Ue.publish,p),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:l,topic:t,message:s,opts:n}})}catch(v){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(v),(o=n?.internal)!=null&&o.throwOnFailedPublish)throw v;this.queue.set(l,p)}},this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.relayer=e,this.logger=Ie(r,this.name),this.registerEventListeners()}get context(){return Re(this.logger)}rpcPublish(e,r,t,s,n,o,a,c){var h,d,l,p;let f={method:Hr(s.protocol).publish,params:{topic:e,message:r,ttl:t,prompt:n,tag:o,attestation:c},id:a};return De((h=f.params)==null?void 0:h.prompt)&&((d=f.params)==null||delete d.prompt),De((l=f.params)==null?void 0:l.tag)&&((p=f.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f}),this.relayer.request(f)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:r,message:t,opts:s}=e;await this.publish(r,t,s)})}registerEventListeners(){this.relayer.core.heartbeat.on(Xt.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ue.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ue.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Ou=class{constructor(){this.map=new Map,this.set=(e,r)=>{let t=this.get(e);this.exists(e,r)||this.map.set(e,[...t,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let t=this.get(e);if(!this.exists(e,r))return;let s=t.filter(n=>n!==r);if(!s.length){this.map.delete(e);return}this.map.set(e,s)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},Jv=Object.defineProperty,Yv=Object.defineProperties,Xv=Object.getOwnPropertyDescriptors,r0=Object.getOwnPropertySymbols,Qv=Object.prototype.hasOwnProperty,Zv=Object.prototype.propertyIsEnumerable,i0=(i,e,r)=>e in i?Jv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Qi=(i,e)=>{for(var r in e||(e={}))Qv.call(e,r)&&i0(i,r,e[r]);if(r0)for(var r of r0(e))Zv.call(e,r)&&i0(i,r,e[r]);return i},wu=(i,e)=>Yv(i,Xv(e)),Pu=class extends Nn{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Ou,this.events=new Ct.EventEmitter,this.name=d_,this.version=f_,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=wt,this.subscribeTimeout=(0,ie.toMiliseconds)(ie.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(t,s)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:s}});try{let n=Ro(s),o={topic:t,relay:n,transportType:s?.transportType};this.pending.set(t,o);let a=await this.rpcSubscribe(t,n,s);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:s}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}},this.unsubscribe=async(t,s)=>{await this.restartToComplete(),this.isInitialized(),typeof s?.id<"u"?await this.unsubscribeById(t,s.id,s):await this.unsubscribeByTopic(t,s)},this.isSubscribed=async t=>{if(this.topics.includes(t))return!0;let s=`${this.pendingSubscriptionWatchLabel}_${t}`;return await new Promise((n,o)=>{let a=new ie.Watch;a.start(s);let c=setInterval(()=>{!this.pending.has(t)&&this.topics.includes(t)&&(clearInterval(c),a.stop(s),n(!0)),a.elapsed(s)>=p_&&(clearInterval(c),a.stop(s),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=Ie(r,this.name),this.clientId=""}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let t=!1;try{t=this.getSubscription(e).topic===r}catch{}return t}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){let t=this.topicMap.get(e);await Promise.all(t.map(async s=>await this.unsubscribeById(e,s,r)))}async unsubscribeById(e,r,t){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:t}});try{let s=Ro(t);await this.rpcUnsubscribe(e,r,s);let n=ce("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:t}})}catch(s){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(s),s}}async rpcSubscribe(e,r,t){var s;t?.transportType===de.relay&&await this.restartToComplete();let n={method:Hr(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let o=(s=t?.internal)==null?void 0:s.throwOnFailedPublish;try{let a=rt(e+this.clientId);if(t?.transportType===de.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(h=>this.logger.warn(h))},(0,ie.toMiliseconds)(ie.ONE_SECOND)),a;let c=await pr(this.relayer.request(n).catch(h=>this.logger.warn(h)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ue.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;let r=e[0].relay,t={method:Hr(r.protocol).batchSubscribe,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await pr(this.relayer.request(t).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ue.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let r=e[0].relay,t={method:Hr(r.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});let s;try{s=await await pr(this.relayer.request(t).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ue.connection_stalled)}return s}rpcUnsubscribe(e,r,t){let s={method:Hr(t.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,r){this.setSubscription(e,wu(Qi({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Qi({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,t){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,t),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r)}addSubscription(e,r){this.subscriptions.set(e,Qi({},r)),this.topicMap.set(r.topic,e),this.events.emit(mt.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let r=this.subscriptions.get(e);if(!r){let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});let t=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(t.topic,e),this.events.emit(mt.deleted,wu(Qi({},t),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(mt.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r"u"||!e.length)return;if(this.subscriptions.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let r=await this.rpcBatchSubscribe(e);Vt(r)&&this.onBatchSubscribe(r.map((t,s)=>wu(Qi({},e[s]),{id:t})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let r=await this.rpcBatchFetchMessages(e);r&&r.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(r.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(r=>{e.push(r)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Xt.pulse,async()=>{await this.checkPending()}),this.events.on(mt.created,async e=>{let r=mt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(mt.deleted,async e=>{let r=mt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}},ex=Object.defineProperty,s0=Object.getOwnPropertySymbols,tx=Object.prototype.hasOwnProperty,rx=Object.prototype.propertyIsEnumerable,n0=(i,e,r)=>e in i?ex(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,o0=(i,e)=>{for(var r in e||(e={}))tx.call(e,r)&&n0(i,r,e[r]);if(s0)for(var r of s0(e))rx.call(e,r)&&n0(i,r,e[r]);return i},Lu=class extends Rn{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ct.EventEmitter,this.name=a_,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ie.toMiliseconds)(ie.THIRTY_SECONDS+ie.ONE_SECOND),this.request=async r=>{var t,s;this.logger.debug("Publishing Request Payload");let n=r.id||it().toString();await this.toEstablishConnection();try{let o=this.provider.request(r);this.requestsInFlight.set(n,{promise:o,request:r}),this.logger.trace({id:n,method:r.method,topic:(t=r.params)==null?void 0:t.topic},"relayer.request - attempt to publish...");let a=await new Promise(async(c,h)=>{let d=()=>{h(new Error(`relayer.request - publish interrupted, id: ${n}`))};this.provider.on(Je.disconnect,d);let l=await o;this.provider.off(Je.disconnect,d),c(l)});return this.logger.trace({id:n,method:r.method,topic:(s=r.params)==null?void 0:s.topic},"relayer.request - published"),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}finally{this.requestsInFlight.delete(n)}},this.resetPingTimeout=()=>{if(Mi())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,t,s;(s=(t=(r=this.provider)==null?void 0:r.connection)==null?void 0:t.socket)==null||s.terminate()},this.heartBeatTimeout)}catch(r){this.logger.warn(r)}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ue.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Ue.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Je.payload,this.onPayloadHandler),this.provider.on(Je.connect,this.onConnectHandler),this.provider.on(Je.disconnect,this.onDisconnectHandler),this.provider.on(Je.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ie(e.logger,this.name):Pt(si({level:e.logger||o_})),this.messages=new Nu(this.logger,e.core),this.subscriber=new Pu(this,this.logger),this.publisher=new Au(this,this.logger),this.relayUrl=e?.relayUrl||w0,this.projectId=e.projectId,this.bundleId=Ap(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return Re(this.logger)}get connected(){var e,r,t;return((t=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:t.readyState)===1}get connecting(){var e,r,t;return((t=(r=(e=this.provider)==null?void 0:e.connection)==null?void 0:r.socket)==null?void 0:t.readyState)===0}async publish(e,r,t){this.isInitialized(),await this.publisher.publish(e,r,t),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now(),transportType:de.relay})}async subscribe(e,r){var t,s,n;this.isInitialized(),r?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((t=r?.internal)==null?void 0:t.throwOnFailedPublish)>"u"?!0:(s=r?.internal)==null?void 0:s.throwOnFailedPublish,a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",c,h=d=>{d.topic===e&&(this.subscriber.off(mt.created,h),c())};return await Promise.all([new Promise(d=>{c=d,this.subscriber.on(mt.created,h)}),new Promise(async(d,l)=>{a=await this.subscriber.subscribe(e,o0({internal:{throwOnFailedPublish:o}},r)).catch(p=>{o&&l(p)})||a,d()})]),a}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await pr(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(r,t)=>{let s=()=>{this.provider.off(Je.disconnect,s),t(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(Je.disconnect,s),await pr(this.provider.connect(),(0,ie.toMiliseconds)(ie.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(n=>{t(n)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(n=>{this.logger.error(n),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,r()})}catch(r){this.logger.error(r);let t=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(t.message))throw r}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await cu())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let r=e.sort((t,s)=>t.publishedAt-s.publishedAt);this.logger.trace(`Batch of ${r.length} message events sorted`);for(let t of r)try{await this.onMessageEvent(t)}catch(s){this.logger.warn(s)}this.logger.trace(`Batch of ${r.length} message events processed`)}async onLinkMessageEvent(e,r){let{topic:t}=e;if(!r.sessionExists){let s=ve(ie.FIVE_MINUTES),n={topic:t,expiry:s,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(t,n)}this.events.emit(Ue.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,r,t,s,n;if(Mi())try{(r=(e=this.provider)==null?void 0:e.connection)!=null&&r.socket&&((n=(s=(t=this.provider)==null?void 0:t.connection)==null?void 0:s.socket)==null||n.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(r=>e.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new zo(new Vo(Op({sdkVersion:bu,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:r,message:t}=e;await this.messages.set(r,t)}async shouldIgnoreMessageEvent(e){let{topic:r,message:t}=e;if(!t||t.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${t}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;let s=this.messages.has(r,t);return s&&this.logger.debug(`Ignoring duplicate message: ${t}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Jr(e)){if(!e.method.endsWith(c_))return;let r=e.params,{topic:t,message:s,publishedAt:n,attestation:o}=r.data,a={topic:t,message:s,publishedAt:n,transportType:de.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(o0({type:"event",event:r.id},a)),this.events.emit(r.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else Ht(e)&&this.events.emit(Ue.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ue.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let r=Wr(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Je.payload,this.onPayloadHandler),this.provider.off(Je.connect,this.onConnectHandler),this.provider.off(Je.disconnect,this.onDisconnectHandler),this.provider.off(Je.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await cu();mg(async r=>{e!==r&&(e=r,r?await this.restartTransport().catch(t=>this.logger.error(t)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ue.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ie.toMiliseconds)(u_))))}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},ix=Object.defineProperty,a0=Object.getOwnPropertySymbols,sx=Object.prototype.hasOwnProperty,nx=Object.prototype.propertyIsEnumerable,c0=(i,e,r)=>e in i?ix(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,u0=(i,e)=>{for(var r in e||(e={}))sx.call(e,r)&&c0(i,r,e[r]);if(a0)for(var r of a0(e))nx.call(e,r)&&c0(i,r,e[r]);return i},bt=class extends Cn{constructor(e,r,t,s=wt,n=void 0){super(e,r,t,s),this.core=e,this.logger=r,this.name=t,this.map=new Map,this.version=h_,this.cached=[],this.initialized=!1,this.storagePrefix=wt,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!De(o)?this.map.set(this.getKey(o),o):rg(o)?this.map.set(o.id,o):ig(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>Yi(a[c],o[c]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let c=u0(u0({},this.getData(o)),a);this.map.set(o,c),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=Ie(r,this.name),this.storagePrefix=s,this.getKey=n}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let r=this.map.get(e);if(!r){if(this.recentlyDeleted.includes(e)){let{message:s}=B("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Uu=class{constructor(e,r){this.core=e,this.logger=r,this.name=g_,this.version=m_,this.events=new Ct.default,this.initialized=!1,this.storagePrefix=wt,this.ignoredPayloadTypes=[tt],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:t})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...t])]},this.create=async t=>{this.isInitialized();let s=To(),n=await this.core.crypto.setSymKey(s),o=ve(ie.FIVE_MINUTES),a={protocol:Ku},c={topic:n,expiry:o,relay:a,active:!1,methods:t?.methods},h=ru({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:s,relay:a,expiryTimestamp:o,methods:t?.methods});return this.events.emit(Gt.create,c),this.core.expirer.set(n,o),await this.pairings.set(n,c),await this.core.relayer.subscribe(n,{transportType:t?.transportType}),{topic:n,uri:h}},this.pair=async t=>{this.isInitialized();let s=this.core.eventClient.createEvent({properties:{topic:t?.uri,trace:[ot.pairing_started]}});this.isValidPair(t,s);let{topic:n,symKey:o,relay:a,expiryTimestamp:c,methods:h}=tu(t.uri);s.props.properties.topic=n,s.addTrace(ot.pairing_uri_validation_success),s.addTrace(ot.pairing_uri_not_expired);let d;if(this.pairings.keys.includes(n)){if(d=this.pairings.get(n),s.addTrace(ot.existing_pairing),d.active)throw s.setError(yt.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);s.addTrace(ot.pairing_not_expired)}let l=c||ve(ie.FIVE_MINUTES),p={topic:n,relay:a,expiry:l,active:!1,methods:h};this.core.expirer.set(n,l),await this.pairings.set(n,p),s.addTrace(ot.store_new_pairing),t.activatePairing&&await this.activate({topic:n}),this.events.emit(Gt.create,p),s.addTrace(ot.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),s.addTrace(ot.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{s.setError(yt.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(f){throw s.setError(yt.subscribe_pairing_topic_failure),f}return s.addTrace(ot.subscribe_pairing_topic_success),p},this.activate=async({topic:t})=>{this.isInitialized();let s=ve(ie.THIRTY_DAYS);this.core.expirer.set(t,s),await this.pairings.update(t,{active:!0,expiry:s})},this.ping=async t=>{this.isInitialized(),await this.isValidPing(t);let{topic:s}=t;if(this.pairings.keys.includes(s)){let n=await this.sendRequest(s,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=Rt();this.events.once(se("pairing_ping",n),({error:h})=>{h?c(h):a()}),await o()}},this.updateExpiry=async({topic:t,expiry:s})=>{this.isInitialized(),await this.pairings.update(t,{expiry:s})},this.updateMetadata=async({topic:t,metadata:s})=>{this.isInitialized(),await this.pairings.update(t,{peerMetadata:s})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async t=>{this.isInitialized(),await this.isValidDisconnect(t);let{topic:s}=t;this.pairings.keys.includes(s)&&(await this.sendRequest(s,"wc_pairingDelete",ce("USER_DISCONNECTED")),await this.deletePairing(s))},this.formatUriFromPairing=t=>{this.isInitialized();let{topic:s,relay:n,expiry:o,methods:a}=t,c=this.core.crypto.keychain.get(s);return ru({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:c,relay:n,expiryTimestamp:o,methods:a})},this.sendRequest=async(t,s,n)=>{let o=st(s,n),a=await this.core.crypto.encode(t,o),c=Xi[s].req;return this.core.history.set(t,o),this.core.relayer.publish(t,a,c),o.id},this.sendResult=async(t,s,n)=>{let o=Wr(t,n),a=await this.core.crypto.encode(s,o),c=await this.core.history.get(s,t),h=Xi[c.request.method].res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o)},this.sendError=async(t,s,n)=>{let o=gr(t,n),a=await this.core.crypto.encode(s,o),c=await this.core.history.get(s,t),h=Xi[c.request.method]?Xi[c.request.method].res:Xi.unregistered_method.res;await this.core.relayer.publish(s,a,h),await this.core.history.resolve(o)},this.deletePairing=async(t,s)=>{await this.core.relayer.unsubscribe(t),await Promise.all([this.pairings.delete(t,ce("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(t),s?Promise.resolve():this.core.expirer.del(t)])},this.cleanup=async()=>{let t=this.pairings.getAll().filter(s=>ft(s.expiry));await Promise.all(t.map(s=>this.deletePairing(s.topic)))},this.onRelayEventRequest=t=>{let{topic:s,payload:n}=t;switch(n.method){case"wc_pairingPing":return this.onPairingPingRequest(s,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(s,n);default:return this.onUnknownRpcMethodRequest(s,n)}},this.onRelayEventResponse=async t=>{let{topic:s,payload:n}=t,o=(await this.core.history.get(s,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(s,n);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(t,s)=>{let{id:n}=s;try{this.isValidPing({topic:t}),await this.sendResult(n,t,!0),this.events.emit(Gt.ping,{id:n,topic:t})}catch(o){await this.sendError(n,t,o),this.logger.error(o)}},this.onPairingPingResponse=(t,s)=>{let{id:n}=s;setTimeout(()=>{Ve(s)?this.events.emit(se("pairing_ping",n),{}):Le(s)&&this.events.emit(se("pairing_ping",n),{error:s.error})},500)},this.onPairingDeleteRequest=async(t,s)=>{let{id:n}=s;try{this.isValidDisconnect({topic:t}),await this.deletePairing(t),this.events.emit(Gt.delete,{id:n,topic:t})}catch(o){await this.sendError(n,t,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(t,s)=>{let{id:n,method:o}=s;try{if(this.registeredMethods.includes(o))return;let a=ce("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,t,a),this.logger.error(a)}catch(a){await this.sendError(n,t,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=t=>{this.registeredMethods.includes(t)||this.logger.error(ce("WC_METHOD_UNSUPPORTED",t))},this.isValidPair=(t,s)=>{var n;if(!Oe(t)){let{message:a}=B("MISSING_OR_INVALID",`pair() params: ${t}`);throw s.setError(yt.malformed_pairing_uri),new Error(a)}if(!tg(t.uri)){let{message:a}=B("MISSING_OR_INVALID",`pair() uri: ${t.uri}`);throw s.setError(yt.malformed_pairing_uri),new Error(a)}let o=tu(t?.uri);if(!((n=o?.relay)!=null&&n.protocol)){let{message:a}=B("MISSING_OR_INVALID","pair() uri#relay-protocol");throw s.setError(yt.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=B("MISSING_OR_INVALID","pair() uri#symKey");throw s.setError(yt.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0,ie.toMiliseconds)(o?.expiryTimestamp){if(!Oe(t)){let{message:n}=B("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:s}=t;await this.isValidPairingTopic(s)},this.isValidDisconnect=async t=>{if(!Oe(t)){let{message:n}=B("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:s}=t;await this.isValidPairingTopic(s)},this.isValidPairingTopic=async t=>{if(!me(t,!1)){let{message:s}=B("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(s)}if(!this.pairings.keys.includes(t)){let{message:s}=B("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(s)}if(ft(this.pairings.get(t).expiry)){await this.deletePairing(t);let{message:s}=B("EXPIRED",`pairing topic: ${t}`);throw new Error(s)}},this.core=e,this.logger=Ie(r,this.name),this.pairings=new bt(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Re(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ue.message,async e=>{let{topic:r,message:t,transportType:s}=e;if(!this.pairings.keys.includes(r)||s===de.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(t)))return;let n=await this.core.crypto.decode(r,t);try{Jr(n)?(this.core.history.set(r,n),this.onRelayEventRequest({topic:r,payload:n})):Ht(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:r,payload:n}),this.core.history.delete(r,n.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(je.expired,async e=>{let{topic:r}=Io(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(Gt.expire,{topic:r}))})}},Mu=class extends In{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new Ct.EventEmitter,this.name=y_,this.version=w_,this.cached=[],this.initialized=!1,this.storagePrefix=wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(t=>this.records.set(t.id,t)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(t,s,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:t,request:s,chainId:n}),this.records.has(s.id))return;let o={id:s.id,topic:t,request:{method:s.method,params:s.params||null},chainId:n,expiry:ve(ie.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(nt.created,o)},this.resolve=async t=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:t}),!this.records.has(t.id))return;let s=await this.getRecord(t.id);typeof s.response>"u"&&(s.response=Le(t)?{error:t.error}:{result:t.result},this.records.set(s.id,s),this.persist(),this.events.emit(nt.updated,s))},this.get=async(t,s)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:t,id:s}),await this.getRecord(s)),this.delete=(t,s)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:s}),this.values.forEach(n=>{if(n.topic===t){if(typeof s<"u"&&n.id!==s)return;this.records.delete(n.id),this.events.emit(nt.deleted,n)}}),this.persist()},this.exists=async(t,s)=>(this.isInitialized(),this.records.has(s)?(await this.getRecord(s)).topic===t:!1),this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.logger=Ie(r,this.name)}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;let t={topic:r.topic,request:st(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(t)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let r=this.records.get(e);if(!r){let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(nt.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(nt.created,e=>{let r=nt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(nt.updated,e=>{let r=nt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.events.on(nt.deleted,e=>{let r=nt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e})}),this.core.heartbeat.on(Xt.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(r=>{(0,ie.toMiliseconds)(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(nt.deleted,r,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},Fu=class extends An{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new Ct.EventEmitter,this.name=b_,this.version=E_,this.cached=[],this.initialized=!1,this.storagePrefix=wt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(t=>this.expirations.set(t.target,t)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=t=>{try{let s=this.formatTarget(t);return typeof this.getExpiration(s)<"u"}catch{return!1}},this.set=(t,s)=>{this.isInitialized();let n=this.formatTarget(t),o={target:n,expiry:s};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(je.created,{target:n,expiration:o})},this.get=t=>{this.isInitialized();let s=this.formatTarget(t);return this.getExpiration(s)},this.del=t=>{if(this.isInitialized(),this.has(t)){let s=this.formatTarget(t),n=this.getExpiration(s);this.expirations.delete(s),this.events.emit(je.deleted,{target:s,expiration:n})}},this.on=(t,s)=>{this.events.on(t,s)},this.once=(t,s)=>{this.events.once(t,s)},this.off=(t,s)=>{this.events.off(t,s)},this.removeListener=(t,s)=>{this.events.removeListener(t,s)},this.logger=Ie(r,this.name)}get context(){return Re(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Lp(e);if(typeof e=="number")return Up(e);let{message:r}=B("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(je.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:r}=B("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let r=this.expirations.get(e);if(!r){let{message:t}=B("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return r}checkExpiry(e,r){let{expiry:t}=r;(0,ie.toMiliseconds)(t)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(je.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Xt.pulse,()=>this.checkExpirations()),this.events.on(je.created,e=>{let r=je.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(je.expired,e=>{let r=je.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(je.deleted,e=>{let r=je.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}},ku=class extends On{constructor(e,r,t){super(e,r,t),this.core=e,this.logger=r,this.store=t,this.name=__,this.verifyUrlV3=x_,this.storagePrefix=wt,this.version=y0,this.init=async()=>{var s;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ie.toMiliseconds)((s=this.publicKey)==null?void 0:s.expiresAt){if(!qr()||this.isDevEnv)return;let n=window.location.origin,{id:o,decryptedId:a}=s,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{let h=(0,g0.getDocument)(),d=this.startAbortTimer(ie.ONE_SECOND*5),l=await new Promise((p,f)=>{let g=()=>{window.removeEventListener("message",b),h.body.removeChild(w),f("attestation aborted")};this.abortController.signal.addEventListener("abort",g);let w=h.createElement("iframe");w.src=c,w.style.display="none",w.addEventListener("error",g,{signal:this.abortController.signal});let b=v=>{if(v.data&&typeof v.data=="string")try{let x=JSON.parse(v.data);if(x.type==="verify_attestation"){if(Lr(x.attestation).payload.id!==o)return;clearInterval(d),h.body.removeChild(w),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",b),p(x.attestation===null?"":x.attestation)}}catch(x){this.logger.warn(x)}};h.body.appendChild(w),window.addEventListener("message",b,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",l),l}catch(h){this.logger.warn(h)}return""},this.resolve=async s=>{if(this.isDevEnv)return"";let{attestationId:n,hash:o,encryptedId:a}=s;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(Lr(n).payload.id!==a)return;let h=await this.isValidJwtAttestation(n);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;let c=this.getVerifyUrl(s?.verifyUrl);return this.fetchAttestation(o,c)},this.fetchAttestation=async(s,n)=>{this.logger.debug(`resolving attestation: ${s} from url: ${n}`);let o=this.startAbortTimer(ie.ONE_SECOND*5),a=await fetch(`${n}/attestation/${s}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=s=>{let n=s||Yr;return S_.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${Yr}`),n=Yr),n},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let s=this.startAbortTimer(ie.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(s),await n.json()}catch(s){this.logger.warn(s)}},this.persistPublicKey=async s=>{this.logger.debug("persisting public key to local storage",s),await this.store.setItem(this.storeKey,s),this.publicKey=s},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async s=>{let n=await this.getPublicKey();try{if(n)return this.validateAttestation(s,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(s,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});let s=await this.fetchPromise;return this.fetchPromise=void 0,s},this.validateAttestation=(s,n)=>{let o=Zp(s,n.publicKey),a={hasExpired:(0,ie.toMiliseconds)(o.exp)this.abortController.abort(),(0,ie.toMiliseconds)(e))}},Bu=class extends Pn{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.context=I_,this.registerDeviceToken=async t=>{let{clientId:s,token:n,notificationType:o,enableEncrypted:a=!1}=t,c=`${D_}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s,type:o,token:n,always_raw:a})})},this.logger=Ie(r,this.context)}},ox=Object.defineProperty,h0=Object.getOwnPropertySymbols,ax=Object.prototype.hasOwnProperty,cx=Object.prototype.propertyIsEnumerable,l0=(i,e,r)=>e in i?ox(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Zi=(i,e)=>{for(var r in e||(e={}))ax.call(e,r)&&l0(i,r,e[r]);if(h0)for(var r of h0(e))cx.call(e,r)&&l0(i,r,e[r]);return i},qu=class extends Ln{constructor(e,r,t=!0){super(e,r,t),this.core=e,this.logger=r,this.context=R_,this.storagePrefix=wt,this.storageVersion=T_,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!ki())try{let s={eventId:$c(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:zc(this.core.relayer.protocol,this.core.relayer.version,bu)}}};await this.sendEvent([s])}catch(s){this.logger.warn(s)}},this.createEvent=s=>{let{event:n="ERROR",type:o="",properties:{topic:a,trace:c}}=s,h=$c(),d=this.core.projectId||"",l=Date.now(),p=Zi({eventId:h,timestamp:l,props:{event:n,type:o,properties:{topic:a,trace:c}},bundleId:d,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,p),this.shouldPersist=!0),p},this.getEvent=s=>{let{eventId:n,topic:o}=s;if(n)return this.events.get(n);let a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return Zi(Zi({},a),this.setMethods(a.eventId))},this.deleteEvent=s=>{let{eventId:n}=s;this.events.delete(n),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Xt.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(s=>{(0,ie.fromMiliseconds)(Date.now())-(0,ie.fromMiliseconds)(s.timestamp)>C_&&(this.events.delete(s.eventId),this.shouldPersist=!0)})})},this.setMethods=s=>({addTrace:n=>this.addTrace(s,n),setError:n=>this.setError(s,n)}),this.addTrace=(s,n)=>{let o=this.events.get(s);o&&(o.props.properties.trace.push(n),this.events.set(s,o),this.shouldPersist=!0)},this.setError=(s,n)=>{let o=this.events.get(s);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(s,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let s=await this.core.storage.getItem(this.storageKey)||[];if(!s.length)return;s.forEach(n=>{this.events.set(n.eventId,Zi(Zi({},n),this.setMethods(n.eventId)))})}catch(s){this.logger.warn(s)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let s=[];for(let[n,o]of this.events)o.props.type&&s.push(o);if(s.length!==0)try{if((await this.sendEvent(s)).ok)for(let n of s)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}},this.sendEvent=async s=>{let n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${N_}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${bu}${n}`,{method:"POST",body:JSON.stringify(s)})},this.getAppDomain=()=>zr().url,this.logger=Ie(r,this.context),this.telemetryEnabled=t,t?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},ux=Object.defineProperty,d0=Object.getOwnPropertySymbols,hx=Object.prototype.hasOwnProperty,lx=Object.prototype.propertyIsEnumerable,f0=(i,e,r)=>e in i?ux(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,p0=(i,e)=>{for(var r in e||(e={}))hx.call(e,r)&&f0(i,r,e[r]);if(d0)for(var r of d0(e))lx.call(e,r)&&f0(i,r,e[r]);return i},zu=class i extends Sn{constructor(e){var r;super(e),this.protocol=m0,this.version=y0,this.name=Vu,this.events=new Ct.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;let h={topic:o,message:a,publishedAt:Date.now(),transportType:de.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:c})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||w0,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let t=si({level:typeof e?.logger=="string"&&e.logger?e.logger:YE.logger}),{logger:s,chunkLoggerController:n}=Zh({opts:t,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=n,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=Ie(s,this.name),this.heartbeat=new gn,this.crypto=new Cu(this,this.logger,e?.keychain),this.history=new Mu(this,this.logger),this.expirer=new Fu(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new wn(p0(p0({},XE),e?.storageOptions)),this.relayer=new Lu({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Uu(this,this.logger),this.verify=new ku(this,this.logger,this.storage),this.echoClient=new Bu(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new qu(this,this.logger,e?.telemetryEnabled)}static async init(e){let r=new i(e);await r.initialize();let t=await r.crypto.getClientId();return await r.storage.setItem(l_,t),r}get context(){return Re(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Jg,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Jg)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},N0=zu});var Ho,ae,U0,M0,F0,eh,ju,O0,dx,fx,px,Qr,gx,xe,$u,Et,mx,yx,wx,bx,Ex,_x,vx,Go,jo,xx,Sx,Ix,P0,Dx,Tx,L0,Ee,at,Hu,Gu,Wu,Ju,Yu,Xu,Qu,Zu,$o,k0=P(()=>{A0();ya();wa();ji();Ho=pe(Yt()),ae=pe(xr());Ji();U0="wc",M0=2,F0="client",eh=`${U0}@${M0}:${F0}:`,ju={name:F0,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},O0="WALLETCONNECT_DEEPLINK_CHOICE",dx="proposal",fx="Proposal expired",px="session",Qr=ae.SEVEN_DAYS,gx="engine",xe={wc_sessionPropose:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ae.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ae.ONE_DAY,prompt:!1,tag:1114},res:{ttl:ae.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:ae.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:ae.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:ae.FIVE_MINUTES,prompt:!1,tag:1119}}},$u={min:ae.FIVE_MINUTES,max:ae.SEVEN_DAYS},Et={idle:"IDLE",active:"ACTIVE"},mx="request",yx=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],wx="wc",bx="auth",Ex="authKeys",_x="pairingTopics",vx="requests",Go=`${wx}@${1.5}:${bx}:`,jo=`${Go}:PUB_KEY`,xx=Object.defineProperty,Sx=Object.defineProperties,Ix=Object.getOwnPropertyDescriptors,P0=Object.getOwnPropertySymbols,Dx=Object.prototype.hasOwnProperty,Tx=Object.prototype.propertyIsEnumerable,L0=(i,e,r)=>e in i?xx(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Ee=(i,e)=>{for(var r in e||(e={}))Dx.call(e,r)&&L0(i,r,e[r]);if(P0)for(var r of P0(e))Tx.call(e,r)&&L0(i,r,e[r]);return i},at=(i,e)=>Sx(i,Ix(e)),Hu=class extends Mn{constructor(e){super(e),this.name=gx,this.events=new Ho.default,this.initialized=!1,this.requestQueue={state:Et.idle,queue:[]},this.sessionRequestQueue={state:Et.idle,queue:[]},this.requestQueueDelay=ae.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(xe)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,ae.toMiliseconds)(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let t=at(Ee({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(t);let{pairingTopic:s,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,relays:c}=t,h=s,d,l=!1;try{h&&(l=this.client.core.pairing.pairings.get(h).active)}catch(S){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),S}if(!h||!l){let{topic:S,uri:T}=await this.client.core.pairing.create();h=S,d=T}if(!h){let{message:S}=B("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(S)}let p=await this.client.core.crypto.generateKeyPair(),f=xe.wc_sessionPropose.req.ttl||ae.FIVE_MINUTES,g=ve(f),w=Ee({requiredNamespaces:n,optionalNamespaces:o,relays:c??[{protocol:Ku}],proposer:{publicKey:p,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:h},a&&{sessionProperties:a}),{reject:b,resolve:v,done:x}=Rt(f,fx);this.events.once(se("session_connect"),async({error:S,session:T})=>{if(S)b(S);else if(T){T.self.publicKey=p;let L=at(Ee({},T),{pairingTopic:w.pairingTopic,requiredNamespaces:w.requiredNamespaces,optionalNamespaces:w.optionalNamespaces,transportType:de.relay});await this.client.session.set(T.topic,L),await this.setExpiry(T.topic,T.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:T.peer.metadata}),this.cleanupDuplicatePairings(L),v(L)}});let I=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0});return await this.setProposal(I,Ee({id:I},w)),{uri:d,approval:x}},this.pair=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(r)}catch(t){throw this.client.logger.error("pair() failed"),t}},this.approve=async r=>{var t,s,n;let o=this.client.core.eventClient.createEvent({properties:{topic:(t=r?.id)==null?void 0:t.toString(),trace:[Ye.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(m){throw o.setError(Wt.no_internet_connection),m}try{await this.isValidProposalId(r?.id)}catch(m){throw this.client.logger.error(`approve() -> proposal.get(${r?.id}) failed`),o.setError(Wt.proposal_not_found),m}try{await this.isValidApprove(r)}catch(m){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Wt.session_approve_namespace_validation_failure),m}let{id:a,relayProtocol:c,namespaces:h,sessionProperties:d,sessionConfig:l}=r,p=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:f,proposer:g,requiredNamespaces:w,optionalNamespaces:b}=p,v=(s=this.client.core.eventClient)==null?void 0:s.getEvent({topic:f});v||(v=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Ye.session_approve_started,properties:{topic:f,trace:[Ye.session_approve_started,Ye.session_namespaces_validation_success]}}));let x=await this.client.core.crypto.generateKeyPair(),I=g.publicKey,S=await this.client.core.crypto.generateSharedKey(x,I),T=Ee(Ee({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:x,metadata:this.client.metadata},expiry:ve(Qr)},d&&{sessionProperties:d}),l&&{sessionConfig:l}),L=de.relay;v.addTrace(Ye.subscribing_session_topic);try{await this.client.core.relayer.subscribe(S,{transportType:L})}catch(m){throw v.setError(Wt.subscribe_session_topic_failure),m}v.addTrace(Ye.subscribe_session_topic_success);let y=at(Ee({},T),{topic:S,requiredNamespaces:w,optionalNamespaces:b,pairingTopic:f,acknowledged:!1,self:T.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:x,transportType:de.relay});await this.client.session.set(S,y),v.addTrace(Ye.store_session);try{v.addTrace(Ye.publishing_session_settle),await this.sendRequest({topic:S,method:"wc_sessionSettle",params:T,throwOnFailedPublish:!0}).catch(m=>{throw v?.setError(Wt.session_settle_publish_failure),m}),v.addTrace(Ye.session_settle_publish_success),v.addTrace(Ye.publishing_session_approve),await this.sendResult({id:a,topic:f,result:{relay:{protocol:c??"irn"},responderPublicKey:x},throwOnFailedPublish:!0}).catch(m=>{throw v?.setError(Wt.session_approve_publish_failure),m}),v.addTrace(Ye.session_approve_publish_success)}catch(m){throw this.client.logger.error(m),this.client.session.delete(S,ce("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(S),m}return this.client.core.eventClient.deleteEvent({eventId:v.eventId}),await this.client.core.pairing.updateMetadata({topic:f,metadata:g.metadata}),await this.client.proposal.delete(a,ce("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(S,ve(Qr)),{topic:S,acknowledged:()=>Promise.resolve(this.client.session.get(S))}},this.reject=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(r)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:t,reason:s}=r,n;try{n=this.client.proposal.get(t).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),o}n&&(await this.sendError({id:t,topic:n,error:s,rpcOpts:xe.wc_sessionPropose.reject}),await this.client.proposal.delete(t,ce("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(r)}catch(l){throw this.client.logger.error("update() -> isValidUpdate() failed"),l}let{topic:t,namespaces:s}=r,{done:n,resolve:o,reject:a}=Rt(),c=gt(),h=it().toString(),d=this.client.session.get(t).namespaces;return this.events.once(se("session_update",c),({error:l})=>{l?a(l):o()}),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:h}).catch(l=>{this.client.logger.error(l),this.client.session.update(t,{namespaces:d}),a(l)}),{acknowledged:n}},this.extend=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(r)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}let{topic:t}=r,s=gt(),{done:n,resolve:o,reject:a}=Rt();return this.events.once(se("session_extend",s),({error:c})=>{c?a(c):o()}),await this.setExpiry(t,ve(Qr)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:n}},this.request=async r=>{this.isInitialized();try{await this.isValidRequest(r)}catch(g){throw this.client.logger.error("request() -> isValidRequest() failed"),g}let{chainId:t,request:s,topic:n,expiry:o=xe.wc_sessionRequest.req.ttl}=r,a=this.client.session.get(n);a?.transportType===de.relay&&await this.confirmOnlineStateOrThrow();let c=gt(),h=it().toString(),{done:d,resolve:l,reject:p}=Rt(o,"Request expired. Please try again.");this.events.once(se("session_request",c),({error:g,result:w})=>{g?p(g):l(w)});let f=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return f?(await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:at(Ee({},s),{expiryTimestamp:ve(o)}),chainId:t},expiry:o,throwOnFailedPublish:!0,appLink:f}).catch(g=>p(g)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:t,id:c}),await d()):await Promise.all([new Promise(async g=>{await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:n,method:"wc_sessionRequest",params:{request:at(Ee({},s),{expiryTimestamp:ve(o)}),chainId:t},expiry:o,throwOnFailedPublish:!0}).catch(w=>p(w)),this.client.events.emit("session_request_sent",{topic:n,request:s,chainId:t,id:c}),g()}),new Promise(async g=>{var w;if(!((w=a.sessionConfig)!=null&&w.disableDeepLink)){let b=await Fp(this.client.core.storage,O0);await Mp({id:c,topic:n,wcDeepLink:b})}g()}),d()]).then(g=>g[2])},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);let{topic:t,response:s}=r,{id:n}=s,o=this.client.session.get(t);o.transportType===de.relay&&await this.confirmOnlineStateOrThrow();let a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Ve(s)?await this.sendResult({id:n,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:a}):Le(s)&&await this.sendError({id:n,topic:t,error:s.error,appLink:a}),this.cleanupAfterResponse(r)},this.ping=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(r)}catch(s){throw this.client.logger.error("ping() -> isValidPing() failed"),s}let{topic:t}=r;if(this.client.session.keys.includes(t)){let s=gt(),n=it().toString(),{done:o,resolve:a,reject:c}=Rt();this.events.once(se("session_ping",s),({error:h})=>{h?c(h):a()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:s,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(r);let{topic:t,event:s,chainId:n}=r,o=it().toString();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:n},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async r=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(r);let{topic:t}=r;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:ce("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(t))await this.client.core.pairing.disconnect({topic:t});else{let{message:s}=B("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(s)}},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(t=>eg(t,r))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(r,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(r);let n=t&&this.client.core.linkModeSupportedApps.includes(t)&&((s=this.client.metadata.redirect)==null?void 0:s.linkMode),o=n?de.link_mode:de.relay;o===de.relay&&await this.confirmOnlineStateOrThrow();let{chains:a,statement:c="",uri:h,domain:d,nonce:l,type:p,exp:f,nbf:g,methods:w=[],expiry:b}=r,v=[...r.resources||[]],{topic:x,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:x,uri:I}});let S=await this.client.core.crypto.generateKeyPair(),T=jr(S);if(await Promise.all([this.client.auth.authKeys.set(jo,{responseTopic:T,publicKey:S}),this.client.auth.pairingTopics.set(T,{topic:T,pairingTopic:x})]),await this.client.core.relayer.subscribe(T,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${x}`),w.length>0){let{namespace:j}=Ui(a[0]),re=qp(j,"request",w);qi(v)&&(re=zp(re,v.pop())),v.push(re)}let L=b&&b>xe.wc_sessionAuthenticate.req.ttl?b:xe.wc_sessionAuthenticate.req.ttl,y={authPayload:{type:p??"caip122",chains:a,statement:c,aud:h,domain:d,version:"1",nonce:l,iat:new Date().toISOString(),exp:f,nbf:g,resources:v},requester:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:ve(L)},m={eip155:{chains:a,methods:[...new Set(["personal_sign",...w])],events:["chainChanged","accountsChanged"]}},k={requiredNamespaces:{},optionalNamespaces:m,relays:[{protocol:"irn"}],pairingTopic:x,proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:ve(xe.wc_sessionPropose.req.ttl)},{done:$,resolve:O,reject:C}=Rt(L,"Request expired"),R=async({error:j,session:re})=>{if(this.events.off(se("session_request",G),N),j)C(j);else if(re){re.self.publicKey=S,await this.client.session.set(re.topic,re),await this.setExpiry(re.topic,re.expiry),x&&await this.client.core.pairing.updateMetadata({topic:x,metadata:re.peer.metadata});let Y=this.client.session.get(re.topic);await this.deleteProposal(H),O({session:Y})}},N=async j=>{var re,Y,Z;if(await this.deletePendingAuthRequest(G,{message:"fulfilled",code:0}),j.error){let D=ce("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return j.error.code===D.code?void 0:(this.events.off(se("session_connect"),R),C(j.error.message))}await this.deleteProposal(H),this.events.off(se("session_connect"),R);let{cacaos:V,responder:J}=j.result,X=[],u=[];for(let D of V){await Gc({cacao:D,projectId:this.client.core.projectId})||(this.client.logger.error(D,"Signature verification failed"),C(ce("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:A}=D,U=qi(A.resources),F=[Do(A.iss)],M=Bi(A.iss);if(U){let Q=Jc(U),z=Yc(U);X.push(...Q),F.push(...z)}for(let Q of F)u.push(`${Q}:${M}`)}let E=await this.client.core.crypto.generateSharedKey(S,J.publicKey),_;X.length>0&&(_={topic:E,acknowledged:!0,self:{publicKey:S,metadata:this.client.metadata},peer:J,controller:J.publicKey,expiry:ve(Qr),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:x,namespaces:iu([...new Set(X)],[...new Set(u)]),transportType:o},await this.client.core.relayer.subscribe(E,{transportType:o}),await this.client.session.set(E,_),x&&await this.client.core.pairing.updateMetadata({topic:x,metadata:J.metadata}),_=this.client.session.get(E)),(re=this.client.metadata.redirect)!=null&&re.linkMode&&(Y=J.metadata.redirect)!=null&&Y.linkMode&&(Z=J.metadata.redirect)!=null&&Z.universal&&t&&(this.client.core.addLinkModeSupportedApp(J.metadata.redirect.universal),this.client.session.update(E,{transportType:de.link_mode})),O({auths:V,session:_})},G=gt(),H=gt();this.events.once(se("session_connect"),R),this.events.once(se("session_request",G),N);let q;try{if(n){let j=st("wc_sessionAuthenticate",y,G);this.client.core.history.set(x,j);let re=await this.client.core.crypto.encode("",j,{type:Kr,encoding:Vr});q=Vi(t,x,re)}else await Promise.all([this.sendRequest({topic:x,method:"wc_sessionAuthenticate",params:y,expiry:r.expiry,throwOnFailedPublish:!0,clientRpcId:G}),this.sendRequest({topic:x,method:"wc_sessionPropose",params:k,expiry:xe.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:H})])}catch(j){throw this.events.off(se("session_connect"),R),this.events.off(se("session_request",G),N),j}return await this.setProposal(H,Ee({id:H},k)),await this.setAuthRequest(G,{request:at(Ee({},y),{verifyContext:{}}),pairingTopic:x,transportType:o}),{uri:q??I,response:$}},this.approveSessionAuthenticate=async r=>{let{id:t,auths:s}=r,n=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[Jt.authenticated_session_approve_started]}});try{this.isInitialized()}catch(b){throw n.setError(Xr.no_internet_connection),b}let o=this.getPendingAuthRequest(t);if(!o)throw n.setError(Xr.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);let a=o.transportType||de.relay;a===de.relay&&await this.confirmOnlineStateOrThrow();let c=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=jr(c),l={type:tt,receiverPublicKey:c,senderPublicKey:h},p=[],f=[];for(let b of s){if(!await Gc({cacao:b,projectId:this.client.core.projectId})){n.setError(Xr.invalid_cacao);let T=ce("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:d,error:T,encodeOpts:l}),new Error(T.message)}n.addTrace(Jt.cacaos_verified);let{p:v}=b,x=qi(v.resources),I=[Do(v.iss)],S=Bi(v.iss);if(x){let T=Jc(x),L=Yc(x);p.push(...T),I.push(...L)}for(let T of I)f.push(`${T}:${S}`)}let g=await this.client.core.crypto.generateSharedKey(h,c);n.addTrace(Jt.create_authenticated_session_topic);let w;if(p?.length>0){w={topic:g,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:ve(Qr),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:iu([...new Set(p)],[...new Set(f)]),transportType:a},n.addTrace(Jt.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(b){throw n.setError(Xr.subscribe_authenticated_session_topic_failure),b}n.addTrace(Jt.subscribe_authenticated_session_topic_success),await this.client.session.set(g,w),n.addTrace(Jt.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Jt.publishing_authenticated_session_approve);try{await this.sendResult({topic:d,id:t,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(b){throw n.setError(Xr.authenticated_session_approve_publish_failure),b}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:w}},this.rejectSessionAuthenticate=async r=>{this.isInitialized();let{id:t,reason:s}=r,n=this.getPendingAuthRequest(t);if(!n)throw new Error(`Could not find pending auth request with id ${t}`);n.transportType===de.relay&&await this.confirmOnlineStateOrThrow();let o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=jr(o),h={type:tt,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:t,topic:c,error:s,encodeOpts:h,rpcOpts:xe.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,ce("USER_DISCONNECTED"))},this.formatAuthMessage=r=>{this.isInitialized();let{request:t,iss:s}=r;return Wc(t,s)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let r=this.relayMessageCache.shift();r&&await this.onRelayMessage(r)}catch(r){this.client.logger.error(r)}},50)},this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{let t=this.client.core.pairing.pairings.get(r.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===r.peer.metadata.url&&n.topic&&n.topic!==t.topic});if(s.length===0)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(t){this.client.logger.error(t)}},this.deleteSession=async r=>{var t;let{topic:s,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=r,{self:c}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,ce("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),n||this.client.core.expirer.del(s),this.client.core.storage.removeItem(O0).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===s&&this.deletePendingSessionRequest(h.id,ce("USER_DISCONNECTED"))}),s===((t=this.sessionRequestQueue.queue[0])==null?void 0:t.topic)&&(this.sessionRequestQueue.state=Et.idle),o&&this.client.events.emit("session_delete",{id:a,topic:s})},this.deleteProposal=async(r,t)=>{if(t)try{let s=this.client.proposal.get(r);this.client.core.eventClient.getEvent({topic:s.pairingTopic})?.setError(Wt.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(r,ce("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"proposal")},this.deletePendingSessionRequest=async(r,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,t),s?Promise.resolve():this.client.core.expirer.del(r)]),this.addToRecentlyDeleted(r,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==r),s&&(this.sessionRequestQueue.state=Et.idle,this.client.events.emit("session_request_expire",{id:r}))},this.deletePendingAuthRequest=async(r,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(r,t),s?Promise.resolve():this.client.core.expirer.del(r)])},this.setExpiry=async(r,t)=>{this.client.session.keys.includes(r)&&(this.client.core.expirer.set(r,t),await this.client.session.update(r,{expiry:t}))},this.setProposal=async(r,t)=>{this.client.core.expirer.set(r,ve(xe.wc_sessionPropose.req.ttl)),await this.client.proposal.set(r,t)},this.setAuthRequest=async(r,t)=>{let{request:s,pairingTopic:n,transportType:o=de.relay}=t;this.client.core.expirer.set(r,s.expiryTimestamp),await this.client.auth.requests.set(r,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:r,pairingTopic:n,verifyContext:s.verifyContext,transportType:o})},this.setPendingSessionRequest=async r=>{let{id:t,topic:s,params:n,verifyContext:o}=r,a=n.request.expiryTimestamp||ve(xe.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,a),await this.client.pendingRequest.set(t,{id:t,topic:s,params:n,verifyContext:o})},this.sendRequest=async r=>{let{topic:t,method:s,params:n,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:h,appLink:d}=r,l=st(s,n,c),p,f=!!d;try{let b=f?Vr:pt;p=await this.client.core.crypto.encode(t,l,{encoding:b})}catch(b){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),b}let g;if(yx.includes(s)){let b=rt(JSON.stringify(l)),v=rt(p);g=await this.client.core.verify.register({id:v,decryptedId:b})}let w=xe[s].req;if(w.attestation=g,o&&(w.ttl=o),a&&(w.id=a),this.client.core.history.set(t,l),f){let b=Vi(d,t,p);await window.Linking.openURL(b,this.client.name)}else{let b=xe[s].req;o&&(b.ttl=o),a&&(b.id=a),h?(b.internal=at(Ee({},b.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,p,b)):this.client.core.relayer.publish(t,p,b).catch(v=>this.client.logger.error(v))}return l.id},this.sendResult=async r=>{let{id:t,topic:s,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=r,h=Wr(t,n),d,l=c&&typeof window?.Linking<"u";try{let f=l?Vr:pt;d=await this.client.core.crypto.encode(s,h,at(Ee({},a||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),f}let p;try{p=await this.client.core.history.get(s,t)}catch(f){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${t}) failed`),f}if(l){let f=Vi(c,s,d);await window.Linking.openURL(f,this.client.name)}else{let f=xe[p.request.method].res;o?(f.internal=at(Ee({},f.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,d,f)):this.client.core.relayer.publish(s,d,f).catch(g=>this.client.logger.error(g))}await this.client.core.history.resolve(h)},this.sendError=async r=>{let{id:t,topic:s,error:n,encodeOpts:o,rpcOpts:a,appLink:c}=r,h=gr(t,n),d,l=c&&typeof window?.Linking<"u";try{let f=l?Vr:pt;d=await this.client.core.crypto.encode(s,h,at(Ee({},o||{}),{encoding:f}))}catch(f){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),f}let p;try{p=await this.client.core.history.get(s,t)}catch(f){throw this.client.logger.error(`sendError() -> history.get(${s}, ${t}) failed`),f}if(l){let f=Vi(c,s,d);await window.Linking.openURL(f,this.client.name)}else{let f=a||xe[p.request.method].res;this.client.core.relayer.publish(s,d,f)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{let r=[],t=[];this.client.session.getAll().forEach(s=>{let n=!1;ft(s.expiry)&&(n=!0),this.client.core.crypto.keychain.has(s.topic)||(n=!0),n&&r.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{ft(s.expiryTimestamp)&&t.push(s.id)}),await Promise.all([...r.map(s=>this.deleteSession({topic:s})),...t.map(s=>this.deleteProposal(s))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Et.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=Et.active;let r=this.requestQueue.queue.shift();if(r)try{await this.processRequest(r)}catch(t){this.client.logger.warn(t)}}this.requestQueue.state=Et.idle},this.processRequest=async r=>{let{topic:t,payload:s,attestation:n,transportType:o,encryptedId:a}=r,c=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}},this.onRelayEventResponse=async r=>{let{topic:t,payload:s,transportType:n}=r,o=(await this.client.core.history.get(t,s.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,n);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=r=>{let{topic:t}=r,{message:s}=B("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)},this.shouldIgnorePairingRequest=r=>{let{topic:t,requestMethod:s}=r,n=this.expectedPairingMethodMap.get(t);return!n||n.includes(s)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async r=>{let{topic:t,payload:s,attestation:n,encryptedId:o}=r,{params:a,id:c}=s;try{let h=this.client.core.eventClient.getEvent({topic:t});this.isValidConnect(Ee({},s.params));let d=a.expiryTimestamp||ve(xe.wc_sessionPropose.req.ttl),l=Ee({id:c,pairingTopic:t,expiryTimestamp:d},a);await this.setProposal(c,l);let p=await this.getVerifyContext({attestationId:n,hash:rt(JSON.stringify(s)),encryptedId:o,metadata:l.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(yt.proposal_listener_not_found)),h?.addTrace(ot.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:p})}catch(h){await this.sendError({id:c,topic:t,error:h,rpcOpts:xe.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(r,t,s)=>{let{id:n}=t;if(Ve(t)){let{result:o}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});let c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});let h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});let d=await this.client.core.crypto.generateSharedKey(c,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:d});let l=await this.client.core.relayer.subscribe(d,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:r})}else if(Le(t)){await this.client.proposal.delete(n,ce("USER_DISCONNECTED"));let o=se("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(se("session_connect"),{error:t.error})}},this.onSessionSettleRequest=async(r,t)=>{let{id:s,params:n}=t;try{this.isValidSessionSettleRequest(n);let{relay:o,controller:a,expiry:c,namespaces:h,sessionProperties:d,sessionConfig:l}=t.params,p=at(Ee(Ee({topic:r,relay:o,expiry:c,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},d&&{sessionProperties:d}),l&&{sessionConfig:l}),{transportType:de.relay}),f=se("session_connect");if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners 997`);this.events.emit(se("session_connect"),{session:p}),await this.sendResult({id:t.id,topic:r,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(r,t)=>{let{id:s}=t;Ve(t)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(se("session_approve",s),{})):Le(t)&&(await this.client.session.delete(r,ce("USER_DISCONNECTED")),this.events.emit(se("session_approve",s),{error:t.error}))},this.onSessionUpdateRequest=async(r,t)=>{let{params:s,id:n}=t;try{let o=`${r}_session_update`,a=zt.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:r,error:ce("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Ee({topic:r},s));try{zt.set(o,n),await this.client.session.update(r,{namespaces:s.namespaces}),await this.sendResult({id:n,topic:r,result:!0,throwOnFailedPublish:!0})}catch(c){throw zt.delete(o),c}this.client.events.emit("session_update",{id:n,topic:r,params:s})}catch(o){await this.sendError({id:n,topic:r,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(r,t)=>parseInt(t.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,t)=>{let{id:s}=t,n=se("session_update",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);Ve(t)?this.events.emit(se("session_update",s),{}):Le(t)&&this.events.emit(se("session_update",s),{error:t.error})},this.onSessionExtendRequest=async(r,t)=>{let{id:s}=t;try{this.isValidExtend({topic:r}),await this.setExpiry(r,ve(Qr)),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}},this.onSessionExtendResponse=(r,t)=>{let{id:s}=t,n=se("session_extend",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);Ve(t)?this.events.emit(se("session_extend",s),{}):Le(t)&&this.events.emit(se("session_extend",s),{error:t.error})},this.onSessionPingRequest=async(r,t)=>{let{id:s}=t;try{this.isValidPing({topic:r}),await this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:r})}catch(n){await this.sendError({id:s,topic:r,error:n}),this.client.logger.error(n)}},this.onSessionPingResponse=(r,t)=>{let{id:s}=t,n=se("session_ping",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);setTimeout(()=>{Ve(t)?this.events.emit(se("session_ping",s),{}):Le(t)&&this.events.emit(se("session_ping",s),{error:t.error})},500)},this.onSessionDeleteRequest=async(r,t)=>{let{id:s}=t;try{this.isValidDisconnect({topic:r,reason:t.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(Ue.publish,async()=>{n(await this.deleteSession({topic:r,id:s}))})}),this.sendResult({id:s,topic:r,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:r,error:ce("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}},this.onSessionRequest=async r=>{var t,s,n;let{topic:o,payload:a,attestation:c,encryptedId:h,transportType:d}=r,{id:l,params:p}=a;try{await this.isValidRequest(Ee({topic:o},p));let f=this.client.session.get(o),g=await this.getVerifyContext({attestationId:c,hash:rt(JSON.stringify(st("wc_sessionRequest",p,l))),encryptedId:h,metadata:f.peer.metadata,transportType:d}),w={id:l,topic:o,params:p,verifyContext:g};await this.setPendingSessionRequest(w),d===de.link_mode&&(t=f.peer.metadata.redirect)!=null&&t.universal&&this.client.core.addLinkModeSupportedApp((s=f.peer.metadata.redirect)==null?void 0:s.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(w):(this.addSessionRequestToSessionRequestQueue(w),this.processSessionRequestQueue())}catch(f){await this.sendError({id:l,topic:o,error:f}),this.client.logger.error(f)}},this.onSessionRequestResponse=(r,t)=>{let{id:s}=t,n=se("session_request",s);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);Ve(t)?this.events.emit(se("session_request",s),{result:t.result}):Le(t)&&this.events.emit(se("session_request",s),{error:t.error})},this.onSessionEventRequest=async(r,t)=>{let{id:s,params:n}=t;try{let o=`${r}_session_event_${n.event.name}`,a=zt.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`);return}this.isValidEmit(Ee({topic:r},n)),this.client.events.emit("session_event",{id:s,topic:r,params:n}),zt.set(o,s)}catch(o){await this.sendError({id:s,topic:r,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(r,t)=>{let{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:r,payload:t}),Ve(t)?this.events.emit(se("session_request",s),{result:t.result}):Le(t)&&this.events.emit(se("session_request",s),{error:t.error})},this.onSessionAuthenticateRequest=async r=>{var t;let{topic:s,payload:n,attestation:o,encryptedId:a,transportType:c}=r;try{let{requester:h,authPayload:d,expiryTimestamp:l}=n.params,p=await this.getVerifyContext({attestationId:o,hash:rt(JSON.stringify(n)),encryptedId:a,metadata:h.metadata,transportType:c}),f={requester:h,pairingTopic:s,id:n.id,authPayload:d,verifyContext:p,expiryTimestamp:l};await this.setAuthRequest(n.id,{request:f,pairingTopic:s,transportType:c}),c===de.link_mode&&(t=h.metadata.redirect)!=null&&t.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:n.params,id:n.id,verifyContext:p})}catch(h){this.client.logger.error(h);let d=n.params.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),p=this.getAppLinkIfEnabled(n.params.requester.metadata,c),f={type:tt,receiverPublicKey:d,senderPublicKey:l};await this.sendError({id:n.id,topic:s,error:h,encodeOpts:f,rpcOpts:xe.wc_sessionAuthenticate.autoReject,appLink:p})}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Et.idle,this.processSessionRequestQueue()},(0,ae.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:r,error:t})=>{let s=this.client.core.history.pending;s.length>0&&s.filter(n=>n.topic===r&&n.request.method==="wc_sessionRequest").forEach(n=>{let o=n.request.id,a=se("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(se("session_request",n.request.id),{error:t})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Et.active){this.client.logger.info("session request queue is already active.");return}let r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=Et.active,this.emitSessionRequest(r)}catch(t){this.client.logger.error(t)}},this.emitSessionRequest=r=>{this.client.events.emit("session_request",r)},this.onPairingCreated=r=>{if(r.methods&&this.expectedPairingMethodMap.set(r.topic,r.methods),r.active)return;let t=this.client.proposal.getAll().find(s=>s.pairingTopic===r.topic);t&&this.onSessionProposeRequest({topic:r.topic,payload:st("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})},this.isValidConnect=async r=>{if(!Oe(r)){let{message:c}=B("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(c)}let{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:n,sessionProperties:o,relays:a}=r;if(De(t)||await this.isValidPairingTopic(t),!ag(a,!0)){let{message:c}=B("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(c)}!De(s)&&Ki(s)!==0&&this.validateNamespaces(s,"requiredNamespaces"),!De(n)&&Ki(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),De(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(r,t)=>{let s=og(r,"connect()",t);if(s)throw new Error(s.message)},this.isValidApprove=async r=>{if(!Oe(r))throw new Error(B("MISSING_OR_INVALID",`approve() params: ${r}`).message);let{id:t,namespaces:s,relayProtocol:n,sessionProperties:o}=r;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);let a=this.client.proposal.get(t),c=Co(s,"approve()");if(c)throw new Error(c.message);let h=au(a.requiredNamespaces,s,"approve()");if(h)throw new Error(h.message);if(!me(n,!0)){let{message:d}=B("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(d)}De(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async r=>{if(!Oe(r)){let{message:n}=B("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(n)}let{id:t,reason:s}=r;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!ug(s)){let{message:n}=B("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(n)}},this.isValidSessionSettleRequest=r=>{if(!Oe(r)){let{message:h}=B("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(h)}let{relay:t,controller:s,namespaces:n,expiry:o}=r;if(!nu(t)){let{message:h}=B("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}let a=sg(s,"onSessionSettleRequest()");if(a)throw new Error(a.message);let c=Co(n,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(ft(o)){let{message:h}=B("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async r=>{if(!Oe(r)){let{message:c}=B("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(c)}let{topic:t,namespaces:s}=r;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let n=this.client.session.get(t),o=Co(s,"update()");if(o)throw new Error(o.message);let a=au(n.requiredNamespaces,s,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async r=>{if(!Oe(r)){let{message:s}=B("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(s)}let{topic:t}=r;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)},this.isValidRequest=async r=>{if(!Oe(r)){let{message:c}=B("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(c)}let{topic:t,request:s,chainId:n,expiry:o}=r;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let{namespaces:a}=this.client.session.get(t);if(!ou(a,n)){let{message:c}=B("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(c)}if(!hg(s)){let{message:c}=B("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(c)}if(!fg(a,n,s.method)){let{message:c}=B("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(c)}if(o&&!gg(o,$u)){let{message:c}=B("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${$u.min} and ${$u.max}`);throw new Error(c)}},this.isValidRespond=async r=>{var t;if(!Oe(r)){let{message:o}=B("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(o)}let{topic:s,response:n}=r;try{await this.isValidSessionTopic(s)}catch(o){throw(t=r?.response)!=null&&t.id&&this.cleanupAfterResponse(r),o}if(!lg(n)){let{message:o}=B("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}},this.isValidPing=async r=>{if(!Oe(r)){let{message:s}=B("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(s)}let{topic:t}=r;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async r=>{if(!Oe(r)){let{message:a}=B("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(a)}let{topic:t,event:s,chainId:n}=r;await this.isValidSessionTopic(t);let{namespaces:o}=this.client.session.get(t);if(!ou(o,n)){let{message:a}=B("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!dg(s)){let{message:a}=B("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}if(!pg(o,n,s.name)){let{message:a}=B("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(a)}},this.isValidDisconnect=async r=>{if(!Oe(r)){let{message:s}=B("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(s)}let{topic:t}=r;await this.isValidSessionOrPairingTopic(t)},this.isValidAuthenticate=r=>{let{chains:t,uri:s,domain:n,nonce:o}=r;if(!Array.isArray(t)||t.length===0)throw new Error("chains is required and must be a non-empty array");if(!me(s,!1))throw new Error("uri is required parameter");if(!me(n,!1))throw new Error("domain is required parameter");if(!me(o,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(c=>Ui(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:a}=Ui(t[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async r=>{let{attestationId:t,hash:s,encryptedId:n,metadata:o,transportType:a}=r,c={verified:{verifyUrl:o.verifyUrl||Yr,validation:"UNKNOWN",origin:o.url||""}};try{if(a===de.link_mode){let d=this.getAppLinkIfEnabled(o,a);return c.verified.validation=d&&new URL(d).origin===new URL(o.url).origin?"VALID":"INVALID",c}let h=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:n,verifyUrl:o.verifyUrl});h&&(c.verified.origin=h.origin,c.verified.isScam=h.isScam,c.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c},this.validateSessionProps=(r,t)=>{Object.values(r).forEach(s=>{if(!me(s,!1)){let{message:n}=B("MISSING_OR_INVALID",`${t} must be in Record format. Received: ${JSON.stringify(s)}`);throw new Error(n)}})},this.getPendingAuthRequest=r=>{let t=this.client.auth.requests.get(r);return typeof t=="object"?t:void 0},this.addToRecentlyDeleted=(r,t)=>{if(this.recentlyDeletedMap.set(r,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let s=0,n=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(s++>=n)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=r=>{let t=this.recentlyDeletedMap.get(r);if(t){let{message:s}=B("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${r}`);throw new Error(s)}},this.isLinkModeEnabled=(r,t)=>{var s,n,o,a,c,h,d,l,p;return!r||t!==de.link_mode?!1:((n=(s=this.client.metadata)==null?void 0:s.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((h=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:h.universal)!==""&&((d=r?.redirect)==null?void 0:d.universal)!==void 0&&((l=r?.redirect)==null?void 0:l.universal)!==""&&((p=r?.redirect)==null?void 0:p.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(r.redirect.universal)&&typeof window?.Linking<"u"},this.getAppLinkIfEnabled=(r,t)=>{var s;return this.isLinkModeEnabled(r,t)?(s=r?.redirect)==null?void 0:s.universal:void 0},this.handleLinkModeMessage=({url:r})=>{if(!r||!r.includes("wc_ev")||!r.includes("topic"))return;let t=jc(r,"topic")||"",s=decodeURIComponent(jc(r,"wc_ev")||""),n=this.client.session.keys.includes(t);n&&this.client.session.update(t,{transportType:de.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:n})},this.registerLinkModeListeners=async()=>{var r;if(ki()||fr()&&(r=this.client.metadata.redirect)!=null&&r.linkMode){let t=window?.Linking;if(typeof t<"u"){t.addEventListener("url",this.handleLinkModeMessage,this.client.name);let s=await t.getInitialURL();s&&setTimeout(()=>{this.handleLinkModeMessage({url:s})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=B("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ue.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:r,message:t,attestation:s,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(jo)?this.client.auth.authKeys.get(jo):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(r,t,{receiverPublicKey:o,encoding:n===de.link_mode?Vr:pt});try{Jr(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a,attestation:s,transportType:n,encryptedId:rt(t)})):Ht(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a,transportType:n}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a,transportType:n})}catch(c){this.client.logger.error(c)}}registerExpirerEvents(){this.client.core.expirer.on(je.expired,async e=>{let{topic:r,id:t}=Io(e.target);if(t&&this.client.pendingRequest.keys.includes(t))return await this.deletePendingSessionRequest(t,B("EXPIRED"),!0);if(t&&this.client.auth.requests.keys.includes(t))return await this.deletePendingAuthRequest(t,B("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession({topic:r,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:r})):t&&(await this.deleteProposal(t,!0),this.client.events.emit("proposal_expire",{id:t}))})}registerPairingEvents(){this.client.core.pairing.events.on(Gt.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Gt.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!me(e,!1)){let{message:r}=B("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:r}=B("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(ft(this.client.core.pairing.pairings.get(e).expiry)){let{message:r}=B("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!me(e,!1)){let{message:r}=B("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:r}=B("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(ft(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:r}=B("EXPIRED",`session topic: ${e}`);throw new Error(r)}if(!this.client.core.crypto.keychain.has(e)){let{message:r}=B("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(me(e,!1)){let{message:r}=B("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{let{message:r}=B("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!cg(e)){let{message:r}=B("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){let{message:r}=B("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(ft(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:r}=B("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}},Gu=class extends bt{constructor(e,r){super(e,r,dx,eh),this.core=e,this.logger=r}},Wu=class extends bt{constructor(e,r){super(e,r,px,eh),this.core=e,this.logger=r}},Ju=class extends bt{constructor(e,r){super(e,r,mx,eh,t=>t.id),this.core=e,this.logger=r}},Yu=class extends bt{constructor(e,r){super(e,r,Ex,Go,()=>jo),this.core=e,this.logger=r}},Xu=class extends bt{constructor(e,r){super(e,r,_x,Go),this.core=e,this.logger=r}},Qu=class extends bt{constructor(e,r){super(e,r,vx,Go,t=>t.id),this.core=e,this.logger=r}},Zu=class{constructor(e,r){this.core=e,this.logger=r,this.authKeys=new Yu(this.core,this.logger),this.pairingTopics=new Xu(this.core,this.logger),this.requests=new Qu(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},$o=class i extends Un{constructor(e){super(e),this.protocol=U0,this.version=M0,this.name=ju.name,this.events=new Ho.EventEmitter,this.on=(t,s)=>this.events.on(t,s),this.once=(t,s)=>this.events.once(t,s),this.off=(t,s)=>this.events.off(t,s),this.removeListener=(t,s)=>this.events.removeListener(t,s),this.removeAllListeners=t=>this.events.removeAllListeners(t),this.connect=async t=>{try{return await this.engine.connect(t)}catch(s){throw this.logger.error(s.message),s}},this.pair=async t=>{try{return await this.engine.pair(t)}catch(s){throw this.logger.error(s.message),s}},this.approve=async t=>{try{return await this.engine.approve(t)}catch(s){throw this.logger.error(s.message),s}},this.reject=async t=>{try{return await this.engine.reject(t)}catch(s){throw this.logger.error(s.message),s}},this.update=async t=>{try{return await this.engine.update(t)}catch(s){throw this.logger.error(s.message),s}},this.extend=async t=>{try{return await this.engine.extend(t)}catch(s){throw this.logger.error(s.message),s}},this.request=async t=>{try{return await this.engine.request(t)}catch(s){throw this.logger.error(s.message),s}},this.respond=async t=>{try{return await this.engine.respond(t)}catch(s){throw this.logger.error(s.message),s}},this.ping=async t=>{try{return await this.engine.ping(t)}catch(s){throw this.logger.error(s.message),s}},this.emit=async t=>{try{return await this.engine.emit(t)}catch(s){throw this.logger.error(s.message),s}},this.disconnect=async t=>{try{return await this.engine.disconnect(t)}catch(s){throw this.logger.error(s.message),s}},this.find=t=>{try{return this.engine.find(t)}catch(s){throw this.logger.error(s.message),s}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(t){throw this.logger.error(t.message),t}},this.authenticate=async(t,s)=>{try{return await this.engine.authenticate(t,s)}catch(n){throw this.logger.error(n.message),n}},this.formatAuthMessage=t=>{try{return this.engine.formatAuthMessage(t)}catch(s){throw this.logger.error(s.message),s}},this.approveSessionAuthenticate=async t=>{try{return await this.engine.approveSessionAuthenticate(t)}catch(s){throw this.logger.error(s.message),s}},this.rejectSessionAuthenticate=async t=>{try{return await this.engine.rejectSessionAuthenticate(t)}catch(s){throw this.logger.error(s.message),s}},this.name=e?.name||ju.name,this.metadata=e?.metadata||zr(),this.signConfig=e?.signConfig;let r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Pt(si({level:e?.logger||ju.logger}));this.core=e?.core||new N0(e),this.logger=Ie(r,this.name),this.session=new Wu(this.core,this.logger),this.proposal=new Gu(this.core,this.logger),this.pendingRequest=new Ju(this.core,this.logger),this.engine=new Hu(this),this.auth=new Zu(this.core,this.logger)}static async init(e){let r=new i(e);return await r.initialize(),r}get context(){return Re(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}});var B0,ct,th=P(()=>{"use strict";B0=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],ct="mvx"});var ts=P(()=>{"use strict"});function Wo(i){return i[Math.floor(Math.random()*i.length)]}var rs,q0,rh,Zr=P(()=>{"use strict";rs=i=>typeof i=="string"?i.toUpperCase():i instanceof Error?i.message:JSON.stringify(i);q0="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",rh=i=>{if(!/^[0-9a-fA-F]+$/.test(i)||i.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(i.length/2);for(let r=0;rt.acknowledged);if(r.length>0){let t=r.length-1;return r[t]}if(e.session.length>0){let t=e.session.keys.length-1;return e.session.get(e.session.keys[t])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Nt(i,e){if(!e)throw new Error("WalletConnect is not initialized");let r=sh(i,e);if(!r?.topic)throw new Error("WalletConnect Session is not connected");return r.topic}function z0(i){return!!i}function nh(i){let e=i.namespaces[ct];if(e&&e.accounts){let r=e.accounts[0],[,,t]=r.split(":");return t}return""}function oh({transaction:i,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:r,guardianSignature:t,version:s,options:n,guardian:o}=e,a=i.guardian;if(a&&a!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(i.guardian=o),s&&(i.version=s),n!=null&&(i.options=n),i.signature=rh(r),t&&(i.guardianSignature=rh(t)),i}function V0(i){if(i)return{...i,url:zr().url}}async function K0(i){return await new Promise(e=>setTimeout(()=>{e()},i))}var j0=P(()=>{"use strict";ji();th();ts();Zr()});var Xe,is=P(()=>{"use strict";k0();ji();j0();th();ts();Xe=class{constructor(e,r,t,s,n,o,a,c){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=r,this.walletConnectV2Relay=t,this.walletConnectV2ProjectId=s,this.Message=n,this.Transaction=o,this.TransactionsConverter=a,this.options=c}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:V0(this.options?.metadata)}:{},r=await $o.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=r,this.isInitializing=!1,await this.subscribeToEvents(r),await this.checkPersistedState(r)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let r=ih(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...r})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let r=await e.approval();if(e.token){await K0(500);let t=nh(r),n=r.namespaces[ct].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:r.topic,request:{method:n,params:{token:e.token,address:t}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:r,signature:o})}return await this.onSessionConnected({session:r,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Nt(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:ce("USER_DISCONNECTED")});else{let r=Nt(this.chainId,this.walletConnector);this.processingTopic=r,await this.walletConnector.disconnect({topic:r,reason:ce("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let r=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let t=this.getAddress(),{signature:s}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:t,message:r.data.toString()}}});if(!s)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{r.signature=Buffer.from(s,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return r}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let r=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let t=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:r}}});return oh({transaction:e,response:t})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let r=e.map(t=>{if(this.chainId!==t.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(t)});try{let{signatures:t}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:r}}});if(!t)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(t)||e.length!==t.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[s,n]of e.entries()){let o=t[s];oh({transaction:n,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let r={...e.request},{method:t}=r,{response:s}=await this.walletConnector.request({chainId:`${ct}:${this.chainId}`,topic:Nt(this.chainId,this.walletConnector),request:{...r,method:t}});s||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Nt(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?z0(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let r=nh(e.session);return r?(await this.loginAccount({address:r,signature:e.signature}),this.account.address=r,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let r=await this.getPairings();this.account.address&&!this.isInitializing&&r&&(r?.length===0?this.onClientConnect.onClientLogout():r[r.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:r}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:t}=r;if(t?.name&&Nt(this.chainId,this.walletConnector)===e){let s=t.data;this.onClientConnect.onClientEvent(s)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:r,params:t})=>{if(!this.session||this.session?.topic!==r)return;let{namespaces:s}=t,o={...e.session.get(r),namespaces:s};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:r})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==r)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:r})=>{!this.session||this.session?.topic!==r||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let r=sh(this.chainId,e);if(r)return await this.onSessionConnected({session:r}),r}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let r=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!Vt(r))return;for(let t of r)if(e.deletePairings)this.walletConnector.core?.expirer?.set(t.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(t.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}}});var $0={};Se($0,{initMobileProvider:()=>Nx});var Nx,H0=P(()=>{"use strict";is();Zr();Nx=async(i,e,r,t,s,n,o,a)=>{if(!o||!i.initOptions.chainType)return;let c={onClientLogin:()=>{},onClientLogout:()=>e(i),onClientEvent:l=>{console.log("wc2 session event: ",l)}},h=Wo(a),d=new Xe(c,r[i.initOptions.chainType].shortId,h,o,t,s,n);try{return await d.init(),d}catch{console.warn("Can't initialize the Dapp Provider!")}}});function Ot(i,e,r){if(e<0||e>31||i>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)r.push(i>>>t&1)}function At(i,e){return(i>>>e&1)!==0}function Z0(i,e){return i[Math.floor((e+7)/17)+1]}function em(i){let e=[];for(let r of i)Ot(r,8,e);return new ss(zx,i.length,e)}function Vx(i){if(!tm(i))throw new RangeError("String contains non-numeric characters");let e=[];for(let r=0;r=1<dh)throw new RangeError("Version number out of range");let e=(16*i+128)*i+64;if(i>=2){let r=Math.floor(i/7)+2;e-=(25*r-10)*r-55,i>=7&&(e-=36)}return e}function Xo(i,e){return Math.floor(uh(i)/8)-X0[e[0]][i]*Q0[e[0]][i]}function Gx(i){if(i<1||i>255)throw new RangeError("Degree out of range");let e=[];for(let t=0;t0);for(let t of i){let s=t^r.shift();r.push(0),e.forEach((n,o)=>r[o]^=hh(n,s))}return r}function hh(i,e){if(i>>>8||e>>>8)throw new RangeError("Byte out of range");let r=0;for(let t=7;t>=0;t--)r=r<<1^(r>>>7)*285,r^=(e>>>t&1)*i;return r}function Jx(i,e,r=1,t=40,s=-1,n=!0){if(!(lh<=r&&r<=t&&t<=dh)||s<-1||s>7)throw new RangeError("Invalid value");let o,a;for(o=r;;o++){let l=Xo(o,e)*8,p=$x(i,o);if(p<=l){a=p;break}if(o>=t)throw new RangeError("Data too long")}for(let l of[W0,J0,Y0])n&&a<=Xo(o,l)*8&&(e=l);let c=[];for(let l of i){Ot(l.mode[0],4,c),Ot(l.numChars,Z0(l.mode,o),c);for(let p of l.getData())c.push(p)}let h=Xo(o,e)*8;Ot(0,Math.min(4,h-c.length),c),Ot(0,(8-c.length%8)%8,c);for(let l=236;c.length0);return c.forEach((l,p)=>d[p>>>3]|=l<<7-(p&7)),new ch(o,e,d,s)}function Yx(i,e){let{ecc:r="L",boostEcc:t=!1,minVersion:s=1,maxVersion:n=40,maskPattern:o=-1,border:a=1}=e||{},c=typeof i=="string"?jx(i):Array.isArray(i)?[em(i)]:void 0;if(!c)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof i}`);let h=Jx(c,Lx[r],s,n,o,t),d=Xx({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},a);return e?.invert&&(d.data=d.data.map(l=>l.map(p=>!p))),e?.onEncoded?.(d),d}function Xx(i,e=1){if(!e)return i;let{size:r}=i,t=r+e*2;i.size=t,i.data.forEach(n=>{for(let o=0;o!1)),i.data.push(Array.from({length:t},o=>!1));let s=mr.Border;i.types.forEach(n=>{for(let o=0;os)),i.types.push(Array.from({length:t},o=>s));return i}function im(i,e={}){let r=Yx(i,e),{pixelSize:t=10,whiteColor:s="white",blackColor:n="black"}=e,o=r.size*t,a=r.size*t,c=``,h=[];for(let d=0;d`,c+=``,c+="",c}var mr,Ax,Ox,Jo,Px,W0,J0,Y0,Lx,Ux,Mx,ah,lh,dh,G0,Fx,Yo,kx,X0,Q0,ch,ss,Bx,qx,zx,sm=P(()=>{mr=(i=>(i[i.Border=-1]="Border",i[i.Data=0]="Data",i[i.Function=1]="Function",i[i.Position=2]="Position",i[i.Timing=3]="Timing",i[i.Alignment=4]="Alignment",i))(mr||{}),Ax=Object.defineProperty,Ox=(i,e,r)=>e in i?Ax(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Jo=(i,e,r)=>(Ox(i,typeof e!="symbol"?e+"":e,r),r),Px=[0,1],W0=[1,0],J0=[2,3],Y0=[3,2],Lx={L:Px,M:W0,Q:J0,H:Y0},Ux=/^[0-9]*$/,Mx=/^[A-Z0-9 $%*+.\/:-]*$/,ah="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",lh=1,dh=40,G0=3,Fx=3,Yo=40,kx=10,X0=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Q0=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],ch=class{constructor(e,r,t,s){if(this.version=e,this.ecc=r,Jo(this,"size"),Jo(this,"mask"),Jo(this,"modules",[]),Jo(this,"types",[]),edh)throw new RangeError("Version value out of range");if(s<-1||s>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let n=Array.from({length:this.size},()=>!1);for(let a=0;a0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(t);if(this.drawCodewords(o),s===-1){let a=1e9;for(let c=0;c<8;c++){this.applyMask(c),this.drawFormatBits(c);let h=this.getPenaltyScore();h=0&&e=0&&r>>9)*1335;let s=(r<<10|t)^21522;for(let n=0;n<=5;n++)this.setFunctionModule(8,n,At(s,n));this.setFunctionModule(8,7,At(s,6)),this.setFunctionModule(8,8,At(s,7)),this.setFunctionModule(7,8,At(s,8));for(let n=9;n<15;n++)this.setFunctionModule(14-n,8,At(s,n));for(let n=0;n<8;n++)this.setFunctionModule(this.size-1-n,8,At(s,n));for(let n=8;n<15;n++)this.setFunctionModule(8,this.size-15+n,At(s,n));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let r=this.version<<12|e;for(let t=0;t<18;t++){let s=At(r,t),n=this.size-11+t%3,o=Math.floor(t/3);this.setFunctionModule(n,o,s),this.setFunctionModule(o,n,s)}}drawFinderPattern(e,r){for(let t=-4;t<=4;t++)for(let s=-4;s<=4;s++){let n=Math.max(Math.abs(s),Math.abs(t)),o=e+s,a=r+t;o>=0&&o=0&&a{(p!==c-n||g>=a)&&l.push(f[p])});return l}drawCodewords(e){if(e.length!==Math.floor(uh(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let t=this.size-1;t>=1;t-=2){t===6&&(t=5);for(let s=0;s>>3],7-(r&7)),r++)}}}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let r=0;r5&&e++):(this.finderPenaltyAddHistory(a,c),o||(e+=this.finderPenaltyCountPatterns(c)*Yo),o=this.modules[n][h],a=1);e+=this.finderPenaltyTerminateAndCount(o,a,c)*Yo}for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(a,c),o||(e+=this.finderPenaltyCountPatterns(c)*Yo),o=this.modules[h][n],a=1);e+=this.finderPenaltyTerminateAndCount(o,a,c)*Yo}for(let n=0;no+(a?1:0),r);let t=this.size*this.size,s=Math.ceil(Math.abs(r*20-t*10)/t)-1;return e+=s*kx,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,r=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,t=[6];for(let s=this.size-7;t.length0&&e[2]===r&&e[3]===r*3&&e[4]===r&&e[5]===r;return(t&&e[0]>=r*4&&e[6]>=r?1:0)+(t&&e[6]>=r*4&&e[0]>=r?1:0)}finderPenaltyTerminateAndCount(e,r,t){return e&&(this.finderPenaltyAddHistory(r,t),r=0),r+=this.size,this.finderPenaltyAddHistory(r,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,r){r[0]===0&&(e+=this.size),r.pop(),r.unshift(e)}};ss=class{constructor(e,r,t){if(this.mode=e,this.numChars=r,this.bitData=t,r<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}getData(){return this.bitData.slice()}},Bx=[1,10,12,14],qx=[2,9,11,13],zx=[4,8,16,16]});var Zx,e2,t2,r2,fh,i2,Qo,s2,n2,o2,a2,c2,nm,om=P(()=>{"use strict";sm();is();Zr();Zr();ts();Zx=i=>{let e=document.createElement("template");return e.innerHTML=i.trim(),e.content.firstChild?.cloneNode(!0)},e2=i=>{let e=`${q0}?wallet-connect=${encodeURIComponent(i)}`,r=document.createElement("a");return r.setAttribute("href",e),r.setAttribute("rel","noopener noreferrer nofollow"),r.setAttribute("target","_blank"),r.textContent="xPortal login",r.classList.add("elven-qr-code-deep-link"),r},t2=()=>{let i=document.createElement("div");return i.classList.add("elven-wc-pairings"),i},r2=()=>{let i=document.createElement("div");return i.textContent="Existing WalletConnect pairings:",i.classList.add("elven-wc-pairings-header"),i},fh={},i2=(i,e)=>{let r=document.createElement("button");return r.classList.add("elven-wc-pairings-remove-btn"),r.textContent="\u2716",fh[i.topic]=new AbortController,r.addEventListener("click",t=>{t.stopImmediatePropagation(),e(i.topic)},{signal:fh[i.topic].signal}),r},Qo={},s2=(i,e,r)=>{let t=document.createElement("div"),s=document.createElement("div");t.classList.add("elven-wc-pairing-item"),t.setAttribute("id",i.topic),s.classList.add("elven-wc-pairing-item-description"),s.textContent=`${i.peerMetadata?.description} (${i.peerMetadata?.url})`,t.appendChild(s);let n=i2(i,e);return t.appendChild(n),Qo[i.topic]=new AbortController,t.addEventListener("click",()=>r(i.topic),{signal:Qo[i.topic].signal}),t},n2=()=>{let i=document.createElement("div");return i.classList.add("elven-wc-pairing-item-confirm-msessage"),i.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),i.innerText="Confirm on xPortal app!",i},o2=i=>{if(!i)return;document.getElementById(i)?.remove()},a2=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),c2=i=>i?im(i):void 0,nm=async(i,e,r,t)=>{if(!i)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let s=null;typeof i=="string"?s=document.getElementById(i):i instanceof HTMLElement&&(s=i);let n=c2(e),o;if(n&&(o=Zx(n)),s&&o&&(s.replaceChildren(),s.appendChild(o),a2()&&s.appendChild(e2(e))),s&&r instanceof Xe){let a=r.pairings,c=async d=>{try{d&&(await r.logout({topic:d}),o2(d))}catch(l){let p=rs(l);console.warn(`Something went wrong trying to remove the existing pairing: ${p}`)}finally{Qo[d].abort()}},h=async d=>{try{let{approval:l}=await r.connect({topic:d,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(d)?.after(n2()),await r.login({approval:l,token:t})}catch(l){let p=rs(l);console.warn(`Something went wrong trying to login the user: ${p}`)}finally{for(let l of Object.values(Qo))l?.abort();for(let l of Object.values(fh))l?.abort()}};if(a&&a.length>0){let d=t2();s.appendChild(d);let l=r2();d.appendChild(l);for(let p of a){let f=s2(p,c,h);d.appendChild(f)}}}return s}});var am={};Se(am,{loginWithMobile:()=>u2});var u2,cm=P(()=>{"use strict";Zr();om();is();ts();u2=async(i,e,r,t,s,n,o,a,c,h,d,l,p,f,g)=>{if(!g)throw new Error("You haven't provided the QR code container DOM element id");let w=Wo(f);if(!w||!i.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!p)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!i.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let b,v={onClientLogin:async()=>{if(i.dappProvider instanceof Xe){let I=await i.dappProvider.getAddress(),S=await i.dappProvider.getSignature();t.set("address",I),t.set("loginMethod","mobile"),t.set("expires",n()),await o(i),S&&t.set("signature",S),t.set("loginToken",e);let T=r.getToken(I,e,S);t.set("accessToken",T),a.run("onLoginSuccess"),b?.replaceChildren()}},onClientLogout:async()=>{i.dappProvider instanceof Xe&&await s(i)},onClientEvent:I=>{console.log("wc2 session event: ",I)}},x=new Xe(v,c[i.initOptions.chainType].shortId,w,p,h,d,l);try{if(x){i.dappProvider=x,a.run("onQrPending"),await x.init();let{uri:I,approval:S}=await x.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),T=e?`${I}&token=${e}`:I;return g&&T&&(b=await nm(g,T,x,e),a.run("onQrLoaded")),await x.login({approval:S,token:e}),x}}catch(I){let S=rs(I);console.warn(`Something went wrong trying to login the user: ${S}`),a.run("onLoginFailure",S)}}});is();var um=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:r,qrCodeContainer:t}){this.WalletConnectV2Provider=Xe;this.initMobileProvider=async(e,r,t,s,n,o)=>{let{initMobileProvider:a}=await Promise.resolve().then(()=>(H0(),$0));return a(e,r,t,s,n,o,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses)};this.loginWithMobile=async(e,r,t,s,n,o,a,c,h,d,l,p)=>{let{loginWithMobile:f}=await Promise.resolve().then(()=>(cm(),am));return f(e,r,t,s,n,o,a,c,h,d,l,p,this.walletConnectV2ProjectId,this.walletConnectV2RelayAddresses,this.qrCodeContainer)};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=r,this.qrCodeContainer=t}};export{um as MobileSigningProvider}; + Approved: ${f.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=Rs(e[y].accounts);S.includes(y)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} + Required: ${y} + Approved: ${S.toString()}`))}),o.forEach(y=>{i||(An(n[y].methods,s[y].methods)?An(n[y].events,s[y].events)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function T_(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function wb(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function D_(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Rs(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function cv(r,e){return ku(r,!1)&&r<=e.max&&r>=e.min}function $u(){let r=Mo();return new Promise(e=>{switch(r){case Ft.browser:e(P_());break;case Ft.reactNative:e(N_());break;case Ft.node:e(C_());break;default:e(!0)}})}function P_(){return _s()&&navigator?.onLine}async function N_(){return Tn()&&typeof window<"u"&&window!=null&&window.NetInfo?(await window?.NetInfo.fetch())?.isConnected:!0}function C_(){return!0}function hv(r){switch(Mo()){case Ft.browser:O_(r);break;case Ft.reactNative:L_(r);break;case Ft.node:break}}function O_(r){!Tn()&&_s()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function L_(r){Tn()&&typeof window<"u"&&window!=null&&window.NetInfo&&window?.NetInfo.addEventListener(e=>r(e?.isConnected))}var xu={},ki=class{static get(e){return xu[e]}static set(e,t){xu[e]=t}static delete(e){delete xu[e]}};var Mv=qe(hn());var Rt={};Dt(Rt,{DEFAULT_ERROR:()=>Oo,IBaseJsonRpcProvider:()=>Uf,IEvents:()=>Lo,IJsonRpcConnection:()=>Yu,IJsonRpcProvider:()=>Fo,INTERNAL_ERROR:()=>Df,INVALID_PARAMS:()=>pv,INVALID_REQUEST:()=>dv,METHOD_NOT_FOUND:()=>lv,PARSE_ERROR:()=>uv,RESERVED_ERROR_CODES:()=>Hu,SERVER_ERROR:()=>Co,SERVER_ERROR_CODE_RANGE:()=>Pf,STANDARD_ERROR_MAP:()=>ji,formatErrorMessage:()=>Sv,formatJsonRpcError:()=>Pn,formatJsonRpcRequest:()=>br,formatJsonRpcResult:()=>Ts,getBigIntRpcId:()=>gr,getError:()=>Cf,getErrorByCode:()=>Of,isHttpUrl:()=>H_,isJsonRpcError:()=>At,isJsonRpcPayload:()=>Zu,isJsonRpcRequest:()=>Ds,isJsonRpcResponse:()=>Hi,isJsonRpcResult:()=>kt,isJsonRpcValidationInvalid:()=>G_,isLocalhostUrl:()=>Xu,isNodeJs:()=>Ev,isReservedErrorCode:()=>Nf,isServerErrorCode:()=>F_,isValidDefaultRoute:()=>Ff,isValidErrorCode:()=>gv,isValidLeadingWildcardRoute:()=>k_,isValidRoute:()=>B_,isValidTrailingWildcardRoute:()=>K_,isValidWildcardRoute:()=>qf,isWsUrl:()=>zf,parseConnectionError:()=>Gu,payloadId:()=>Qr,validateJsonRpcError:()=>q_});var uv="PARSE_ERROR",dv="INVALID_REQUEST",lv="METHOD_NOT_FOUND",pv="INVALID_PARAMS",Df="INTERNAL_ERROR",Co="SERVER_ERROR",Hu=[-32700,-32600,-32601,-32602,-32603],Pf=[-32e3,-32099],ji={[uv]:{code:-32700,message:"Parse error"},[dv]:{code:-32600,message:"Invalid Request"},[lv]:{code:-32601,message:"Method not found"},[pv]:{code:-32602,message:"Invalid params"},[Df]:{code:-32603,message:"Internal error"},[Co]:{code:-32e3,message:"Server error"}},Oo=Co;function F_(r){return r<=Pf[0]&&r>=Pf[1]}function Nf(r){return Hu.includes(r)}function gv(r){return typeof r=="number"}function Cf(r){return Object.keys(ji).includes(r)?ji[r]:ji[Oo]}function Of(r){let e=Object.values(ji).find(t=>t.code===r);return e||ji[Oo]}function q_(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!gv(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(Nf(r.error.code)){let e=Of(r.error.code);if(e.message!==ji[Oo].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Gu(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var Nt={};Dt(Nt,{isNodeJs:()=>Ev});var xv=qe(Ju());qt(Nt,qe(Ju()));var Ev=xv.isNode;qt(Rt,Nt);function Qr(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function gr(r=6){return BigInt(Qr(r))}function br(r,e,t){return{id:t||Qr(),jsonrpc:"2.0",method:r,params:e}}function Ts(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Pn(r,e,t){return{id:r,jsonrpc:"2.0",error:Sv(e,t)}}function Sv(r,e){return typeof r>"u"?Cf(Df):(typeof r=="string"&&(r=Object.assign(Object.assign({},Cf(Co)),{message:r})),typeof e<"u"&&(r.data=e),Nf(r.code)&&(r=Of(r.code)),r)}function B_(r){return r.includes("*")?qf(r):!/\W/g.test(r)}function Ff(r){return r==="*"}function qf(r){return Ff(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function k_(r){return!Ff(r)&&qf(r)&&!r.split("*")[0].trim()}function K_(r){return!Ff(r)&&qf(r)&&!r.split("*")[1].trim()}var Lo=class{},Yu=class extends Lo{constructor(e){super()}},Uf=class extends Lo{constructor(){super()}},Fo=class extends Uf{constructor(e){super()}};var j_="^https?:",V_="^wss?:";function $_(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Iv(r,e){let t=$_(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function H_(r){return Iv(r,j_)}function zf(r){return Iv(r,V_)}function Xu(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function Zu(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Ds(r){return Zu(r)&&"method"in r}function Hi(r){return Zu(r)&&(kt(r)||At(r))}function kt(r){return"result"in r}function At(r){return"error"in r}function G_(r){return"error"in r&&r.valid===!1}var Bf=class extends Fo{constructor(e){super(e),this.events=new Mv.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(br(e.method,e.params||[],e.id||gr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{At(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Hi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Pv=qe(hn());var W_=()=>typeof WebSocket<"u"?WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Rv(),J_=()=>typeof WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Tv=r=>r.split("?")[0],Dv=10,Y_=W_(),kf=class{constructor(e){if(this.url=e,this.events=new Pv.EventEmitter,this.registering=!1,!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Wt(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Rt.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Xu(e)},o=new Y_(e,[],s);J_()?o.onerror=f=>{let d=f;i(this.emitError(d.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?Fr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=Pn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Gu(e,Tv(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Dv&&this.events.setMaxListeners(Dv)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Tv(this.url)}`));return this.events.emit("register_error",t),t}};var Om=qe(dm()),Lm=qe(za()),Fm="wc",qm=2,Ld="core",ii=`${Fm}@2:${Ld}:`,AE={name:Ld,logger:"error"},RE={database:":memory:"},TE="crypto",lm="client_ed25519_seed",DE=re.ONE_DAY,PE="keychain",NE="0.3",CE="messages",OE="0.3",LE=re.SIX_HOURS,FE="publisher",Fd="irn",qE="error",Um="wss://relay.walletconnect.org",UE="relayer",Tt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},zE="_subscription",rr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},BE=.1;var dd="2.17.1";var $e={link_mode:"link_mode",relay:"relay"},kE="0.3",KE="WALLETCONNECT_CLIENT_ID",pm="WALLETCONNECT_LINK_MODE_APPS",ti={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var jE="subscription",VE="0.3",$E=re.FIVE_SECONDS*1e3,HE="pairing",GE="0.3";var Ko={wc_pairingDelete:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:re.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:re.ONE_DAY,prompt:!1,tag:0},res:{ttl:re.ONE_DAY,prompt:!1,tag:0}}},Ji={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},vr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},WE="history",JE="0.3",YE="expirer",Kt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},XE="0.3";var ZE="verify-api",QE="https://verify.walletconnect.com",zm="https://verify.walletconnect.org",Os=zm,e9=`${Os}/v3`,t9=[QE,zm],r9="echo",i9="https://echo.walletconnect.com";var mr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ri={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ir={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Yi={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Xi={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Ls={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},n9=.1,s9="event-client",o9=86400,a9="https://pulse.walletconnect.org/batch";function f9(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,z=new Uint8Array(B);P!==U;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,z[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");C=H,P++}for(var O=B-C;O!==B&&z[O]===0;)O++;for(var W=d.repeat(T);O>>0,B=new Uint8Array(U);M[T];){var z=t[M.charCodeAt(T)];if(z===255)return;for(var j=0,H=U-1;(z!==0||j>>0,B[H]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=U-P;L!==U&&B[L]===0;)L++;for(var O=new Uint8Array(C+(U-L)),W=C;L!==U;)O[W++]=B[L++];return O}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var c9=f9,h9=c9,Bm=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},u9=r=>new TextEncoder().encode(r),d9=r=>new TextDecoder().decode(r),ld=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},pd=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return km(this,e)}},gd=class{constructor(e){this.decoders=e}or(e){return km(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},km=(r,e)=>new gd({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),bd=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ld(e,t,i),this.decoder=new pd(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Qf=({name:r,prefix:e,encode:t,decode:i})=>new bd(r,e,t,i),$o=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=h9(t,e);return Qf({prefix:r,name:e,encode:i,decode:s=>Bm(n(s))})},l9=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[h++]=255&d>>f)}if(f>=t||255&d<<8-f)throw new SyntaxError("Unexpected end of data");return o},p9=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Qf({prefix:e,name:r,encode(n){return p9(n,i,t)},decode(n){return l9(n,i,t,r)}}),g9=Qf({prefix:"\0",name:"identity",encode:r=>d9(r),decode:r=>u9(r)}),b9=Object.freeze({__proto__:null,identity:g9}),v9=mt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),m9=Object.freeze({__proto__:null,base2:v9}),y9=mt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),w9=Object.freeze({__proto__:null,base8:y9}),_9=$o({prefix:"9",name:"base10",alphabet:"0123456789"}),x9=Object.freeze({__proto__:null,base10:_9}),E9=mt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),S9=mt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),I9=Object.freeze({__proto__:null,base16:E9,base16upper:S9}),M9=mt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),A9=mt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),R9=mt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),T9=mt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),D9=mt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),P9=mt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),N9=mt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),C9=mt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),O9=mt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),L9=Object.freeze({__proto__:null,base32:M9,base32upper:A9,base32pad:R9,base32padupper:T9,base32hex:D9,base32hexupper:P9,base32hexpad:N9,base32hexpadupper:C9,base32z:O9}),F9=$o({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),q9=$o({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),U9=Object.freeze({__proto__:null,base36:F9,base36upper:q9}),z9=$o({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),B9=$o({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),k9=Object.freeze({__proto__:null,base58btc:z9,base58flickr:B9}),K9=mt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j9=mt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V9=mt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$9=mt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),H9=Object.freeze({__proto__:null,base64:K9,base64pad:j9,base64url:V9,base64urlpad:$9}),Km=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),G9=Km.reduce((r,e,t)=>(r[t]=e,r),[]),W9=Km.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function J9(r){return r.reduce((e,t)=>(e+=G9[t],e),"")}function Y9(r){let e=[];for(let t of r){let i=W9[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var X9=Qf({prefix:"\u{1F680}",name:"base256emoji",encode:J9,decode:Y9}),Z9=Object.freeze({__proto__:null,base256emoji:X9}),Q9=jm,gm=128,e7=127,t7=~e7,r7=Math.pow(2,31);function jm(r,e,t){e=e||[],t=t||0;for(var i=t;r>=r7;)e[t++]=r&255|gm,r/=128;for(;r&t7;)e[t++]=r&255|gm,r>>>=7;return e[t]=r|0,jm.bytes=t-i+1,e}var i7=vd,n7=128,bm=127;function vd(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw vd.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&bm)<=n7);return vd.bytes=s-i,t}var s7=Math.pow(2,7),o7=Math.pow(2,14),a7=Math.pow(2,21),f7=Math.pow(2,28),c7=Math.pow(2,35),h7=Math.pow(2,42),u7=Math.pow(2,49),d7=Math.pow(2,56),l7=Math.pow(2,63),p7=function(r){return r(Vm.encode(r,e,t),e),mm=r=>Vm.encodingLength(r),md=(r,e)=>{let t=e.byteLength,i=mm(r),n=i+mm(t),s=new Uint8Array(n+t);return vm(r,s,0),vm(t,s,i),s.set(e,n),new yd(r,t,e,s)},yd=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},$m=({name:r,code:e,encode:t})=>new wd(r,e,t),wd=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?md(this.code,t):t.then(i=>md(this.code,i))}else throw Error("Unknown type, must be binary type")}},Hm=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),b7=$m({name:"sha2-256",code:18,encode:Hm("SHA-256")}),v7=$m({name:"sha2-512",code:19,encode:Hm("SHA-512")}),m7=Object.freeze({__proto__:null,sha256:b7,sha512:v7}),Gm=0,y7="identity",Wm=Bm,w7=r=>md(Gm,Wm(r)),_7={code:Gm,name:y7,encode:Wm,digest:w7},x7=Object.freeze({__proto__:null,identity:_7});new TextEncoder,new TextDecoder;var ym={...b9,...m9,...w9,...x9,...I9,...L9,...U9,...k9,...H9,...Z9};({...m7,...x7});function E7(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Jm(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var wm=Jm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),hd=Jm("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=E7(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=X("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},xd=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=TE,this.randomSessionIdentifier=Af(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=_h(n);return Ua(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=Ub();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=_h(s),f=this.randomSessionIdentifier;return await fp(f,n,DE,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let f=this.getPrivateKey(n),d=zb(f,s);return this.setSymKey(d,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||Is(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let f=Lu(o),d=Wt(s);if(qu(f))return Kb(d,o?.encoding);if(Fu(f)){let S=f.senderPublicKey,I=f.receiverPublicKey;n=await this.generateSharedKey(S,I)}let h=this.getSymKey(n),{type:b,senderPublicKey:y}=f;return kb({type:b,symKey:h,message:d,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let f=Hb(s,o);if(qu(f)){let d=Vb(s,o?.encoding);return Fr(d)}if(Fu(f)){let d=f.receiverPublicKey,h=f.senderPublicKey;n=await this.generateSharedKey(d,h)}try{let d=this.getSymKey(n),h=jb({symKey:d,encoded:s,encoding:o?.encoding});return Fr(h)}catch(d){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(d)}},this.getPayloadType=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return Bi(o.type)},this.getPayloadSenderPublicKey=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return o.senderPublicKey?Ze(o.senderPublicKey,It):void 0},this.core=e,this.logger=lt(t,this.name),this.keychain=i||new _d(this.core,this.logger)}get context(){return yt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(lm)}catch{e=Af(),await this.keychain.set(lm,e)}return I7(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Ed=class extends ba{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=CE,this.version=OE,this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=pr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=pr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=lt(e,this.name),this.core=t}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Sd=class extends va{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Ei.EventEmitter,this.name=FE,this.queue=new Map,this.publishTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.failedPublishTimeout=(0,re.toMiliseconds)(re.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let f=s?.ttl||LE,d=Rf(s),h=s?.prompt||!1,b=s?.tag||0,y=s?.id||gr().toString(),S={topic:i,message:n,opts:{ttl:f,relay:d,prompt:h,tag:b,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${b}`,M=Date.now(),T,C=1;try{for(;T===void 0;){if(Date.now()-M>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:C},`publisher.publish - attempt ${C}`),T=await await Dn(this.rpcPublish(i,n,f,d,h,b,y,s?.attestation).catch(P=>this.logger.warn(P)),this.publishTimeout,I),C++,T||await new Promise(P=>setTimeout(P,this.failedPublishTimeout))}this.relayer.events.emit(Tt.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(P){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(P),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw P;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=lt(t,this.name),this.registerEventListeners()}get context(){return yt(this.logger)}rpcPublish(e,t,i,n,s,o,f,d){var h,b,y,S;let I={method:As(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:d},id:f};return vt((h=I.params)==null?void 0:h.prompt)&&((b=I.params)==null||delete b.prompt),vt((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(un.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Tt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Tt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Id=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},M7=Object.defineProperty,A7=Object.defineProperties,R7=Object.getOwnPropertyDescriptors,_m=Object.getOwnPropertySymbols,T7=Object.prototype.hasOwnProperty,D7=Object.prototype.propertyIsEnumerable,xm=(r,e,t)=>e in r?M7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jo=(r,e)=>{for(var t in e||(e={}))T7.call(e,t)&&xm(r,t,e[t]);if(_m)for(var t of _m(e))D7.call(e,t)&&xm(r,t,e[t]);return r},ud=(r,e)=>A7(r,R7(e)),Md=class extends wa{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Id,this.events=new Ei.EventEmitter,this.name=jE,this.version=VE,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ii,this.subscribeTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=Rf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let f=new re.Watch;f.start(n);let d=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(d),f.stop(n),s(!0)),f.elapsed(n)>=$E&&(clearInterval(d),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=lt(t,this.name),this.clientId=""}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=Rf(i);await this.rpcUnsubscribe(e,t,n);let s=Ue("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===$e.relay&&await this.restartToComplete();let s={method:As(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let f=pr(e+this.clientId);if(i?.transportType===$e.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(h=>this.logger.warn(h))},(0,re.toMiliseconds)(re.ONE_SECOND)),f;let d=await Dn(this.relayer.request(s).catch(h=>this.logger.warn(h)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!d&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return d?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Tt.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Dn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Dn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:As(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,ud(jo({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,jo({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,jo({},t)),this.topicMap.set(t.topic,e),this.events.emit(ti.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(ti.deleted,ud(jo({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ti.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);Ki(t)&&this.onBatchSubscribe(t.map((i,n)=>ud(jo({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(un.pulse,async()=>{await this.checkPending()}),this.events.on(ti.created,async e=>{let t=ti.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(ti.deleted,async e=>{let t=ti.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},P7=Object.defineProperty,Em=Object.getOwnPropertySymbols,N7=Object.prototype.hasOwnProperty,C7=Object.prototype.propertyIsEnumerable,Sm=(r,e,t)=>e in r?P7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Im=(r,e)=>{for(var t in e||(e={}))N7.call(e,t)&&Sm(r,t,e[t]);if(Em)for(var t of Em(e))C7.call(e,t)&&Sm(r,t,e[t]);return r},Ad=class extends ma{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ei.EventEmitter,this.name=UE,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,re.toMiliseconds)(re.THIRTY_SECONDS+re.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||gr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let f=await new Promise(async(d,h)=>{let b=()=>{h(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(rr.disconnect,b);let y=await o;this.provider.off(rr.disconnect,b),d(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Io())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Tt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Tt.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(rr.payload,this.onPayloadHandler),this.provider.on(rr.connect,this.onConnectHandler),this.provider.on(rr.disconnect,this.onDisconnectHandler),this.provider.on(rr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?lt(e.logger,this.name):(0,Hs.default)(Ws({level:e.logger||qE})),this.messages=new Ed(this.logger,e.core),this.subscriber=new Md(this,this.logger),this.publisher=new Sd(this,this.logger),this.relayUrl=e?.relayUrl||Um,this.projectId=e.projectId,this.bundleId=Ib(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return yt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:$e.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",d,h=b=>{b.topic===e&&(this.subscriber.off(ti.created,h),d())};return await Promise.all([new Promise(b=>{d=b,this.subscriber.on(ti.created,h)}),new Promise(async(b,y)=>{f=await this.subscriber.subscribe(e,Im({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||f,b()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await Dn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(rr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(rr.disconnect,n),await Dn(this.provider.connect(),(0,re.toMiliseconds)(re.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await $u())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=st(re.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Tt.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Io())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Bf(new kf(Mb({sdkVersion:dd,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Ds(e)){if(!e.method.endsWith(zE))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:$e.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Im({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Hi(e)&&this.events.emit(Tt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Tt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=Ts(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(rr.payload,this.onPayloadHandler),this.provider.off(rr.connect,this.onConnectHandler),this.provider.off(rr.disconnect,this.onDisconnectHandler),this.provider.off(rr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await $u();hv(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Tt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,re.toMiliseconds)(BE))))}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},O7=Object.defineProperty,Mm=Object.getOwnPropertySymbols,L7=Object.prototype.hasOwnProperty,F7=Object.prototype.propertyIsEnumerable,Am=(r,e,t)=>e in r?O7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rm=(r,e)=>{for(var t in e||(e={}))L7.call(e,t)&&Am(r,t,e[t]);if(Mm)for(var t of Mm(e))F7.call(e,t)&&Am(r,t,e[t]);return r},ni=class extends ya{constructor(e,t,i,n=ii,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=kE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!vt(o)?this.map.set(this.getKey(o),o):Yb(o)?this.map.set(o.id,o):Xb(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(d=>(0,Om.default)(f[d],o[d]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});let d=Rm(Rm({},this.getData(o)),f);this.map.set(o,d),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=lt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Rd=class{constructor(e,t){this.core=e,this.logger=t,this.name=HE,this.version=GE,this.events=new Ei.default,this.initialized=!1,this.storagePrefix=ii,this.ignoredPayloadTypes=[lr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=Af(),s=await this.core.crypto.setSymKey(n),o=st(re.FIVE_MINUTES),f={protocol:Fd},d={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},h=zu({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Ji.create,d),this.core.expirer.set(s,o),await this.pairings.set(s,d),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[mr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:f,expiryTimestamp:d,methods:h}=Uu(i.uri);n.props.properties.topic=s,n.addTrace(mr.pairing_uri_validation_success),n.addTrace(mr.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(mr.existing_pairing),b.active)throw n.setError(ri.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(mr.pairing_not_expired)}let y=d||st(re.FIVE_MINUTES),S={topic:s,relay:f,expiry:y,active:!1,methods:h};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(mr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Ji.create,S),n.addTrace(mr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(mr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ri.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(I){throw n.setError(ri.subscribe_pairing_topic_failure),I}return n.addTrace(mr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=st(re.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:d}=wi();this.events.once(Oe("pairing_ping",s),({error:h})=>{h?d(h):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Ue("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:f}=i,d=this.core.crypto.keychain.get(n);return zu({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:d,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{let o=br(n,s),f=await this.core.crypto.encode(i,o),d=Ko[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,d),o.id},this.sendResult=async(i,n,s)=>{let o=Ts(i,s),f=await this.core.crypto.encode(n,o),d=await this.core.history.get(n,i),h=Ko[d.request.method].res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=Pn(i,s),f=await this.core.crypto.encode(n,o),d=await this.core.history.get(n,i),h=Ko[d.request.method]?Ko[d.request.method].res:Ko.unregistered_method.res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Ue("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>Xr(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Ji.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{kt(n)?this.events.emit(Oe("pairing_ping",s),{}):At(n)&&this.events.emit(Oe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Ji.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let f=Ue("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Ue("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Mt(i)){let{message:f}=X("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!Jb(i.uri)){let{message:f}=X("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}let o=Uu(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&(0,re.toMiliseconds)(o?.expiryTimestamp){if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!Ye(i,!1)){let{message:n}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Xr(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=X("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=lt(t,this.name),this.pairings=new ni(this.core,this.logger,this.name,this.storagePrefix)}get context(){return yt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Tt.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===$e.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{Ds(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Hi(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Kt.expired,async e=>{let{topic:t}=If(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Ji.expire,{topic:t}))})}},Td=class extends ga{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Ei.EventEmitter,this.name=WE,this.version=JE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:st(re.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(vr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=At(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(vr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(vr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:br(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(vr.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(vr.created,e=>{let t=vr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.updated,e=>{let t=vr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.deleted,e=>{let t=vr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(un.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,re.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(vr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Dd=class extends _a{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Ei.EventEmitter,this.name=YE,this.version=XE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Kt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Kt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Rb(e);if(typeof e=="number")return Tb(e);let{message:t}=X("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Kt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,re.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Kt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(un.pulse,()=>this.checkExpirations()),this.events.on(Kt.created,e=>{let t=Kt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.expired,e=>{let t=Kt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.deleted,e=>{let t=Kt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Pd=class extends xa{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=ZE,this.verifyUrlV3=e9,this.storagePrefix=ii,this.version=qm,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,re.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!_s()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:f}=n,d=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{let h=(0,Lm.getDocument)(),b=this.startAbortTimer(re.ONE_SECOND*5),y=await new Promise((S,I)=>{let M=()=>{window.removeEventListener("message",C),h.body.removeChild(T),I("attestation aborted")};this.abortController.signal.addEventListener("abort",M);let T=h.createElement("iframe");T.src=d,T.style.display="none",T.addEventListener("error",M,{signal:this.abortController.signal});let C=P=>{if(P.data&&typeof P.data=="string")try{let U=JSON.parse(P.data);if(U.type==="verify_attestation"){if(ts(U.attestation).payload.id!==o)return;clearInterval(b),h.body.removeChild(T),this.abortController.signal.removeEventListener("abort",M),window.removeEventListener("message",C),S(U.attestation===null?"":U.attestation)}}catch(U){this.logger.warn(U)}};h.body.appendChild(T),window.addEventListener("message",C,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(h){this.logger.warn(h)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ts(s).payload.id!==f)return;let h=await this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;let d=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,d)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(re.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||Os;return t9.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Os}`),s=Os),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(re.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=Gb(n,s.publicKey),f={hasExpired:(0,re.toMiliseconds)(o.exp)this.abortController.abort(),(0,re.toMiliseconds)(e))}},Nd=class extends Ea{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=r9,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,d=`${i9}/${this.projectId}/clients`;await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=lt(t,this.context)}},q7=Object.defineProperty,Tm=Object.getOwnPropertySymbols,U7=Object.prototype.hasOwnProperty,z7=Object.prototype.propertyIsEnumerable,Dm=(r,e,t)=>e in r?q7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vo=(r,e)=>{for(var t in e||(e={}))U7.call(e,t)&&Dm(r,t,e[t]);if(Tm)for(var t of Tm(e))z7.call(e,t)&&Dm(r,t,e[t]);return r},Cd=class extends Sa{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=s9,this.storagePrefix=ii,this.storageVersion=n9,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Ao())try{let n={eventId:Ru(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Su(this.core.relayer.protocol,this.core.relayer.version,dd)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:f,trace:d}}=n,h=Ru(),b=this.core.projectId||"",y=Date.now(),S=Vo({eventId:h,timestamp:y,props:{event:s,type:o,properties:{topic:f,trace:d}},bundleId:b,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let f=Array.from(this.events.values()).find(d=>d.props.properties.topic===o);if(f)return Vo(Vo({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(un.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,re.fromMiliseconds)(Date.now())-(0,re.fromMiliseconds)(n.timestamp)>o9&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Vo(Vo({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${a9}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${dd}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>xs().url,this.logger=lt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},B7=Object.defineProperty,Pm=Object.getOwnPropertySymbols,k7=Object.prototype.hasOwnProperty,K7=Object.prototype.propertyIsEnumerable,Nm=(r,e,t)=>e in r?B7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cm=(r,e)=>{for(var t in e||(e={}))k7.call(e,t)&&Nm(r,t,e[t]);if(Pm)for(var t of Pm(e))K7.call(e,t)&&Nm(r,t,e[t]);return r},Od=class r extends pa{constructor(e){var t;super(e),this.protocol=Fm,this.version=qm,this.name=Ld,this.events=new Ei.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:d})=>{if(!o||!f)return;let h={topic:o,message:f,publishedAt:Date.now(),transportType:$e.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:d})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Um,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Ws({level:typeof e?.logger=="string"&&e.logger?e.logger:AE.logger}),{logger:n,chunkLoggerController:s}=Zl({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=lt(n,this.name),this.heartbeat=new na,this.crypto=new xd(this,this.logger,e?.keychain),this.history=new Td(this,this.logger),this.expirer=new Dd(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new aa(Cm(Cm({},RE),e?.storageOptions)),this.relayer=new Ad({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Rd(this,this.logger),this.verify=new Pd(this,this.logger,this.storage),this.echoClient=new Nd(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Cd(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(KE,i),t}get context(){return yt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(pm,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(pm)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},Ym=Od;var rc=qe(hn()),Fe=qe(jn());var ey="wc",ty=2,ry="client",Gd=`${ey}@${ty}:${ry}:`,qd={name:ry,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var Xm="WALLETCONNECT_DEEPLINK_CHOICE";var j7="proposal";var V7="Proposal expired",$7="session",Fs=Fe.SEVEN_DAYS,H7="engine",dt={wc_sessionPropose:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Fe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Fe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1119}}},Ud={min:Fe.FIVE_MINUTES,max:Fe.SEVEN_DAYS},si={idle:"IDLE",active:"ACTIVE"},G7="request",W7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],J7="wc";var Y7="auth",X7="authKeys",Z7="pairingTopics",Q7="requests",ic=`${J7}@${1.5}:${Y7}:`,ec=`${ic}:PUB_KEY`,eS=Object.defineProperty,tS=Object.defineProperties,rS=Object.getOwnPropertyDescriptors,Zm=Object.getOwnPropertySymbols,iS=Object.prototype.hasOwnProperty,nS=Object.prototype.propertyIsEnumerable,Qm=(r,e,t)=>e in r?eS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tt=(r,e)=>{for(var t in e||(e={}))iS.call(e,t)&&Qm(r,t,e[t]);if(Zm)for(var t of Zm(e))nS.call(e,t)&&Qm(r,t,e[t]);return r},yr=(r,e)=>tS(r,rS(e)),zd=class extends Ma{constructor(e){super(e),this.name=H7,this.events=new rc.default,this.initialized=!1,this.requestQueue={state:si.idle,queue:[]},this.sessionRequestQueue={state:si.idle,queue:[]},this.requestQueueDelay=Fe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(dt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=yr(tt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:d}=i,h=n,b,y=!1;try{h&&(y=this.client.core.pairing.pairings.get(h).active)}catch(z){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),z}if(!h||!y){let{topic:z,uri:j}=await this.client.core.pairing.create();h=z,b=j}if(!h){let{message:z}=X("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(z)}let S=await this.client.core.crypto.generateKeyPair(),I=dt.wc_sessionPropose.req.ttl||Fe.FIVE_MINUTES,M=st(I),T=tt({requiredNamespaces:s,optionalNamespaces:o,relays:d??[{protocol:Fd}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:M,pairingTopic:h},f&&{sessionProperties:f}),{reject:C,resolve:P,done:U}=wi(I,V7);this.events.once(Oe("session_connect"),async({error:z,session:j})=>{if(z)C(z);else if(j){j.self.publicKey=S;let H=yr(tt({},j),{pairingTopic:T.pairingTopic,requiredNamespaces:T.requiredNamespaces,optionalNamespaces:T.optionalNamespaces,transportType:$e.relay});await this.client.session.set(j.topic,H),await this.setExpiry(j.topic,j.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(H),P(H)}});let B=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:T,throwOnFailedPublish:!0});return await this.setProposal(B,tt({id:B},T)),{uri:b,approval:U}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[ir.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(O){throw o.setError(Yi.no_internet_connection),O}try{await this.isValidProposalId(t?.id)}catch(O){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(Yi.proposal_not_found),O}try{await this.isValidApprove(t)}catch(O){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Yi.session_approve_namespace_validation_failure),O}let{id:f,relayProtocol:d,namespaces:h,sessionProperties:b,sessionConfig:y}=t,S=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:M,requiredNamespaces:T,optionalNamespaces:C}=S,P=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});P||(P=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:ir.session_approve_started,properties:{topic:I,trace:[ir.session_approve_started,ir.session_namespaces_validation_success]}}));let U=await this.client.core.crypto.generateKeyPair(),B=M.publicKey,z=await this.client.core.crypto.generateSharedKey(U,B),j=tt(tt({relay:{protocol:d??"irn"},namespaces:h,controller:{publicKey:U,metadata:this.client.metadata},expiry:st(Fs)},b&&{sessionProperties:b}),y&&{sessionConfig:y}),H=$e.relay;P.addTrace(ir.subscribing_session_topic);try{await this.client.core.relayer.subscribe(z,{transportType:H})}catch(O){throw P.setError(Yi.subscribe_session_topic_failure),O}P.addTrace(ir.subscribe_session_topic_success);let L=yr(tt({},j),{topic:z,requiredNamespaces:T,optionalNamespaces:C,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:M.publicKey,metadata:M.metadata},controller:U,transportType:$e.relay});await this.client.session.set(z,L),P.addTrace(ir.store_session);try{P.addTrace(ir.publishing_session_settle),await this.sendRequest({topic:z,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(O=>{throw P?.setError(Yi.session_settle_publish_failure),O}),P.addTrace(ir.session_settle_publish_success),P.addTrace(ir.publishing_session_approve),await this.sendResult({id:f,topic:I,result:{relay:{protocol:d??"irn"},responderPublicKey:U},throwOnFailedPublish:!0}).catch(O=>{throw P?.setError(Yi.session_approve_publish_failure),O}),P.addTrace(ir.session_approve_publish_success)}catch(O){throw this.client.logger.error(O),this.client.session.delete(z,Ue("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(z),O}return this.client.core.eventClient.deleteEvent({eventId:P.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:M.metadata}),await this.client.proposal.delete(f,Ue("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(z,st(Fs)),{topic:z,acknowledged:()=>Promise.resolve(this.client.session.get(z))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:dt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=wi(),d=Qr(),h=gr().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Oe("session_update",d),({error:y})=>{y?f(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:d,relayRpcId:h}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:b}),f(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(d){throw this.client.logger.error("extend() -> isValidExtend() failed"),d}let{topic:i}=t,n=Qr(),{done:s,resolve:o,reject:f}=wi();return this.events.once(Oe("session_extend",n),({error:d})=>{d?f(d):o()}),await this.setExpiry(i,st(Fs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(d=>{f(d)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(M){throw this.client.logger.error("request() -> isValidRequest() failed"),M}let{chainId:i,request:n,topic:s,expiry:o=dt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let d=Qr(),h=gr().toString(),{done:b,resolve:y,reject:S}=wi(o,"Request expired. Please try again.");this.events.once(Oe("session_request",d),({error:M,result:T})=>{M?S(M):y(T)});let I=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return I?(await this.sendRequest({clientRpcId:d,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(M=>S(M)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:d}),await b()):await Promise.all([new Promise(async M=>{await this.sendRequest({clientRpcId:d,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(T=>S(T)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:d}),M()}),new Promise(async M=>{var T;if(!((T=f.sessionConfig)!=null&&T.disableDeepLink)){let C=await Pb(this.client.core.storage,Xm);await Db({id:d,topic:s,wcDeepLink:C})}M()}),b()]).then(M=>M[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);kt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):At(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=Qr(),s=gr().toString(),{done:o,resolve:f,reject:d}=wi();this.events.once(Oe("session_ping",n),({error:h})=>{h?d(h):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=gr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Ue("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=X("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>Wb(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?$e.link_mode:$e.relay;o===$e.relay&&await this.confirmOnlineStateOrThrow();let{chains:f,statement:d="",uri:h,domain:b,nonce:y,type:S,exp:I,nbf:M,methods:T=[],expiry:C}=t,P=[...t.resources||[]],{topic:U,uri:B}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:U,uri:B}});let z=await this.client.core.crypto.generateKeyPair(),j=Is(z);if(await Promise.all([this.client.auth.authKeys.set(ec,{responseTopic:j,publicKey:z}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:U})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${U}`),T.length>0){let{namespace:m}=So(f[0]),c=Ob(m,"request",T);To(P)&&(c=Lb(c,P.pop())),P.push(c)}let H=C&&C>dt.wc_sessionAuthenticate.req.ttl?C:dt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:f,statement:d,aud:h,domain:b,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:M,resources:P},requester:{publicKey:z,metadata:this.client.metadata},expiryTimestamp:st(H)},O={eip155:{chains:f,methods:[...new Set(["personal_sign",...T])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:O,relays:[{protocol:"irn"}],pairingTopic:U,proposer:{publicKey:z,metadata:this.client.metadata},expiryTimestamp:st(dt.wc_sessionPropose.req.ttl)},{done:D,resolve:l,reject:w}=wi(H,"Request expired"),p=async({error:m,session:c})=>{if(this.events.off(Oe("session_request",u),a),m)w(m);else if(c){c.self.publicKey=z,await this.client.session.set(c.topic,c),await this.setExpiry(c.topic,c.expiry),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:c.peer.metadata});let x=this.client.session.get(c.topic);await this.deleteProposal(v),l({session:x})}},a=async m=>{var c,x,A;if(await this.deletePendingAuthRequest(u,{message:"fulfilled",code:0}),m.error){let q=Ue("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return m.error.code===q.code?void 0:(this.events.off(Oe("session_connect"),p),w(m.error.message))}await this.deleteProposal(v),this.events.off(Oe("session_connect"),p);let{cacaos:g,responder:R}=m.result,k=[],E=[];for(let q of g){await Du({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,J=To(K.resources),$=[Mf(K.iss)],V=Ro(K.iss);if(J){let ee=Nu(J),G=Cu(J);k.push(...ee),$.push(...G)}for(let ee of $)E.push(`${ee}:${V}`)}let N=await this.client.core.crypto.generateSharedKey(z,R.publicKey),F;k.length>0&&(F={topic:N,acknowledged:!0,self:{publicKey:z,metadata:this.client.metadata},peer:R,controller:R.publicKey,expiry:st(Fs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:U,namespaces:Bu([...new Set(k)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(N,{transportType:o}),await this.client.session.set(N,F),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:R.metadata}),F=this.client.session.get(N)),(c=this.client.metadata.redirect)!=null&&c.linkMode&&(x=R.metadata.redirect)!=null&&x.linkMode&&(A=R.metadata.redirect)!=null&&A.universal&&i&&(this.client.core.addLinkModeSupportedApp(R.metadata.redirect.universal),this.client.session.update(N,{transportType:$e.link_mode})),l({auths:g,session:F})},u=Qr(),v=Qr();this.events.once(Oe("session_connect"),p),this.events.once(Oe("session_request",u),a);let _;try{if(s){let m=br("wc_sessionAuthenticate",L,u);this.client.core.history.set(U,m);let c=await this.client.core.crypto.encode("",m,{type:Ss,encoding:Es});_=Po(i,U,c)}else await Promise.all([this.sendRequest({topic:U,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:u}),this.sendRequest({topic:U,method:"wc_sessionPropose",params:W,expiry:dt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:v})])}catch(m){throw this.events.off(Oe("session_connect"),p),this.events.off(Oe("session_request",u),a),m}return await this.setProposal(v,tt({id:v},W)),await this.setAuthRequest(u,{request:yr(tt({},L),{verifyContext:{}}),pairingTopic:U,transportType:o}),{uri:_??B,response:D}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Xi.authenticated_session_approve_started]}});try{this.isInitialized()}catch(C){throw s.setError(Ls.no_internet_connection),C}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Ls.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let f=o.transportType||$e.relay;f===$e.relay&&await this.confirmOnlineStateOrThrow();let d=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),b=Is(d),y={type:lr,receiverPublicKey:d,senderPublicKey:h},S=[],I=[];for(let C of n){if(!await Du({cacao:C,projectId:this.client.core.projectId})){s.setError(Ls.invalid_cacao);let j=Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:j,encodeOpts:y}),new Error(j.message)}s.addTrace(Xi.cacaos_verified);let{p:P}=C,U=To(P.resources),B=[Mf(P.iss)],z=Ro(P.iss);if(U){let j=Nu(U),H=Cu(U);S.push(...j),B.push(...H)}for(let j of B)I.push(`${j}:${z}`)}let M=await this.client.core.crypto.generateSharedKey(h,d);s.addTrace(Xi.create_authenticated_session_topic);let T;if(S?.length>0){T={topic:M,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:d,metadata:o.requester.metadata},controller:d,expiry:st(Fs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Bu([...new Set(S)],[...new Set(I)]),transportType:f},s.addTrace(Xi.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(M,{transportType:f})}catch(C){throw s.setError(Ls.subscribe_authenticated_session_topic_failure),C}s.addTrace(Xi.subscribe_authenticated_session_topic_success),await this.client.session.set(M,T),s.addTrace(Xi.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Xi.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(C){throw s.setError(Ls.authenticated_session_approve_publish_failure),C}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:T}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),d=Is(o),h={type:lr,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:d,error:n,encodeOpts:h,rpcOpts:dt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return Pu(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:d}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Ue("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(d.publicKey)&&await this.client.core.crypto.deleteKeyPair(d.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Xm).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,Ue("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=si.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(Yi.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Ue("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=si.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,st(dt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=$e.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||st(dt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:d,throwOnFailedPublish:h,appLink:b}=t,y=br(n,s,d),S,I=!!b;try{let C=I?Es:Zr;S=await this.client.core.crypto.encode(i,y,{encoding:C})}catch(C){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),C}let M;if(W7.includes(n)){let C=pr(JSON.stringify(y)),P=pr(S);M=await this.client.core.verify.register({id:P,decryptedId:C})}let T=dt[n].req;if(T.attestation=M,o&&(T.ttl=o),f&&(T.id=f),this.client.core.history.set(i,y),I){let C=Po(b,i,S);await window.Linking.openURL(C,this.client.name)}else{let C=dt[n].req;o&&(C.ttl=o),f&&(C.id=f),h?(C.internal=yr(tt({},C.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,C)):this.client.core.relayer.publish(i,S,C).catch(P=>this.client.logger.error(P))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:d}=t,h=Ts(i,s),b,y=d&&typeof window?.Linking<"u";try{let I=y?Es:Zr;b=await this.client.core.crypto.encode(n,h,yr(tt({},f||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Po(d,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=dt[S.request.method].res;o?(I.internal=yr(tt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,I)):this.client.core.relayer.publish(n,b,I).catch(M=>this.client.logger.error(M))}await this.client.core.history.resolve(h)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:d}=t,h=Pn(i,s),b,y=d&&typeof window?.Linking<"u";try{let I=y?Es:Zr;b=await this.client.core.crypto.encode(n,h,yr(tt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Po(d,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=f||dt[S.request.method].res;this.client.core.relayer.publish(n,b,I)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Xr(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Xr(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===si.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=si.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=si.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,d=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:d}))switch(d){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${d}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=X("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:d}=n;try{let h=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(tt({},n.params));let b=f.expiryTimestamp||st(dt.wc_sessionPropose.req.ttl),y=tt({id:d,pairingTopic:i,expiryTimestamp:b},f);await this.setProposal(d,y);let S=await this.getVerifyContext({attestationId:s,hash:pr(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(ri.proposal_listener_not_found)),h?.addTrace(mr.emit_session_proposal),this.client.events.emit("session_proposal",{id:d,params:y,verifyContext:S})}catch(h){await this.sendError({id:d,topic:i,error:h,rpcOpts:dt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(kt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});let d=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:d});let h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});let b=await this.client.core.crypto.generateSharedKey(d,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});let y=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(At(i)){await this.client.proposal.delete(s,Ue("USER_DISCONNECTED"));let o=Oe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Oe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:f,expiry:d,namespaces:h,sessionProperties:b,sessionConfig:y}=i.params,S=yr(tt(tt({topic:t,relay:o,expiry:d,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},b&&{sessionProperties:b}),y&&{sessionConfig:y}),{transportType:$e.relay}),I=Oe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Oe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;kt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Oe("session_approve",n),{})):At(i)&&(await this.client.session.delete(t,Ue("USER_DISCONNECTED")),this.events.emit(Oe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,f=ki.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:Ue("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(tt({topic:t},n));try{ki.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(d){throw ki.delete(o),d}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Oe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_update",n),{}):At(i)&&this.events.emit(Oe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,st(Fs)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Oe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_extend",n),{}):At(i)&&this.events.emit(Oe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Oe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{kt(i)?this.events.emit(Oe("session_ping",n),{}):At(i)&&this.events.emit(Oe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Tt.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Ue("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:f,attestation:d,encryptedId:h,transportType:b}=t,{id:y,params:S}=f;try{await this.isValidRequest(tt({topic:o},S));let I=this.client.session.get(o),M=await this.getVerifyContext({attestationId:d,hash:pr(JSON.stringify(br("wc_sessionRequest",S,y))),encryptedId:h,metadata:I.peer.metadata,transportType:b}),T={id:y,topic:o,params:S,verifyContext:M};await this.setPendingSessionRequest(T),b===$e.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(T):(this.addSessionRequestToSessionRequestQueue(T),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Oe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,f=ki.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(tt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),ki.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:f,transportType:d}=t;try{let{requester:h,authPayload:b,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:pr(JSON.stringify(s)),encryptedId:f,metadata:h.metadata,transportType:d}),I={requester:h,pairingTopic:n,id:s.id,authPayload:b,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:d}),d===$e.link_mode&&(i=h.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(h){this.client.logger.error(h);let b=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,d),I={type:lr,receiverPublicKey:b,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:I,rpcOpts:dt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=si.idle,this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,f=Oe("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Oe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===si.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=si.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:br("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Mt(t)){let{message:d}=X("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(d)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(vt(i)||await this.isValidPairingTopic(i),!tv(f,!0)){let{message:d}=X("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(d)}!vt(n)&&No(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!vt(s)&&No(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),vt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=ev(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Mt(t))throw new Error(X("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let f=this.client.proposal.get(i),d=Tf(n,"approve()");if(d)throw new Error(d.message);let h=Vu(f.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!Ye(s,!0)){let{message:b}=X("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}vt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Mt(t)){let{message:s}=X("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!iv(n)){let{message:s}=X("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Mt(t)){let{message:h}=X("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(h)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Ku(i)){let{message:h}=X("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}let f=Zb(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);let d=Tf(s,"onSessionSettleRequest()");if(d)throw new Error(d.message);if(Xr(o)){let{message:h}=X("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async t=>{if(!Mt(t)){let{message:d}=X("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(d)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=Tf(n,"update()");if(o)throw new Error(o.message);let f=Vu(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Mt(t)){let{message:d}=X("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(d)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:f}=this.client.session.get(i);if(!ju(f,s)){let{message:d}=X("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(d)}if(!nv(n)){let{message:d}=X("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(d)}if(!av(f,s,n.method)){let{message:d}=X("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(d)}if(o&&!cv(o,Ud)){let{message:d}=X("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Ud.min} and ${Ud.max}`);throw new Error(d)}},this.isValidRespond=async t=>{var i;if(!Mt(t)){let{message:o}=X("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!sv(s)){let{message:o}=X("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Mt(t)){let{message:f}=X("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!ju(o,s)){let{message:f}=X("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!ov(n)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!fv(o,s,n.name)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Ye(n,!1))throw new Error("uri is required parameter");if(!Ye(s,!1))throw new Error("domain is required parameter");if(!Ye(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(d=>So(d).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:f}=So(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,d={verified:{verifyUrl:o.verifyUrl||Os,validation:"UNKNOWN",origin:o.url||""}};try{if(f===$e.link_mode){let b=this.getAppLinkIfEnabled(o,f);return d.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",d}let h=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});h&&(d.verified.origin=h.origin,d.verified.isScam=h.isScam,d.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(d)}`),d},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!Ye(n,!1)){let{message:s}=X("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,d,h,b,y,S;return!t||i!==$e.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((h=(d=this.client.metadata)==null?void 0:d.redirect)==null?void 0:h.universal)!==""&&((b=t?.redirect)==null?void 0:b.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof window?.Linking<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=Au(t,"topic")||"",n=decodeURIComponent(Au(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:$e.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Ao()||Tn()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=window?.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Tt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(ec)?this.client.auth.authKeys.get(ec):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===$e.link_mode?Es:Zr});try{Ds(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:pr(i)})):Hi(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(d){this.client.logger.error(d)}}registerExpirerEvents(){this.client.core.expirer.on(Kt.expired,async e=>{let{topic:t,id:i}=If(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,X("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,X("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Ji.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Ji.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=X("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=X("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=X("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Ye(e,!1)){let{message:t}=X("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=X("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!rv(e)){let{message:t}=X("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=X("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},Bd=class extends ni{constructor(e,t){super(e,t,j7,Gd),this.core=e,this.logger=t}},kd=class extends ni{constructor(e,t){super(e,t,$7,Gd),this.core=e,this.logger=t}},Kd=class extends ni{constructor(e,t){super(e,t,G7,Gd,i=>i.id),this.core=e,this.logger=t}},jd=class extends ni{constructor(e,t){super(e,t,X7,ic,()=>ec),this.core=e,this.logger=t}},Vd=class extends ni{constructor(e,t){super(e,t,Z7,ic),this.core=e,this.logger=t}},$d=class extends ni{constructor(e,t){super(e,t,Q7,ic,i=>i.id),this.core=e,this.logger=t}},Hd=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new jd(this.core,this.logger),this.pairingTopics=new Vd(this.core,this.logger),this.requests=new $d(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},tc=class r extends Ia{constructor(e){super(e),this.protocol=ey,this.version=ty,this.name=qd.name,this.events=new rc.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||qd.name,this.metadata=e?.metadata||xs(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,Hs.default)(Ws({level:e?.logger||qd.logger}));this.core=e?.core||new Ym(e),this.logger=lt(t,this.name),this.session=new kd(this.core,this.logger),this.proposal=new Bd(this.core,this.logger),this.pendingRequest=new Kd(this.core,this.logger),this.engine=new zd(this),this.auth=new Hd(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return yt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var iy=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],wr="mvx";var Ho=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);function Wd(r){return r[Math.floor(Math.random()*r.length)]}var ny="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Jd=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;ti.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Si(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=Xd(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function sy(r){return!!r}function Zd(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function Qd({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,f=r.guardian;if(f&&f!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=Jd(t),i&&(r.guardianSignature=Jd(i)),r}function oy(r){if(r)return{...r,url:xs().url}}async function ay(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var oi=class{constructor(e,t,i,n,s,o,f,d){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.Message=s,this.Transaction=o,this.TransactionsConverter=f,this.options=d}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:oy(this.options?.metadata)}:{},t=await tc.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=Yd(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await ay(500);let i=Zd(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Si(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:Ue("USER_DISCONNECTED")});else{let t=Si(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:Ue("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return Qd({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];Qd({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Si(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?sy(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=Zd(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&Si(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=Xd(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!Ki(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var Fn=(r=>(r[r.Border=-1]="Border",r[r.Data=0]="Data",r[r.Function=1]="Function",r[r.Position=2]="Position",r[r.Timing=3]="Timing",r[r.Alignment=4]="Alignment",r))(Fn||{}),aS=Object.defineProperty,fS=(r,e,t)=>e in r?aS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nc=(r,e,t)=>(fS(r,typeof e!="symbol"?e+"":e,t),t),cS=[0,1],cy=[1,0],hy=[2,3],uy=[3,2],hS={L:cS,M:cy,Q:hy,H:uy},uS=/^[0-9]*$/,dS=/^[A-Z0-9 $%*+.\/:-]*$/,el="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",nl=1,sl=40,fy=3,lS=3,sc=40,pS=10,dy=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],ly=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],tl=class{constructor(e,t,i,n){if(this.version=e,this.ecc=t,nc(this,"size"),nc(this,"mask"),nc(this,"modules",[]),nc(this,"types",[]),esl)throw new RangeError("Version value out of range");if(n<-1||n>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let s=Array.from({length:this.size},()=>!1);for(let f=0;f0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(i);if(this.drawCodewords(o),n===-1){let f=1e9;for(let d=0;d<8;d++){this.applyMask(d),this.drawFormatBits(d);let h=this.getPenaltyScore();h=0&&e=0&&t>>9)*1335;let n=(t<<10|i)^21522;for(let s=0;s<=5;s++)this.setFunctionModule(8,s,Ii(n,s));this.setFunctionModule(8,7,Ii(n,6)),this.setFunctionModule(8,8,Ii(n,7)),this.setFunctionModule(7,8,Ii(n,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,Ii(n,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,Ii(n,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,Ii(n,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let i=0;i<12;i++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let i=0;i<18;i++){let n=Ii(t,i),s=this.size-11+i%3,o=Math.floor(i/3);this.setFunctionModule(s,o,n),this.setFunctionModule(o,s,n)}}drawFinderPattern(e,t){for(let i=-4;i<=4;i++)for(let n=-4;n<=4;n++){let s=Math.max(Math.abs(n),Math.abs(i)),o=e+n,f=t+i;o>=0&&o=0&&f{(S!==d-s||M>=f)&&y.push(I[S])});return y}drawCodewords(e){if(e.length!==Math.floor(rl(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let i=this.size-1;i>=1;i-=2){i===6&&(i=5);for(let n=0;n>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(f,d),o||(e+=this.finderPenaltyCountPatterns(d)*sc),o=this.modules[s][h],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,d)*sc}for(let s=0;s5&&e++):(this.finderPenaltyAddHistory(f,d),o||(e+=this.finderPenaltyCountPatterns(d)*sc),o=this.modules[h][s],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,d)*sc}for(let s=0;so+(f?1:0),t);let i=this.size*this.size,n=Math.ceil(Math.abs(t*20-i*10)/i)-1;return e+=n*pS,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,i=[6];for(let n=this.size-7;i.length0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(i&&e[0]>=t*4&&e[6]>=t?1:0)+(i&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,i){return e&&(this.finderPenaltyAddHistory(t,i),t=0),t+=this.size,this.finderPenaltyAddHistory(t,i),this.finderPenaltyCountPatterns(i)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Mi(r,e,t){if(e<0||e>31||r>>>e)throw new RangeError("Value out of range");for(let i=e-1;i>=0;i--)t.push(r>>>i&1)}function Ii(r,e){return(r>>>e&1)!==0}var Go=class{constructor(e,t,i){if(this.mode=e,this.numChars=t,this.bitData=i,t<0)throw new RangeError("Invalid argument");this.bitData=i.slice()}getData(){return this.bitData.slice()}},gS=[1,10,12,14],bS=[2,9,11,13],vS=[4,8,16,16];function py(r,e){return r[Math.floor((e+7)/17)+1]}function gy(r){let e=[];for(let t of r)Mi(t,8,e);return new Go(vS,r.length,e)}function mS(r){if(!by(r))throw new RangeError("String contains non-numeric characters");let e=[];for(let t=0;t=1<sl)throw new RangeError("Version number out of range");let e=(16*r+128)*r+64;if(r>=2){let t=Math.floor(r/7)+2;e-=(25*t-10)*t-55,r>=7&&(e-=36)}return e}function oc(r,e){return Math.floor(rl(r)/8)-dy[e[0]][r]*ly[e[0]][r]}function ES(r){if(r<1||r>255)throw new RangeError("Degree out of range");let e=[];for(let i=0;i0);for(let i of r){let n=i^t.shift();t.push(0),e.forEach((s,o)=>t[o]^=il(s,n))}return t}function il(r,e){if(r>>>8||e>>>8)throw new RangeError("Byte out of range");let t=0;for(let i=7;i>=0;i--)t=t<<1^(t>>>7)*285,t^=(e>>>i&1)*r;return t}function IS(r,e,t=1,i=40,n=-1,s=!0){if(!(nl<=t&&t<=i&&i<=sl)||n<-1||n>7)throw new RangeError("Invalid value");let o,f;for(o=t;;o++){let y=oc(o,e)*8,S=_S(r,o);if(S<=y){f=S;break}if(o>=i)throw new RangeError("Data too long")}for(let y of[cy,hy,uy])s&&f<=oc(o,y)*8&&(e=y);let d=[];for(let y of r){Mi(y.mode[0],4,d),Mi(y.numChars,py(y.mode,o),d);for(let S of y.getData())d.push(S)}let h=oc(o,e)*8;Mi(0,Math.min(4,h-d.length),d),Mi(0,(8-d.length%8)%8,d);for(let y=236;d.length0);return d.forEach((y,S)=>b[S>>>3]|=y<<7-(S&7)),new tl(o,e,b,n)}function MS(r,e){let{ecc:t="L",boostEcc:i=!1,minVersion:n=1,maxVersion:s=40,maskPattern:o=-1,border:f=1}=e||{},d=typeof r=="string"?wS(r):Array.isArray(r)?[gy(r)]:void 0;if(!d)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof r}`);let h=IS(d,hS[t],n,s,o,i),b=AS({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},f);return e?.invert&&(b.data=b.data.map(y=>y.map(S=>!S))),e?.onEncoded?.(b),b}function AS(r,e=1){if(!e)return r;let{size:t}=r,i=t+e*2;r.size=i,r.data.forEach(s=>{for(let o=0;o!1)),r.data.push(Array.from({length:i},o=>!1));let n=Fn.Border;r.types.forEach(s=>{for(let o=0;on)),r.types.push(Array.from({length:i},o=>n));return r}function my(r,e={}){let t=MS(r,e),{pixelSize:i=10,whiteColor:n="white",blackColor:s="black"}=e,o=t.size*i,f=t.size*i,d=``,h=[];for(let b=0;b`,d+=``,d+="",d}var TS=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},DS=r=>{let e=`${ny}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},PS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},NS=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},ol={},CS=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",ol[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:ol[r.topic].signal}),t},ac={},OS=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=CS(r,e);return i.appendChild(s),ac[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:ac[r.topic].signal}),i},LS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},FS=r=>{if(!r)return;document.getElementById(r)?.remove()},qS=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),US=r=>r?my(r):void 0,yy=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=US(e),o;if(s&&(o=TS(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),qS()&&n.appendChild(DS(e))),n&&t instanceof oi){let f=t.pairings,d=async b=>{try{b&&(await t.logout({topic:b}),FS(b))}catch(y){let S=Ho(y);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{ac[b].abort()}},h=async b=>{try{let{approval:y}=await t.connect({topic:b,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(b)?.after(LS()),await t.login({approval:y,token:i})}catch(y){let S=Ho(y);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let y of Object.values(ac))y?.abort();for(let y of Object.values(ol))y?.abort()}};if(f&&f.length>0){let b=PS();n.appendChild(b);let y=NS();b.appendChild(y);for(let S of f){let I=OS(S,d,h);b.appendChild(I)}}}return n};var wy=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:t,qrCodeContainer:i}){this.WalletConnectV2Provider=oi;this.initMobileProvider=async(e,t,i,n,s,o)=>{if(!this.walletConnectV2ProjectId||!e.initOptions.chainType)return;let f={onClientLogin:()=>{},onClientLogout:()=>t(e),onClientEvent:b=>{console.log("wc2 session event: ",b)}},d=Wd(this.walletConnectV2RelayAddresses),h=new oi(f,i[e.initOptions.chainType].shortId,d,this.walletConnectV2ProjectId,n,s,o);try{return await h.init(),h}catch{console.warn("Can't initialize the Dapp Provider!");return}};this.loginWithMobile=async(e,t,i,n,s,o,f,d,h,b,y,S)=>{if(!this.qrCodeContainer)throw new Error("You haven't provided the QR code container DOM element id");let I=Wd(this.walletConnectV2RelayAddresses);if(!I||!e.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!this.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!e.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let M,T={onClientLogin:async()=>{if(e.dappProvider instanceof oi){let P=e.dappProvider.getAddress(),U=e.dappProvider.getSignature();if(n.set("address",P),n.set("loginMethod","mobile"),n.set("expires",o()),await f(e),U){n.set("signature",U),n.set("loginToken",t);let B=i.getToken(P,t,U);n.set("accessToken",B),d.run("onLoginSuccess"),M?.replaceChildren()}}},onClientLogout:async()=>{e.dappProvider instanceof oi&&await s(e)},onClientEvent:P=>{console.log("wc2 session event: ",P)}},C=new oi(T,h[e.initOptions.chainType].shortId,I,this.walletConnectV2ProjectId,b,y,S);try{if(C){e.dappProvider=C,d.run("onQrPending"),await C.init();let{uri:P,approval:U}=await C.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),B=t?`${P}&token=${t}`:P;return this.qrCodeContainer&&B&&(M=await yy(this.qrCodeContainer,B,C,t),d.run("onQrLoaded")),await C.login({approval:U,token:t}),C}}catch(P){let U=Ho(P);console.warn(`Something went wrong trying to login the user: ${U}`),d.run("onLoginFailure",U)}};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=t,this.qrCodeContainer=i}};export{wy as MobileSigningProvider}; /*! Bundled license information: +tslib/tslib.es6.js: + (*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** *) + js-sha3/src/sha3.js: (** * [js-sha3]{@link https://github.com/emn178/js-sha3} @@ -41,7 +57,4 @@ js-sha3/src/sha3.js: * @copyright Chen, Yi-Cyuan 2015-2018 * @license MIT *) - -@noble/secp256k1/index.js: - (*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *) */ diff --git a/packages/mobile-signing-provider/esbuild.config.js b/packages/mobile-signing-provider/esbuild.config.js index 53f91d6..3eaa9c8 100644 --- a/packages/mobile-signing-provider/esbuild.config.js +++ b/packages/mobile-signing-provider/esbuild.config.js @@ -1,467 +1,11 @@ import { baseConfig } from '@configs/esbuild'; import * as esbuild from 'esbuild'; import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; esbuild .build({ ...baseConfig, entryPoints: ['./src/mobile-signing-provider.ts'], - // These are workarounds to avoid not needed code being bundled - // Always review when updating the walletconnect packages - plugins: [ - { - name: 'bn-resolver', - setup(build) { - build.onResolve({ filter: /^bn\.js$/ }, () => { - return { path: 'virtual:bn.js', namespace: 'bn-shim' }; - }); - build.onLoad( - { filter: /^virtual:bn\.js$/, namespace: 'bn-shim' }, - () => ({ - contents: ` - export class BN { - constructor(value) { - this.value = BigInt(value); - } - - toString(base = 10) { - return this.value.toString(base); - } - - toNumber() { - return Number(this.value); - } - } - export default BN; - `, - }) - ); - }, - }, - { - name: 'customize-walletconnect', - setup(build) { - // Replace elliptic with our adapter - build.onResolve({ filter: /^elliptic$/ }, () => ({ - path: 'virtual:secp256k1-adapter', - namespace: 'virtual', - })); - - build.onLoad( - { filter: /^virtual:secp256k1-adapter$/, namespace: 'virtual' }, - () => ({ - contents: ` - import * as secp from '@noble/secp256k1'; - - class EC { - constructor(curve) { - if (curve !== 'secp256k1') throw new Error('Only secp256k1 is supported'); - } - - keyFromPrivate(priv) { - const privBytes = typeof priv === 'string' ? - secp.utils.hexToBytes(priv.replace('0x', '')) : - priv; - - return { - getPublic: (compact = false) => { - const pubKey = secp.getPublicKey(privBytes); - return { - encode: (enc) => pubKey - }; - } - }; - } - - keyFromPublic(pub) { - const pubBytes = typeof pub === 'string' ? - secp.utils.hexToBytes(pub.replace('0x', '')) : - pub; - - return { - verify: async (msg, sig) => { - return secp.verify(sig, msg, pubBytes); - } - }; - } - } - - export const ec = EC; - export { EC }; - export default { EC }; - `, - loader: 'js', - resolveDir: path.dirname(fileURLToPath(import.meta.url)), - }) - ); - }, - }, - { - name: 'replace-lodash-isequal', - setup(build) { - build.onResolve({ filter: /^lodash\.isequal$/ }, () => ({ - path: 'virtual:isequal', - namespace: 'virtual', - })); - - build.onLoad( - { filter: /^virtual:isequal$/, namespace: 'virtual' }, - () => ({ - contents: ` - export default function isEqual(a, b) { - if (a === b) return true; - - if (a && b && typeof a === 'object' && typeof b === 'object') { - if (Array.isArray(a)) { - if (!Array.isArray(b) || a.length !== b.length) return false; - for (let i = 0; i < a.length; i++) { - if (!isEqual(a[i], b[i])) return false; - } - return true; - } - - const keys = Object.keys(a); - if (keys.length !== Object.keys(b).length) return false; - - for (const key of keys) { - if (!b.hasOwnProperty(key) || !isEqual(a[key], b[key])) return false; - } - return true; - } - - return false; - } - `, - loader: 'js', - }) - ); - }, - }, - { - name: 'replace-query-string', - setup(build) { - build.onResolve({ filter: /^query-string$/ }, () => ({ - path: 'virtual:query-string', - namespace: 'virtual', - })); - - build.onLoad( - { filter: /^virtual:query-string$/, namespace: 'virtual' }, - () => ({ - contents: ` - export function parse(str) { - const searchParams = new URLSearchParams(str); - const result = {}; - for (const [key, value] of searchParams.entries()) { - result[key] = value; - } - return result; - } - - export function stringify(obj) { - const searchParams = new URLSearchParams(); - for (const key in obj) { - if (obj[key] != null) { - searchParams.append(key, obj[key]); - } - } - return searchParams.toString(); - } - - export function parseUrl(url) { - const [base, query] = url.split('?'); - return { - url: base, - query: parse(query || '') - }; - } - - export default { - parse, - stringify, - parseUrl, - extract: url => url.split('?')[1] || '' - }; - `, - loader: 'js', - }) - ); - }, - }, - { - name: 'inline-tslib', - setup(build) { - build.onResolve({ filter: /^tslib$/ }, () => ({ - path: 'virtual:tslib', - namespace: 'virtual', - })); - - build.onLoad( - { filter: /^virtual:tslib$/, namespace: 'virtual' }, - () => ({ - contents: ` - export function __awaiter(thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function(resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); - } - - export function __exportStar(m, o) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); - } - - export function __createBinding(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); - } - - export function __values(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); - } - - export function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; - } - `, - loader: 'js', - }) - ); - }, - }, - { - name: 'replace-unstorage', - setup(build) { - build.onResolve({ filter: /^unstorage$/ }, () => ({ - path: 'virtual:unstorage', - namespace: 'virtual', - })); - - build.onLoad( - { filter: /^virtual:unstorage$/, namespace: 'virtual' }, - () => ({ - contents: ` - export function createStorage(options = {}) { - return { - async getItem(key) { - try { - return localStorage.getItem(key); - } catch (e) { - console.warn('Storage getItem error:', e); - return null; - } - }, - async setItem(key, value) { - try { - localStorage.setItem(key, value); - } catch (e) { - console.warn('Storage setItem error:', e); - } - }, - async removeItem(key) { - try { - localStorage.removeItem(key); - } catch (e) { - console.warn('Storage removeItem error:', e); - } - }, - async clear() { - try { - localStorage.clear(); - } catch (e) { - console.warn('Storage clear error:', e); - } - }, - async mount() {}, - async unmount() {} - }; - } - - export default { - createStorage - }; - `, - loader: 'js', - }) - ); - }, - }, - { - name: 'replace-signing-key', - setup(build) { - build.onResolve({ filter: /^@ethersproject\/signing-key/ }, () => ({ - path: 'virtual:signing-key', - namespace: 'virtual', - })); - - build.onLoad( - { filter: /^virtual:signing-key$/, namespace: 'virtual' }, - () => ({ - contents: ` - import { getPublicKey, sign, utils } from '@noble/secp256k1'; - import { hexlify, arrayify } from '@ethersproject/bytes'; - - export class SigningKey { - #privateKey; - #publicKey; - - constructor(privateKey) { - this.#privateKey = arrayify(privateKey); - this.#publicKey = getPublicKey(this.#privateKey, false); - } - - get publicKey() { - return hexlify(this.#publicKey); - } - - get privateKey() { - return hexlify(this.#privateKey); - } - - get compressedPublicKey() { - return hexlify(getPublicKey(this.#privateKey, true)); - } - - signDigest(digest) { - const [signature, recovery] = sign(arrayify(digest), this.#privateKey, { - recovered: true, - der: false, - }); - - const r = hexlify(signature.slice(0, 32)); - const s = hexlify(signature.slice(32, 64)); - - return { - r, - s, - v: recovery + 27, - _vs: null, - recoveryParam: recovery - }; - } - } - - export function computePublicKey(key, compressed = false) { - const publicKey = getPublicKey(arrayify(key), compressed); - return hexlify(publicKey); - } - - export function recoverPublicKey(digest, signature, recoveryParam) { - const sig = new Uint8Array(64); - sig.set(arrayify(signature.r), 0); - sig.set(arrayify(signature.s), 32); - - const publicKey = utils.recoverPublicKey( - arrayify(digest), - sig, - recoveryParam, - false - ); - - return hexlify(publicKey); - } - `, - loader: 'js', - resolveDir: process.cwd(), - }) - ); - }, - }, - { - name: 'replace-pino', - setup(build) { - // Match any pino import pattern - build.onResolve( - { - filter: /^pino($|\/.*$)|^\.\.\/\.\.\/node_modules\/pino(\/.*)?$/, - }, - () => ({ - path: 'virtual:pino-browser', - namespace: 'virtual', - }) - ); - - build.onLoad( - { filter: /^virtual:pino-browser$/, namespace: 'virtual' }, - () => ({ - contents: ` - // Simplified logger implementation - const noop = () => {}; - - const levels = { - values: { - trace: 10, - debug: 20, - info: 30, - warn: 40, - error: 50, - fatal: 60, - } - }; - - function createLogger() { - return { - trace: noop, - debug: noop, - info: console.log.bind(console), - warn: console.warn.bind(console), - error: console.error.bind(console), - fatal: console.error.bind(console), - child: function() { return this; } - }; - } - - function pino() { - return createLogger(); - } - - // Static properties - pino.destination = () => ({ write: noop }); - pino.transport = () => createLogger(); - pino.levels = levels; - - // Named exports - export { levels }; - export { pino }; - - // Default export - export default pino; - `, - loader: 'js', - }) - ); - }, - }, - ], }) .then((result) => { fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); diff --git a/packages/mobile-signing-provider/src/components/init-mobile-provider.ts b/packages/mobile-signing-provider/src/components/init-mobile-provider.ts deleted file mode 100644 index 7ec0d1d..0000000 --- a/packages/mobile-signing-provider/src/components/init-mobile-provider.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { - SessionEventTypes, - WalletConnectV2Provider, -} from './walletconnect-signing'; -import { getRandomAddressFromNetwork } from './utils'; - -export const initMobileProvider = async ( - elven: any, - logout: any, - networkConfig: any, - Message: any, - Transaction: any, - TransactionsConverter: any, - walletConnectV2ProjectId: string, - walletConnectV2RelayAddresses: string[] -) => { - if (!walletConnectV2ProjectId || !elven.initOptions.chainType) { - return undefined; - } - - const providerHandlers = { - onClientLogin: () => {}, - onClientLogout: () => logout(elven), - onClientEvent: (event: SessionEventTypes['event']) => { - console.log('wc2 session event: ', event); - }, - }; - - const relayAddress = getRandomAddressFromNetwork( - walletConnectV2RelayAddresses - ); - - const dappProviderInstance = new WalletConnectV2Provider( - providerHandlers, - networkConfig[elven.initOptions.chainType].shortId, - relayAddress, - walletConnectV2ProjectId, - Message, - Transaction, - TransactionsConverter - ); - - try { - await dappProviderInstance.init(); - return dappProviderInstance; - } catch { - console.warn("Can't initialize the Dapp Provider!"); - } -}; diff --git a/packages/mobile-signing-provider/src/components/login-with-mobile.ts b/packages/mobile-signing-provider/src/components/login-with-mobile.ts deleted file mode 100644 index 5bd8971..0000000 --- a/packages/mobile-signing-provider/src/components/login-with-mobile.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { errorParse, getRandomAddressFromNetwork } from './utils'; -import { qrCodeAndPairingsBuilder } from './qr-code-and-pairings-builder'; -import { - WalletConnectV2Provider, - SessionEventTypes, -} from './walletconnect-signing'; -import { - EventStoreEvents, - LoginMethodsEnum, - DappCoreWCV2CustomMethodsEnum, -} from './types'; - -// TODO: think how to handle types -export const loginWithMobile = async ( - elven: any, - loginToken: string, - nativeAuthClient: any, - ls: any, - logout: any, - getNewLoginExpiresTimestamp: any, - accountSync: any, - EventsStore: any, - networkConfig: any, - Message: any, - Transaction: any, - TransactionsConverter: any, - walletConnectV2ProjectId: string, - walletConnectV2RelayAddresses: string[], - qrCodeContainer: string | HTMLElement -) => { - if (!qrCodeContainer) { - throw new Error( - "You haven't provided the QR code container DOM element id" - ); - } - - const relayAddress = getRandomAddressFromNetwork( - walletConnectV2RelayAddresses - ); - - if (!relayAddress || !elven.networkProvider) { - throw new Error( - "Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!" - ); - } - - if (!walletConnectV2ProjectId) { - throw new Error( - 'Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)' - ); - } - - if (!elven.initOptions.chainType) { - throw new Error('Please provide the chain type in ElvenJS.init function!'); - } - - let qrCodeElement: HTMLElement | null; - - const providerHandlers = { - onClientLogin: async () => { - if (elven.dappProvider instanceof WalletConnectV2Provider) { - const address = await elven.dappProvider.getAddress(); - const signature = await elven.dappProvider.getSignature(); - - ls.set('address', address); - ls.set('loginMethod', LoginMethodsEnum.mobile); - ls.set('expires', getNewLoginExpiresTimestamp()); - - await accountSync(elven); - - if (signature) { - ls.set('signature', signature); - } - - ls.set('loginToken', loginToken); - - const accessToken = nativeAuthClient.getToken( - address, - loginToken, - signature - ); - ls.set('accessToken', accessToken); - - EventsStore.run(EventStoreEvents.onLoginSuccess); - qrCodeElement?.replaceChildren(); - } - }, - onClientLogout: async () => { - if (elven.dappProvider instanceof WalletConnectV2Provider) { - await logout(elven); - } - }, - onClientEvent: (event: SessionEventTypes['event']) => { - console.log('wc2 session event: ', event); - }, - }; - - const dappProvider = new WalletConnectV2Provider( - providerHandlers, - networkConfig[elven.initOptions.chainType].shortId, - relayAddress, - walletConnectV2ProjectId, - Message, - Transaction, - TransactionsConverter - ); - - try { - if (dappProvider) { - elven.dappProvider = dappProvider; - - EventsStore.run(EventStoreEvents.onQrPending); - - await dappProvider.init(); - - const { uri: walletConnectUri, approval } = await dappProvider.connect({ - methods: [ - DappCoreWCV2CustomMethodsEnum.mvx_cancelAction, - DappCoreWCV2CustomMethodsEnum.mvx_signNativeAuthToken, - ], - }); - - const wCUri = loginToken - ? `${walletConnectUri}&token=${loginToken}` - : walletConnectUri; - - if (qrCodeContainer && wCUri) { - qrCodeElement = await qrCodeAndPairingsBuilder( - qrCodeContainer, - wCUri, - dappProvider, - loginToken - ); - - EventsStore.run(EventStoreEvents.onQrLoaded); - } - - await dappProvider.login({ - approval, - token: loginToken, - }); - - return dappProvider; - } - } catch (e) { - const err = errorParse(e); - console.warn(`Something went wrong trying to login the user: ${err}`); - EventsStore.run(EventStoreEvents.onLoginFailure, err); - } -}; diff --git a/packages/mobile-signing-provider/src/components/types.ts b/packages/mobile-signing-provider/src/components/types.ts index a152f38..a57e5e6 100644 --- a/packages/mobile-signing-provider/src/components/types.ts +++ b/packages/mobile-signing-provider/src/components/types.ts @@ -65,3 +65,25 @@ export enum WalletConnectV2ProviderErrorMessagesEnum { connectionError = 'WalletConnect could not establish a connection', invalidGuardian = 'WalletConnect: Invalid Guardian', } + +export interface Context { + networkProvider?: unknown; + initOptions: { chainType: string }; + dappProvider?: unknown; +} + +export interface NativeAuthClient { + getToken(address: string, loginToken: string, signature: string): string; +} + +export interface LocalStorage { + set(key: string, value: unknown): void; +} + +export interface EventsStore { + run(event: string, ...args: unknown[]): void; +} + +export interface NetworkConfig { + [key: string]: { shortId: string }; +} diff --git a/packages/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/mobile-signing-provider/src/mobile-signing-provider.ts index c024c7c..0a2b589 100644 --- a/packages/mobile-signing-provider/src/mobile-signing-provider.ts +++ b/packages/mobile-signing-provider/src/mobile-signing-provider.ts @@ -1,4 +1,20 @@ -import { WalletConnectV2Provider } from './components/walletconnect-signing'; +import { + SessionEventTypes, + WalletConnectV2Provider, +} from './components/walletconnect-signing'; +import { + Context, + NetworkConfig, + NativeAuthClient, + LocalStorage, + EventsStore, + EventStoreEvents, + DappCoreWCV2CustomMethodsEnum, + LoginMethodsEnum, +} from './components/types'; + +import { errorParse, getRandomAddressFromNetwork } from './components/utils'; +import { qrCodeAndPairingsBuilder } from './components/qr-code-and-pairings-builder'; export class MobileSigningProvider { private walletConnectV2ProjectId: string; @@ -19,62 +35,184 @@ export class MobileSigningProvider { this.walletConnectV2RelayAddresses = walletConnectV2RelayAddresses; this.qrCodeContainer = qrCodeContainer; } - // TODO: think how to handle types + initMobileProvider = async ( - context: any, - logout: any, - networkConfig: any, - Message: any, - Transaction: any, - TransactionsConverter: any + context: Context, + logout: (context: Context) => Promise, + networkConfig: NetworkConfig, + Message: new (...args: any[]) => unknown, + Transaction: new (...args: any[]) => unknown, + TransactionsConverter: new (...args: any[]) => unknown ) => { - const { initMobileProvider } = await import( - './components/init-mobile-provider' + if (!this.walletConnectV2ProjectId || !context.initOptions.chainType) { + return undefined; + } + + const providerHandlers = { + onClientLogin: () => {}, + onClientLogout: () => logout(context), + onClientEvent: (event: SessionEventTypes['event']) => { + console.log('wc2 session event: ', event); + }, + }; + + const relayAddress = getRandomAddressFromNetwork( + this.walletConnectV2RelayAddresses ); - return initMobileProvider( - context, - logout, - networkConfig, + + const dappProviderInstance = new WalletConnectV2Provider( + providerHandlers, + networkConfig[context.initOptions.chainType].shortId, + relayAddress, + this.walletConnectV2ProjectId, Message, Transaction, - TransactionsConverter, - this.walletConnectV2ProjectId, - this.walletConnectV2RelayAddresses + TransactionsConverter ); + + try { + await dappProviderInstance.init(); + return dappProviderInstance; + } catch { + console.warn("Can't initialize the Dapp Provider!"); + return undefined; + } }; - // TODO: think how to handle types loginWithMobile = async ( - context: any, + context: Context, loginToken: string, - nativeAuthClient: any, - ls: any, - logout: any, - getNewLoginExpiresTimestamp: any, - accountSync: any, - EventsStore: any, - networkConfig: any, - Message: any, - Transaction: any, - TransactionsConverter: any + nativeAuthClient: NativeAuthClient, + ls: LocalStorage, + logout: (context: Context) => Promise, + getNewLoginExpiresTimestamp: () => number, + accountSync: (context: Context) => Promise, + EventsStore: EventsStore, + networkConfig: NetworkConfig, + Message: new (...args: any[]) => unknown, + Transaction: new (...args: any[]) => unknown, + TransactionsConverter: new (...args: any[]) => unknown ) => { - const { loginWithMobile } = await import('./components/login-with-mobile'); - return loginWithMobile( - context, - loginToken, - nativeAuthClient, - ls, - logout, - getNewLoginExpiresTimestamp, - accountSync, - EventsStore, - networkConfig, + if (!this.qrCodeContainer) { + throw new Error( + "You haven't provided the QR code container DOM element id" + ); + } + + const relayAddress = getRandomAddressFromNetwork( + this.walletConnectV2RelayAddresses + ); + + if (!relayAddress || !context.networkProvider) { + throw new Error( + "Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!" + ); + } + + if (!this.walletConnectV2ProjectId) { + throw new Error( + 'Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)' + ); + } + + if (!context.initOptions.chainType) { + throw new Error( + 'Please provide the chain type in ElvenJS.init function!' + ); + } + + let qrCodeElement: HTMLElement | null; + + const providerHandlers = { + onClientLogin: async () => { + if (context.dappProvider instanceof WalletConnectV2Provider) { + const address = context.dappProvider.getAddress(); + const signature = context.dappProvider.getSignature(); + + ls.set('address', address); + ls.set('loginMethod', LoginMethodsEnum.mobile); + ls.set('expires', getNewLoginExpiresTimestamp()); + + await accountSync(context); + + if (signature) { + ls.set('signature', signature); + ls.set('loginToken', loginToken); + + const accessToken = nativeAuthClient.getToken( + address, + loginToken, + signature + ); + + ls.set('accessToken', accessToken); + + EventsStore.run(EventStoreEvents.onLoginSuccess); + qrCodeElement?.replaceChildren(); + } + } + }, + onClientLogout: async () => { + if (context.dappProvider instanceof WalletConnectV2Provider) { + await logout(context); + } + }, + onClientEvent: (event: SessionEventTypes['event']) => { + console.log('wc2 session event: ', event); + }, + }; + + const dappProvider = new WalletConnectV2Provider( + providerHandlers, + networkConfig[context.initOptions.chainType].shortId, + relayAddress, + this.walletConnectV2ProjectId, Message, Transaction, - TransactionsConverter, - this.walletConnectV2ProjectId, - this.walletConnectV2RelayAddresses, - this.qrCodeContainer + TransactionsConverter ); + + try { + if (dappProvider) { + context.dappProvider = dappProvider; + + EventsStore.run(EventStoreEvents.onQrPending); + + await dappProvider.init(); + + const { uri: walletConnectUri, approval } = await dappProvider.connect({ + methods: [ + DappCoreWCV2CustomMethodsEnum.mvx_cancelAction, + DappCoreWCV2CustomMethodsEnum.mvx_signNativeAuthToken, + ], + }); + + const wCUri = loginToken + ? `${walletConnectUri}&token=${loginToken}` + : walletConnectUri; + + if (this.qrCodeContainer && wCUri) { + qrCodeElement = await qrCodeAndPairingsBuilder( + this.qrCodeContainer, + wCUri, + dappProvider, + loginToken + ); + + EventsStore.run(EventStoreEvents.onQrLoaded); + } + + await dappProvider.login({ + approval, + token: loginToken, + }); + + return dappProvider; + } + } catch (e) { + const err = errorParse(e); + console.warn(`Something went wrong trying to login the user: ${err}`); + EventsStore.run(EventStoreEvents.onLoginFailure, err); + } }; } From 032f14f653bc852bfbd2c8f493fd907d407c2e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Wed, 6 Nov 2024 00:06:35 +0100 Subject: [PATCH 11/13] some refactor --- TODO.md | 2 +- demo-app/elven.js | 2 +- demo-app/mobile-signing-provider.js | 16 +- package-lock.json | 202 +++++++++--------- packages/elven.js/package.json | 3 - packages/elven.js/src/main.ts | 54 ++--- packages/elven.js/src/types.ts | 39 ++-- packages/elven.js/src/utils/ls-helpers.ts | 8 +- packages/mobile-signing-provider/package.json | 8 +- .../src/mobile-signing-provider.ts | 112 +++++----- 10 files changed, 236 insertions(+), 210 deletions(-) diff --git a/TODO.md b/TODO.md index 3b8399a..63f465c 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,3 @@ -- anyway check what can be done with wallet connect to make it as small as possible - check and handle all the errors for the mobile provider when the provider is not initialized etc. - add tests for at least most used utilities, maybe some core tools, check tests in MVX SDKs (more tests can be added later) - prepare a new API @@ -11,3 +10,4 @@ - update README and docs and demos - how it is built now - what it can't do + - why the mobile provider is so big and what can be done to make it smaller, plus why it isn't so bad because it is a separate file diff --git a/demo-app/elven.js b/demo-app/elven.js index 964b5e4..d0cc598 100644 --- a/demo-app/elven.js +++ b/demo-app/elven.js @@ -6,6 +6,6 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ie=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),A=n=>et.encode(n),R=n=>tt.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),j=n=>b(A(n)),k=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},nt=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Ae=a&63;e+=C.charAt(l),e+=C.charAt(u),e+=r+1R(k(n)),I=n=>{let e=typeof n=="string"?A(n):n;return nt(e)};function rt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function it(n,e,t){let r=n;for(let o=0;o{he([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&he([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function me(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=rt(r);it(t,i,o)}return t}function Le(n){let e=[];return he([],n,e),e.join("&")}var ot=()=>typeof window<"u"&&typeof window.location<"u",$=()=>{if(ot()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},fe=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var P=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Ee(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:b(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return b(this.address)}};var ke=1e9,Ue=0,K=2,Oe=2,Te=64,Ce=1;var Me="sdk-js";var We="hook/login",_e="hook/logout";var De="hook/sign",Fe="hook/2fa",Ge="hook/sign-message",B="walletProviderStatus",V="transactionsSigned";var He={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var E=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||ke),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||K),this.options=Number(e.options?.valueOf()||Ue),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var J=class extends v{constructor(){super("Async timer already running")}},X=class extends v{constructor(){super("Async timer aborted")}};var M=class extends v{constructor(){super("Expected transaction status not reached")}},q=class extends v{constructor(){super("Expected transaction events not found")}};var Y=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var Z=class extends v{constructor(){super("Cannot sign single transaction.")}},ee=class extends v{constructor(){super("Account is not connected.")}},z=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},te=class extends Error{constructor(){super("Cannot get signed message")}};var W=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new J;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new X),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var we=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Q=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new we(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new Y;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==Te)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${Te}.`);return t}async awaitConditionally(e,t,r){let o=new W("watcher:periodic"),i=new W("watcher:patience"),s=new W("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var w=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ce,this.signer=e.signer||Me}};var p=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?I(e.senderUsername):void 0,receiverUsername:e.receiverUsername?I(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?I(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?b(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?b(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new E({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:H(e.receiverUsername||""),sender:e.sender,senderUsername:H(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?k(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var U=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new Z;return t[0]}ensureConnected(){if(!this.account.address)throw new ee}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>p.transactionToPlainObject(r))});try{return t.map(o=>p.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:R(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new w({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var ne="elvenjs_state",$e="https://devnet-api.multiversx.com";var L="/dapp/init",re="devnet";var f={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(ne);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(ne,JSON.stringify(t))},clear(){localStorage.removeItem(ne)}};var ie=async()=>{let n=U.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var ye=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},y=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:We,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:_e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Ge,callbackUrl:t?.callbackUrl,params:{message:R(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=me(e);if((t.status?.toString()||"")!=="signed")throw new te;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Fe,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(De,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=me(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,B)&&e[B]===V}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new z;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new z;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var be=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},_=class{constructor(e){this.config=Object.assign(new be,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(s=>s.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(j(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var oe=(n,e)=>t=>{let r=t.data;try{r=fe()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!fe()&&t.origin!=$()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",oe(n,e)),e({type:o,payload:i}))};var N=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",oe("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>p.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>p.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:R(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new w({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),$()):t.parent&&t.parent.postMessage(e,$())),await this.waitingForResponse(He[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",oe(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var T=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var ve=async(n,e)=>{let t=T("signature"),r=T("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new y(`${n}${L}`);if(t&&e&&r){let l=new _({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var se=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var ae=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||re,this.apiUrl=e||f[this.chainType]?.apiAddress,this.apiTimeout=r||f[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=p.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new se(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:k(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>j(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var S=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(S||{}),O=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(O||{}),at=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(at||{}),xe=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(xe||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var h=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var ce=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=h(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var D=()=>new Date().setHours(new Date().getHours()+24),de=n=>Date.now()>n;var F=async n=>{let e=d.get("address"),t=d.get("expires");if(!(t&&de(t))&&e&&n.networkProvider){let o=new P(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=h(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Be=async(n,e,t,r="/")=>{let o=await ie(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=h(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",D()),await F(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var Se=async(n,e,t,r)=>{let o=new y(`${n}${L}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",f[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",D()),d.set("loginToken",e),o}catch(a){let l=h(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var le=async(n,e)=>{c.run("onTxSent",n);let r=await new Q(e).awaitCompleted(n.txHash),o=r.sender,i=new P(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var ue=n=>{let e=n.sender,t=new P(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var qe=async(n,e,t,r)=>{if(T(B)===V&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=T("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=I(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new y(`${t}${L}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=p.plainObjectToTransaction(l);u.nonce=BigInt(r),ue(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await le(m,e)}catch(m){let Re=`Getting transaction information failed! ${h(m)}`;throw c.run("onTxFailure",u,Re),new Error(Re)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var ze=n=>{let e=d.get("activeGuardian");return e&&(n.version=K,n.options=Oe,n.guardian=e),n},Qe=async(n,e)=>{let t=new y(`${e}${L}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},je=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ke=()=>{let n=!T("walletProviderStatus"),e=T("status")==="signed",t=T("message"),r=T("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ct(n){try{let e=atob(n),t=btoa(e),r=H(n),o=I(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function G(n){return ct(n)?atob(n):n}var ge=n=>Object.prototype.toString.call(n)==="[object String]";var Ve=n=>{if(!n||!ge(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(G(i)),a=G(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Je=n=>{if(!n||!ge(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=G(t),s=G(r),a=Ve(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function Xe(n,e){let t=Je(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new N)}var Ye=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&c.set("onQrPending",e.onQrPending),e?.onQrLoaded&&c.set("onQrLoaded",e.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var pe=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=h(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var Pe=class{static async init(e){let t=d.get();if(t.expires&&de(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:re,apiUrl:$e,apiTimeout:1e4,...e},this.networkProvider=new ae(this.initOptions),this.mobileProvider=this.initOptions?.externalSigningProviders?.mobile?.provider?new this.initOptions.externalSigningProviders.mobile.provider(this.initOptions.externalSigningProviders.mobile.config):void 0,Ye(this.initOptions);let r=T("accessToken");r&&await pe(async i=>{Xe(r,this),await F(this),i()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&T("address"))&&t?.loginMethod&&(await pe(async i=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await ie()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this,ce,f,w,E,p)),t.loginMethod==="webview"&&(this.dappProvider=new N),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await ve(f[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await ve(f[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await F(this),i()}),this.initOptions?.chainType&&(await qe(this.dappProvider,this.networkProvider,f[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Ke()))}static async login(e,t){if(!Object.values(O).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await pe(async()=>{let o=new _({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize();if(e==="browser-extension"){let s=await Be(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o,d,ce,D,F,c,f,w,E,p);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await Se(f[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await Se(f[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await ce(this);return this.dappProvider=void 0,e}catch(e){let t=h(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=ze(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof N&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof y&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=je(t);if(o||ue(t),o&&this.initOptions?.chainType){await Qe(t,f[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await le(i,this.networkProvider)}}catch(r){let o=h(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new w({data:A(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new w({data:A(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof N){let i=await this.dappProvider.signMessage(new w({data:A(e)}));typeof i!="string"&&i?.signature&&(r=b(i.signature))}if(this.dappProvider instanceof y){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new w({data:A(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=h(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=h(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}static{this.storage=d}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,c.clear()}}};var dt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},Ze=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),Ze({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{P as Account,at as DappCoreWCV2CustomMethodsEnum,Pe as ElvenJS,S as EventStoreEvents,O as LoginMethodsEnum,E as Transaction,Q as TransactionWatcher,xe as WebWalletUrlParamsEnum,Ze as formatAmount,dt as parseAmount}; +var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ie=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),A=n=>et.encode(n),R=n=>tt.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),j=n=>y(A(n)),N=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},nt=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Ae=a&63;e+=C.charAt(l),e+=C.charAt(u),e+=r+1R(N(n)),I=n=>{let e=typeof n=="string"?A(n):n;return nt(e)};function rt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function it(n,e,t){let r=n;for(let o=0;o{pe([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&pe([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function he(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=rt(r);it(t,i,o)}return t}function Le(n){let e=[];return pe([],n,e),e.join("&")}var ot=()=>typeof window<"u"&&typeof window.location<"u",$=()=>{if(ot()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},me=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var P=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Ee(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:y(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return y(this.address)}};var ke=1e9,Ue=0,K=2,Oe=2,fe=64,Ce=1;var Me="sdk-js";var We="hook/login",_e="hook/logout";var De="hook/sign",Fe="hook/2fa",Ge="hook/sign-message",B="walletProviderStatus",V="transactionsSigned";var He={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var k=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||ke),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||K),this.options=Number(e.options?.valueOf()||Ue),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var J=class extends v{constructor(){super("Async timer already running")}},X=class extends v{constructor(){super("Async timer aborted")}};var M=class extends v{constructor(){super("Expected transaction status not reached")}},q=class extends v{constructor(){super("Expected transaction events not found")}};var Y=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var Z=class extends v{constructor(){super("Cannot sign single transaction.")}},ee=class extends v{constructor(){super("Account is not connected.")}},z=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},te=class extends Error{constructor(){super("Cannot get signed message")}};var W=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new J;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new X),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var Te=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Q=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new Te(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new Y;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==fe)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${fe}.`);return t}async awaitConditionally(e,t,r){let o=new W("watcher:periodic"),i=new W("watcher:patience"),s=new W("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var b=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ce,this.signer=e.signer||Me}};var h=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?I(e.senderUsername):void 0,receiverUsername:e.receiverUsername?I(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?I(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?y(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?y(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new k({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:H(e.receiverUsername||""),sender:e.sender,senderUsername:H(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?N(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var U=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new Z;return t[0]}ensureConnected(){if(!this.account.address)throw new ee}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>h.transactionToPlainObject(r))});try{return t.map(o=>h.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:R(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new b({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var ne="elvenjs_state",$e="https://devnet-api.multiversx.com";var E="/dapp/init",re="devnet";var T={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(ne);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(ne,JSON.stringify(t))},clear(){localStorage.removeItem(ne)}};var ie=async()=>{let n=U.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var we=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},w=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:We,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:_e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Ge,callbackUrl:t?.callbackUrl,params:{message:R(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=he(e);if((t.status?.toString()||"")!=="signed")throw new te;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Fe,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(De,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=he(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,B)&&e[B]===V}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new z;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new z;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var ye=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},_=class{constructor(e){this.config=Object.assign(new ye,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(s=>s.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(j(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var oe=(n,e)=>t=>{let r=t.data;try{r=me()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!me()&&t.origin!=$()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",oe(n,e)),e({type:o,payload:i}))};var L=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",oe("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>h.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>h.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:R(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new b({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),$()):t.parent&&t.parent.postMessage(e,$())),await this.waitingForResponse(He[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",oe(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var f=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var be=async(n,e)=>{let t=f("signature"),r=f("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new w(`${n}${E}`);if(t&&e&&r){let l=new _({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var se=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var ae=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||re,this.apiUrl=e||T[this.chainType]?.apiAddress,this.apiTimeout=r||T[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=h.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new se(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:N(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>j(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var S=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(S||{}),O=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(O||{}),at=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(at||{}),ve=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(ve||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var p=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var xe=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=p(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var D=()=>new Date().setHours(new Date().getHours()+24),ce=n=>Date.now()>n;var F=async n=>{let e=d.get("address"),t=d.get("expires");if(!(t&&ce(t))&&e&&n.networkProvider){let o=new P(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=p(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Be=async(n,e,t,r="/")=>{let o=await ie(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=p(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",D()),await F(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var Se=async(n,e,t,r)=>{let o=new w(`${n}${E}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",T[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",D()),d.set("loginToken",e),o}catch(a){let l=p(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var de=async(n,e)=>{c.run("onTxSent",n);let r=await new Q(e).awaitCompleted(n.txHash),o=r.sender,i=new P(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var le=n=>{let e=n.sender,t=new P(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var qe=async(n,e,t,r)=>{if(f(B)===V&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=f("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=I(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new w(`${t}${E}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=h.plainObjectToTransaction(l);u.nonce=BigInt(r),le(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await de(m,e)}catch(m){let Re=`Getting transaction information failed! ${p(m)}`;throw c.run("onTxFailure",u,Re),new Error(Re)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var ze=n=>{let e=d.get("activeGuardian");return e&&(n.version=K,n.options=Oe,n.guardian=e),n},Qe=async(n,e)=>{let t=new w(`${e}${E}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},je=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ke=()=>{let n=!f("walletProviderStatus"),e=f("status")==="signed",t=f("message"),r=f("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ct(n){try{let e=atob(n),t=btoa(e),r=H(n),o=I(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function G(n){return ct(n)?atob(n):n}var ue=n=>Object.prototype.toString.call(n)==="[object String]";var Ve=n=>{if(!n||!ue(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(G(i)),a=G(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Je=n=>{if(!n||!ue(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=G(t),s=G(r),a=Ve(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function Xe(n,e){let t=Je(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new L)}var Ye=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&c.set("onQrPending",e.onQrPending),e?.onQrLoaded&&c.set("onQrLoaded",e.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var ge=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=p(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var Pe=class{static async init(e){let t=d.get();if(t.expires&&ce(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:re,apiUrl:$e,apiTimeout:1e4,...e},this.networkProvider=new ae(this.initOptions),Ye(this.initOptions);let r=this.initOptions?.externalSigningProviders?.mobile?.provider;if(r){let s={networkConfig:T,Message:b,Transaction:k,TransactionsConverter:h,ls:d,logout:xe,getNewLoginExpiresTimestamp:D,accountSync:F,EventsStore:c},a=this.initOptions?.externalSigningProviders?.mobile?.config;if(a)this.mobileProvider=new r(a,s);else throw new Error("Mobile provider config is required!")}let o=f("accessToken");o&&await ge(async s=>{Xe(o,this),await F(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&f("address"))&&t?.loginMethod&&(await ge(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await ie()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this)),t.loginMethod==="webview"&&(this.dappProvider=new L),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await be(T[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await be(T[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await F(this),s()}),this.initOptions?.chainType&&(await qe(this.dappProvider,this.networkProvider,T[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Ke()))}static async login(e,t){if(!Object.values(O).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await ge(async()=>{let o=new _({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize();if(e==="browser-extension"){let s=await Be(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await Se(T[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await Se(T[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await xe(this);return this.dappProvider=void 0,e}catch(e){let t=p(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=ze(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof L&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof w&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=je(t);if(o||le(t),o&&this.initOptions?.chainType){await Qe(t,T[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await de(i,this.networkProvider)}}catch(r){let o=p(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new b({data:A(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new b({data:A(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof L){let i=await this.dappProvider.signMessage(new b({data:A(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof w){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new b({data:A(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=p(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=p(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}static{this.storage=d}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,c.clear()}}};var dt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},Ze=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),Ze({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{P as Account,at as DappCoreWCV2CustomMethodsEnum,Pe as ElvenJS,S as EventStoreEvents,O as LoginMethodsEnum,k as Transaction,Q as TransactionWatcher,ve as WebWalletUrlParamsEnum,Ze as formatAmount,dt as parseAmount}; /** keccak.js https://github.com/adraffy/keccak.js @license MIT */ /** https://github.com/emn178/js-sha3/blob/master/src/sha3.js @license MIT */ diff --git a/demo-app/mobile-signing-provider.js b/demo-app/mobile-signing-provider.js index 1a1557a..83de21e 100644 --- a/demo-app/mobile-signing-provider.js +++ b/demo-app/mobile-signing-provider.js @@ -6,7 +6,7 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var _y=Object.create;var Jo=Object.defineProperty;var xy=Object.getOwnPropertyDescriptor;var Ey=Object.getOwnPropertyNames;var Sy=Object.getPrototypeOf,Iy=Object.prototype.hasOwnProperty;var al=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var My=(r,e)=>()=>(r&&(e=r(r=0)),e);var Z=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Dt=(r,e)=>{for(var t in e)Jo(r,t,{get:e[t],enumerable:!0})},Wo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ey(e))!Iy.call(r,n)&&n!==t&&Jo(r,n,{get:()=>e[n],enumerable:!(i=xy(e,n))||i.enumerable});return r},qt=(r,e,t)=>(Wo(r,e,"default"),t&&Wo(t,e,"default")),qe=(r,e,t)=>(t=r!=null?_y(Sy(r)):{},Wo(e||!r||!r.__esModule?Jo(t,"default",{value:r,enumerable:!0}):t,r)),qs=r=>Wo(Jo({},"__esModule",{value:!0}),r);var hn=Z((BS,uc)=>{"use strict";var qn=typeof Reflect=="object"?Reflect:null,fl=qn&&typeof qn.apply=="function"?qn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Yo;qn&&typeof qn.ownKeys=="function"?Yo=qn.ownKeys:Object.getOwnPropertySymbols?Yo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yo=function(e){return Object.getOwnPropertyNames(e)};function Ay(r){console&&console.warn&&console.warn(r)}var hl=Number.isNaN||function(e){return e!==e};function Ke(){Ke.init.call(this)}uc.exports=Ke;uc.exports.once=Py;Ke.EventEmitter=Ke;Ke.prototype._events=void 0;Ke.prototype._eventsCount=0;Ke.prototype._maxListeners=void 0;var cl=10;function Xo(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ke,"defaultMaxListeners",{enumerable:!0,get:function(){return cl},set:function(r){if(typeof r!="number"||r<0||hl(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");cl=r}});Ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ke.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||hl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ul(r){return r._maxListeners===void 0?Ke.defaultMaxListeners:r._maxListeners}Ke.prototype.getMaxListeners=function(){return ul(this)};Ke.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var d=s[e];if(d===void 0)return!1;if(typeof d=="function")fl(d,this,t);else for(var h=d.length,b=bl(d,h),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,Ay(f)}return r}Ke.prototype.addListener=function(e,t){return dl(this,e,t,!1)};Ke.prototype.on=Ke.prototype.addListener;Ke.prototype.prependListener=function(e,t){return dl(this,e,t,!0)};function Ry(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ll(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=Ry.bind(i);return n.listener=t,i.wrapFn=n,n}Ke.prototype.once=function(e,t){return Xo(t),this.on(e,ll(this,e,t)),this};Ke.prototype.prependOnceListener=function(e,t){return Xo(t),this.prependListener(e,ll(this,e,t)),this};Ke.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Xo(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Ty(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ke.prototype.off=Ke.prototype.removeListener;Ke.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function pl(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?Dy(n):bl(n,n.length)}Ke.prototype.listeners=function(e){return pl(this,e,!0)};Ke.prototype.rawListeners=function(e){return pl(this,e,!1)};Ke.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):gl.call(r,e)};Ke.prototype.listenerCount=gl;function gl(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ke.prototype.eventNames=function(){return this._eventsCount>0?Yo(this._events):[]};function bl(r,e){for(var t=new Array(e),i=0;ilc,__asyncDelegator:()=>$y,__asyncGenerator:()=>Vy,__asyncValues:()=>Hy,__await:()=>Us,__awaiter:()=>Uy,__classPrivateFieldGet:()=>Yy,__classPrivateFieldSet:()=>Xy,__createBinding:()=>By,__decorate:()=>Ly,__exportStar:()=>ky,__extends:()=>Cy,__generator:()=>zy,__importDefault:()=>Jy,__importStar:()=>Wy,__makeTemplateObject:()=>Gy,__metadata:()=>qy,__param:()=>Fy,__read:()=>ml,__rest:()=>Oy,__spread:()=>Ky,__spreadArrays:()=>jy,__values:()=>pc});function Cy(r,e){dc(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Fy(r,e){return function(t,i){e(t,i,r)}}function qy(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Uy(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{h(i.next(b))}catch(y){o(y)}}function d(b){try{h(i.throw(b))}catch(y){o(y)}}function h(b){b.done?s(b.value):n(b.value).then(f,d)}h((i=i.apply(r,e||[])).next())})}function zy(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(h){return function(b){return d([h,b])}}function d(h){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=h[0]&2?n.return:h[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,h[1])).done)return s;switch(n=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return t.label++,{value:h[1],done:!1};case 5:t.label++,n=h[1],h=[0];continue;case 7:h=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){t=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ml(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Ky(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{d(i[S](I))}catch(M){y(s[0][3],M)}}function d(S){S.value instanceof Us?Promise.resolve(S.value.v).then(h,b):y(s[0][2],S)}function h(S){f("next",S)}function b(S){f("throw",S)}function y(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function $y(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Us(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function Hy(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof pc=="function"?pc(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,d){o=r[s](o),n(f,d,o.done,o.value)})}}function n(s,o,f,d){Promise.resolve(d).then(function(h){s({value:h,done:f})},o)}}function Gy(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wy(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function Jy(r){return r&&r.__esModule?r:{default:r}}function Yy(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Xy(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var dc,lc,zn=My(()=>{dc=function(r,e){return dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},dc(r,e)};lc=function(){return lc=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.delay=void 0;function Zy(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Zo.delay=Zy});var wl=Z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.ONE_THOUSAND=Bn.ONE_HUNDRED=void 0;Bn.ONE_HUNDRED=100;Bn.ONE_THOUSAND=1e3});var _l=Z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.ONE_YEAR=Q.FOUR_WEEKS=Q.THREE_WEEKS=Q.TWO_WEEKS=Q.ONE_WEEK=Q.THIRTY_DAYS=Q.SEVEN_DAYS=Q.FIVE_DAYS=Q.THREE_DAYS=Q.ONE_DAY=Q.TWENTY_FOUR_HOURS=Q.TWELVE_HOURS=Q.SIX_HOURS=Q.THREE_HOURS=Q.ONE_HOUR=Q.SIXTY_MINUTES=Q.THIRTY_MINUTES=Q.TEN_MINUTES=Q.FIVE_MINUTES=Q.ONE_MINUTE=Q.SIXTY_SECONDS=Q.THIRTY_SECONDS=Q.TEN_SECONDS=Q.FIVE_SECONDS=Q.ONE_SECOND=void 0;Q.ONE_SECOND=1;Q.FIVE_SECONDS=5;Q.TEN_SECONDS=10;Q.THIRTY_SECONDS=30;Q.SIXTY_SECONDS=60;Q.ONE_MINUTE=Q.SIXTY_SECONDS;Q.FIVE_MINUTES=Q.ONE_MINUTE*5;Q.TEN_MINUTES=Q.ONE_MINUTE*10;Q.THIRTY_MINUTES=Q.ONE_MINUTE*30;Q.SIXTY_MINUTES=Q.ONE_MINUTE*60;Q.ONE_HOUR=Q.SIXTY_MINUTES;Q.THREE_HOURS=Q.ONE_HOUR*3;Q.SIX_HOURS=Q.ONE_HOUR*6;Q.TWELVE_HOURS=Q.ONE_HOUR*12;Q.TWENTY_FOUR_HOURS=Q.ONE_HOUR*24;Q.ONE_DAY=Q.TWENTY_FOUR_HOURS;Q.THREE_DAYS=Q.ONE_DAY*3;Q.FIVE_DAYS=Q.ONE_DAY*5;Q.SEVEN_DAYS=Q.ONE_DAY*7;Q.THIRTY_DAYS=Q.ONE_DAY*30;Q.ONE_WEEK=Q.SEVEN_DAYS;Q.TWO_WEEKS=Q.ONE_WEEK*2;Q.THREE_WEEKS=Q.ONE_WEEK*3;Q.FOUR_WEEKS=Q.ONE_WEEK*4;Q.ONE_YEAR=Q.ONE_DAY*365});var gc=Z(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});var xl=(zn(),qs(Un));xl.__exportStar(wl(),Qo);xl.__exportStar(_l(),Qo)});var Sl=Z(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.fromMiliseconds=kn.toMiliseconds=void 0;var El=gc();function Qy(r){return r*El.ONE_THOUSAND}kn.toMiliseconds=Qy;function e2(r){return Math.floor(r/El.ONE_THOUSAND)}kn.fromMiliseconds=e2});var Ml=Z(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var Il=(zn(),qs(Un));Il.__exportStar(yl(),ea);Il.__exportStar(Sl(),ea)});var Al=Z(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.Watch=void 0;var ta=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};zs.Watch=ta;zs.default=ta});var Rl=Z(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.IWatch=void 0;var bc=class{};ra.IWatch=bc});var Tl=Z(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var t2=(zn(),qs(Un));t2.__exportStar(Rl(),vc)});var jn=Z(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var ia=(zn(),qs(Un));ia.__exportStar(Ml(),Kn);ia.__exportStar(Al(),Kn);ia.__exportStar(Tl(),Kn);ia.__exportStar(gc(),Kn)});var $l=Z((lI,Vl)=>{"use strict";function E2(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}Vl.exports=S2;function S2(r,e,t){var i=t&&t.stringify||E2,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=d||e[b]==null)break;y=d||e[b]==null)break;y=d||e[b]===void 0)break;y",y=I+2,I++;break}h+=i(e[b]),y=I+2,I++;break;case 115:if(b>=d)break;y{"use strict";var Hl=$l();Jl.exports=qr;var Vs=O2().console||{},I2={mapHttpRequest:fa,mapHttpResponse:fa,wrapRequestSerializer:Mc,wrapResponseSerializer:Mc,wrapErrorSerializer:Mc,req:fa,res:fa,err:D2};function M2(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function qr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||Vs;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=M2(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",d=Object.create(t);d.log||(d.log=$s),Object.defineProperty(d,"levelVal",{get:b}),Object.defineProperty(d,"level",{get:y,set:S});let h={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:P2(r)};d.levels=qr.levels,d.level=f,d.setMaxListeners=d.getMaxListeners=d.emit=d.addListener=d.on=d.prependListener=d.once=d.prependOnceListener=d.removeListener=d.removeAllListeners=d.listeners=d.listenerCount=d.eventNames=d.write=d.flush=$s,d.serializers=i,d._serialize=n,d._stdErrSerialize=s,d.child=I,e&&(d._logEvent=Ac());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,Vn(h,d,"error","log"),Vn(h,d,"fatal","error"),Vn(h,d,"warn","error"),Vn(h,d,"info","log"),Vn(h,d,"debug","log"),Vn(h,d,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let C=T.serializers;if(n&&C){var P=Object.assign({},i,C),U=r.browser.serialize===!0?Object.keys(P):n;delete M.serializers,ca([M],U,P,this._stdErrSerialize)}function B(z){this._childLevel=(z._childLevel|0)+1,this.error=$n(z,M,"error"),this.fatal=$n(z,M,"fatal"),this.warn=$n(z,M,"warn"),this.info=$n(z,M,"info"),this.debug=$n(z,M,"debug"),this.trace=$n(z,M,"trace"),P&&(this.serializers=P,this._serialize=U),e&&(this._logEvent=Ac([].concat(z._logEvent.bindings,M)))}return B.prototype=this,new B(this)}return d}qr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};qr.stdSerializers=I2;qr.stdTimeFunctions=Object.assign({},{nullTime:Gl,epochTime:Wl,unixTime:N2,isoTime:C2});function Vn(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?$s:n[t]?n[t]:Vs[t]||Vs[i]||$s,A2(r,e,t)}function A2(r,e,t){!r.transmit&&e[t]===$s||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Vs?Vs:this;for(var d=0;d-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function $n(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.BrowserRandomSource=void 0;var e0=65536,Cc=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function H2(r){for(var e=0;e{});var r0=Z(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.NodeRandomSource=void 0;var G2=Jt(),Fc=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof al<"u"){let e=Lc();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.SystemRandomSource=void 0;var W2=t0(),J2=r0(),qc=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new W2.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new J2.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Ta.SystemRandomSource=qc});var n0=Z(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Y2(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Ut.mul=Math.imul||Y2;function X2(r,e){return r+e|0}Ut.add=X2;function Z2(r,e){return r-e|0}Ut.sub=Z2;function Q2(r,e){return r<>>32-e}Ut.rotl=Q2;function e3(r,e){return r<<32-e|r>>>e}Ut.rotr=e3;function t3(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Ut.isInteger=Number.isInteger||t3;Ut.MAX_SAFE_INTEGER=9007199254740991;Ut.isSafeInteger=function(r){return Ut.isInteger(r)&&r>=-Ut.MAX_SAFE_INTEGER&&r<=Ut.MAX_SAFE_INTEGER}});var Hn=Z(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var s0=n0();function r3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Le.readInt16BE=r3;function i3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Le.readUint16BE=i3;function n3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Le.readInt16LE=n3;function s3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Le.readUint16LE=s3;function o0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Le.writeUint16BE=o0;Le.writeInt16BE=o0;function a0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Le.writeUint16LE=a0;Le.writeInt16LE=a0;function Uc(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Le.readInt32BE=Uc;function zc(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Le.readUint32BE=zc;function Bc(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Le.readInt32LE=Bc;function kc(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Le.readUint32LE=kc;function Da(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Le.writeUint32BE=Da;Le.writeInt32BE=Da;function Pa(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Le.writeUint32LE=Pa;Le.writeInt32LE=Pa;function o3(r,e){e===void 0&&(e=0);var t=Uc(r,e),i=Uc(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Le.readInt64BE=o3;function a3(r,e){e===void 0&&(e=0);var t=zc(r,e),i=zc(r,e+4);return t*4294967296+i}Le.readUint64BE=a3;function f3(r,e){e===void 0&&(e=0);var t=Bc(r,e),i=Bc(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Le.readInt64LE=f3;function c3(r,e){e===void 0&&(e=0);var t=kc(r,e),i=kc(r,e+4);return i*4294967296+t}Le.readUint64LE=c3;function f0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Da(r/4294967296>>>0,e,t),Da(r>>>0,e,t+4),e}Le.writeUint64BE=f0;Le.writeInt64BE=f0;function c0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Pa(r>>>0,e,t),Pa(r/4294967296>>>0,e,t+4),e}Le.writeUint64LE=c0;Le.writeInt64LE=c0;function h3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Le.readUintBE=h3;function u3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Le.writeUintBE=d3;function l3(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!s0.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.randomStringForEntropy=wt.randomString=wt.randomUint32=wt.randomBytes=wt.defaultRandomSource=void 0;var x3=i0(),E3=Hn(),h0=Jt();wt.defaultRandomSource=new x3.SystemRandomSource;function Kc(r,e=wt.defaultRandomSource){return e.randomBytes(r)}wt.randomBytes=Kc;function S3(r=wt.defaultRandomSource){let e=Kc(4,r),t=(0,E3.readUint32LE)(e);return(0,h0.wipe)(e),t}wt.randomUint32=S3;var u0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function d0(r,e=u0,t=wt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Kc(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let d=o[f];d{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});var Wn=Hn(),Gn=Jt();fi.DIGEST_LENGTH=64;fi.BLOCK_SIZE=128;var p0=function(){function r(){this.digestLength=fi.DIGEST_LENGTH,this.blockSize=fi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Gn.wipe(this._buffer),Gn.wipe(this._tempHi),Gn.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Gn.wipe(e.stateHi),Gn.wipe(e.stateLo),e.buffer&&Gn.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();fi.SHA512=p0;var l0=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function jc(r,e,t,i,n,s,o){for(var f=t[0],d=t[1],h=t[2],b=t[3],y=t[4],S=t[5],I=t[6],M=t[7],T=i[0],C=i[1],P=i[2],U=i[3],B=i[4],z=i[5],j=i[6],H=i[7],L,O,W,D,l,w,p,a;o>=128;){for(var u=0;u<16;u++){var v=8*u+s;r[u]=Wn.readUint32BE(n,v),e[u]=Wn.readUint32BE(n,v+4)}for(var u=0;u<80;u++){var _=f,m=d,c=h,x=b,A=y,g=S,R=I,k=M,E=T,N=C,F=P,q=U,K=B,J=z,$=j,V=H;if(L=M,O=H,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=(y>>>14|B<<18)^(y>>>18|B<<14)^(B>>>9|y<<23),O=(B>>>14|y<<18)^(B>>>18|y<<14)^(y>>>9|B<<23),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=y&S^~y&I,O=B&z^~B&j,l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=l0[u*2],O=l0[u*2+1],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=r[u%16],O=e[u%16],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,W=p&65535|a<<16,D=l&65535|w<<16,L=W,O=D,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),O=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,L=f&d^f&h^d&h,O=T&C^T&P^C&P,l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,k=p&65535|a<<16,V=l&65535|w<<16,L=x,O=q,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=W,O=D,l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,q=l&65535|w<<16,d=_,h=m,b=c,y=x,S=A,I=g,M=R,f=k,C=E,P=N,U=F,B=q,z=K,j=J,H=$,T=V,u%16===15)for(var v=0;v<16;v++)L=r[v],O=e[v],l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=r[(v+9)%16],O=e[(v+9)%16],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,W=r[(v+1)%16],D=e[(v+1)%16],L=(W>>>1|D<<31)^(W>>>8|D<<24)^W>>>7,O=(D>>>1|W<<31)^(D>>>8|W<<24)^(D>>>7|W<<25),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,W=r[(v+14)%16],D=e[(v+14)%16],L=(W>>>19|D<<13)^(D>>>29|W<<3)^W>>>6,O=(D>>>19|W<<13)^(W>>>29|D<<3)^(D>>>6|W<<26),l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[v]=p&65535|a<<16,e[v]=l&65535|w<<16}L=f,O=T,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[0],O=i[0],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=d,O=C,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[1],O=i[1],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=d=p&65535|a<<16,i[1]=C=l&65535|w<<16,L=h,O=P,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[2],O=i[2],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=h=p&65535|a<<16,i[2]=P=l&65535|w<<16,L=b,O=U,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[3],O=i[3],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=U=l&65535|w<<16,L=y,O=B,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[4],O=i[4],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=y=p&65535|a<<16,i[4]=B=l&65535|w<<16,L=S,O=z,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[5],O=i[5],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=z=l&65535|w<<16,L=I,O=j,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[6],O=i[6],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=j=l&65535|w<<16,L=M,O=H,l=O&65535,w=O>>>16,p=L&65535,a=L>>>16,L=t[7],O=i[7],l+=O&65535,w+=O>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=H=l&65535|w<<16,s+=128,o-=128}return s}function M3(r){var e=new p0;e.update(r);var t=e.digest();return e.clean(),t}fi.hash=M3});var T0=Z(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var A3=Js(),Ys=g0(),w0=Jt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function te(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,_0(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function x0(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function m0(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Xs(t,r),Xs(i,e),x0(t,i)}function E0(r){let e=new Uint8Array(32);return Xs(e,r),e[0]&1}function N3(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ln(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function gn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function je(r,e,t){let i,n,s=0,o=0,f=0,d=0,h=0,b=0,y=0,S=0,I=0,M=0,T=0,C=0,P=0,U=0,B=0,z=0,j=0,H=0,L=0,O=0,W=0,D=0,l=0,w=0,p=0,a=0,u=0,v=0,_=0,m=0,c=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,d+=i*R,h+=i*k,b+=i*E,y+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,C+=i*$,P+=i*V,U+=i*ee,B+=i*G,z+=i*Y,i=e[1],o+=i*x,f+=i*A,d+=i*g,h+=i*R,b+=i*k,y+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,C+=i*J,P+=i*$,U+=i*V,B+=i*ee,z+=i*G,j+=i*Y,i=e[2],f+=i*x,d+=i*A,h+=i*g,b+=i*R,y+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,C+=i*K,P+=i*J,U+=i*$,B+=i*V,z+=i*ee,j+=i*G,H+=i*Y,i=e[3],d+=i*x,h+=i*A,b+=i*g,y+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,C+=i*q,P+=i*K,U+=i*J,B+=i*$,z+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],h+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,C+=i*F,P+=i*q,U+=i*K,B+=i*J,z+=i*$,j+=i*V,H+=i*ee,L+=i*G,O+=i*Y,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,C+=i*N,P+=i*F,U+=i*q,B+=i*K,z+=i*J,j+=i*$,H+=i*V,L+=i*ee,O+=i*G,W+=i*Y,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,C+=i*E,P+=i*N,U+=i*F,B+=i*q,z+=i*K,j+=i*J,H+=i*$,L+=i*V,O+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,C+=i*k,P+=i*E,U+=i*N,B+=i*F,z+=i*q,j+=i*K,H+=i*J,L+=i*$,O+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,C+=i*R,P+=i*k,U+=i*E,B+=i*N,z+=i*F,j+=i*q,H+=i*K,L+=i*J,O+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,C+=i*g,P+=i*R,U+=i*k,B+=i*E,z+=i*N,j+=i*F,H+=i*q,L+=i*K,O+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,C+=i*A,P+=i*g,U+=i*R,B+=i*k,z+=i*E,j+=i*N,H+=i*F,L+=i*q,O+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],C+=i*x,P+=i*A,U+=i*g,B+=i*R,z+=i*k,j+=i*E,H+=i*N,L+=i*F,O+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,u+=i*Y,i=e[12],P+=i*x,U+=i*A,B+=i*g,z+=i*R,j+=i*k,H+=i*E,L+=i*N,O+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,u+=i*G,v+=i*Y,i=e[13],U+=i*x,B+=i*A,z+=i*g,j+=i*R,H+=i*k,L+=i*E,O+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,u+=i*ee,v+=i*G,_+=i*Y,i=e[14],B+=i*x,z+=i*A,j+=i*g,H+=i*R,L+=i*k,O+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,u+=i*V,v+=i*ee,_+=i*G,m+=i*Y,i=e[15],z+=i*x,j+=i*A,H+=i*g,L+=i*R,O+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,u+=i*$,v+=i*V,_+=i*ee,m+=i*G,c+=i*Y,s+=38*j,o+=38*H,f+=38*L,d+=38*O,h+=38*W,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*u,C+=38*v,P+=38*_,U+=38*m,B+=38*c,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=d,r[4]=h,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=C,r[12]=P,r[13]=U,r[14]=B,r[15]=z}function pn(r,e){je(r,e,e)}function S0(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)pn(t,t),i!==2&&i!==4&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function C3(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)pn(t,t),i!==1&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Gc(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),d=te(),h=te(),b=te();gn(t,r[1],r[0]),gn(b,e[1],e[0]),je(t,t,b),ln(i,r[0],r[1]),ln(b,e[0],e[1]),je(i,i,b),je(n,r[3],e[3]),je(n,n,D3),je(s,r[2],e[2]),ln(s,s,s),gn(o,i,t),gn(f,s,n),ln(d,s,n),ln(h,i,t),je(r[0],o,f),je(r[1],h,d),je(r[2],d,f),je(r[3],o,h)}function y0(r,e,t){for(let i=0;i<4;i++)_0(r[i],e[i],t)}function Jc(r,e){let t=te(),i=te(),n=te();S0(n,e[2]),je(t,e[0],n),je(i,e[1],n),Xs(r,i),r[31]^=E0(t)<<7}function I0(r,e,t){Ai(r[0],Hc),Ai(r[1],Jn),Ai(r[2],Jn),Ai(r[3],Hc);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;y0(r,e,n),Gc(e,r),Gc(r,r),y0(r,e,n)}}function Yc(r,e){let t=[te(),te(),te(),te()];Ai(t[0],b0),Ai(t[1],v0),Ai(t[2],Jn),je(t[3],b0,v0),I0(r,t,e)}function M0(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ys.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[te(),te(),te(),te()];Yc(i,e),Jc(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=M0;function O3(r){let e=(0,A3.randomBytes)(32,r),t=M0(e);return(0,w0.wipe)(e),t}ze.generateKeyPair=O3;function L3(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=L3;var $c=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function A0(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*$c[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*$c[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Wc(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;A0(r,e)}function F3(r,e){let t=new Float64Array(64),i=[te(),te(),te(),te()],n=(0,Ys.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ys.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Wc(f),Yc(i,f),Jc(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let d=o.digest();Wc(d);for(let h=0;h<32;h++)t[h]=f[h];for(let h=0;h<32;h++)for(let b=0;b<32;b++)t[h+b]+=d[h]*n[b];return A0(s.subarray(32),t),s}ze.sign=F3;function R0(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),d=te();return Ai(r[2],Jn),N3(r[1],e),pn(n,r[1]),je(s,n,T3),gn(n,n,r[2]),ln(s,r[2],s),pn(o,s),pn(f,o),je(d,f,o),je(t,d,n),je(t,t,s),C3(t,t),je(t,t,n),je(t,t,s),je(t,t,s),je(r[0],t,s),pn(i,r[0]),je(i,i,s),m0(i,n)&&je(r[0],r[0],P3),pn(i,r[0]),je(i,i,s),m0(i,n)?-1:(E0(r[0])===e[31]>>7&&gn(r[0],Hc,r[0]),je(r[3],r[0],r[1]),0)}function q3(r,e,t){let i=new Uint8Array(32),n=[te(),te(),te(),te()],s=[te(),te(),te(),te()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(R0(s,r))return!1;let o=new Ys.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Wc(f),I0(n,s,f),Yc(s,t.subarray(32)),Gc(n,s),Jc(i,n),!x0(t,i)}ze.verify=q3;function U3(r){let e=[te(),te(),te(),te()];if(R0(e,r))throw new Error("Ed25519: invalid public key");let t=te(),i=te(),n=e[1];ln(t,Jn,n),gn(i,Jn,n),S0(i,i),je(t,t,i);let s=new Uint8Array(32);return Xs(s,t),s}ze.convertPublicKeyToX25519=U3;function z3(r){let e=(0,Ys.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,w0.wipe)(e),t}ze.convertSecretKeyToX25519=z3});var za=Z(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.getLocalStorage=He.getLocalStorageOrThrow=He.getCrypto=He.getCryptoOrThrow=He.getLocation=He.getLocationOrThrow=He.getNavigator=He.getNavigatorOrThrow=He.getDocument=He.getDocumentOrThrow=He.getFromWindowOrThrow=He.getFromWindow=void 0;function mn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}He.getFromWindow=mn;function rs(r){let e=mn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}He.getFromWindowOrThrow=rs;function dw(){return rs("document")}He.getDocumentOrThrow=dw;function lw(){return mn("document")}He.getDocument=lw;function pw(){return rs("navigator")}He.getNavigatorOrThrow=pw;function gw(){return mn("navigator")}He.getNavigator=gw;function bw(){return rs("location")}He.getLocationOrThrow=bw;function vw(){return mn("location")}He.getLocation=vw;function mw(){return rs("crypto")}He.getCryptoOrThrow=mw;function yw(){return mn("crypto")}He.getCrypto=yw;function ww(){return rs("localStorage")}He.getLocalStorageOrThrow=ww;function _w(){return mn("localStorage")}He.getLocalStorage=_w});var gp=Z(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.getWindowMetadata=void 0;var pp=za();function xw(){let r,e;try{r=pp.getDocumentOrThrow(),e=pp.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let C=M.getAttribute("href");if(C)if(C.toLowerCase().indexOf("https:")===-1&&C.toLowerCase().indexOf("http:")===-1&&C.indexOf("//")!==0){let P=e.protocol+"//"+e.host;if(C.indexOf("/")===0)P+=C;else{let U=e.pathname.split("/");U.pop();let B=U.join("/");P+=B+"/"+C}S.push(P)}else if(C.indexOf("//")===0){let P=e.protocol+C;S.push(P)}else S.push(C)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(C)).filter(C=>C?y.includes(C):!1);if(T.length&&T){let C=M.getAttribute("content");if(C)return C}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),d=e.origin,h=t();return{description:f,url:d,icons:h,name:o}}Ba.getWindowMetadata=xw});var vp=Z((zM,bp)=>{"use strict";bp.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var xp=Z((BM,_p)=>{"use strict";var wp="%[a-f0-9]{2}",mp=new RegExp("("+wp+")|([^%]+?)","gi"),yp=new RegExp("("+wp+")+","gi");function xh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],xh(t),xh(i))}function Ew(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(mp)||[],t=1;t{"use strict";Ep.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Mp=Z((KM,Ip)=>{"use strict";Ip.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Iw=vp(),Mw=xp(),Rp=Sp(),Aw=Mp(),Rw=r=>r==null,Eh=Symbol("encodeFragmentIdentifier");function Tw(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[",n,"]"].join("")]:[...t,[it(e,r),"[",it(n,r),"]=",it(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[]"].join("")]:[...t,[it(e,r),"[]=",it(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),":list="].join("")]:[...t,[it(e,r),":list=",it(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[it(t,r),e,it(n,r)].join("")]:[[i,it(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,it(e,r)]:[...t,[it(e,r),"=",it(i,r)].join("")]}}function Dw(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&hi(i,r).includes(r.arrayFormatSeparator);i=o?hi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(d=>hi(d,r)):i===null?i:hi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&hi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>hi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Tp(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function it(r,e){return e.encode?e.strict?Iw(r):encodeURIComponent(r):r}function hi(r,e){return e.decode?Mw(r):r}function Dp(r){return Array.isArray(r)?r.sort():typeof r=="object"?Dp(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Pp(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Pw(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Np(r){r=Pp(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ap(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Cp(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Tp(e.arrayFormatSeparator);let t=Dw(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Rp(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:hi(o,e),t(hi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ap(s[o],e);else i[n]=Ap(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Dp(o):n[s]=o,n},Object.create(null))}Ct.extract=Np;Ct.parse=Cp;Ct.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Tp(e.arrayFormatSeparator);let t=o=>e.skipNull&&Rw(r[o])||e.skipEmptyString&&r[o]==="",i=Tw(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?it(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?it(o,e)+"[]":f.reduce(i(o),[]).join("&"):it(o,e)+"="+it(f,e)}).filter(o=>o.length>0).join("&")};Ct.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Rp(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Cp(Np(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:hi(i,e)}:{})};Ct.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Eh]:!0},e);let t=Pp(r.url).split("?")[0]||"",i=Ct.extract(r.url),n=Ct.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ct.stringify(s,e);o&&(o=`?${o}`);let f=Pw(r.url);return r.fragmentIdentifier&&(f=`#${e[Eh]?it(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ct.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Eh]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ct.parseUrl(r,t);return Ct.stringifyUrl({url:i,query:Aw(n,e),fragmentIdentifier:s},t)};Ct.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ct.pick(r,i,t)}});var Lp=Z((VM,ka)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=window:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ka=="object"&&ka.exports,f=typeof define=="function"&&define.amd,d=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",h="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],C=[224,256,384,512],P=[128,256],U=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),d&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var z=function(E,N,F){return function(q){return new g(E,N,E).update(q)[F]()}},j=function(E,N,F){return function(q,K){return new g(E,N,K).update(q)[F]()}},H=function(E,N,F){return function(q,K,J,$){return a["cshake"+E].update(q,K,J,$)[F]()}},L=function(E,N,F){return function(q,K,J,$){return a["kmac"+E].update(q,K,J,$)[F]()}},O=function(E,N,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(d&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!d||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}for(var q=this.blocks,K=this.byteCount,J=E.length,$=this.blockCount,V=0,ee=this.s,G,Y;V>2]|=E[V]<>2]|=Y<>2]|=(192|Y>>6)<>2]|=(128|Y&63)<=57344?(q[G>>2]|=(224|Y>>12)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<>2]|=(240|Y>>18)<>2]|=(128|Y>>12&63)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<=K){for(this.start=G-K,this.block=q[$],G=0;G<$;++G)ee[G]^=q[G];k(ee),this.reset=!0}else this.start=G}return this},g.prototype.encode=function(E,N){var F=E&255,q=1,K=[F];for(E=E>>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return N?K.push(q):K.unshift(q),this.update(K),K.length},g.prototype.encodeString=function(E){var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(d&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!d||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}var q=0,K=E.length;if(N)q=K;else for(var J=0;J=57344?q+=3:($=65536+(($&1023)<<10|E.charCodeAt(++J)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},g.prototype.bytepad=function(E,N){for(var F=this.encode(N),q=0;q>2]|=this.padding[N&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],N=1;N>4&15]+h[V&15]+h[V>>12&15]+h[V>>8&15]+h[V>>20&15]+h[V>>16&15]+h[V>>28&15]+h[V>>24&15];J%E===0&&(k(N),K=0)}return q&&(V=N[K],$+=h[V>>4&15]+h[V&15],q>1&&($+=h[V>>12&15]+h[V>>8&15]),q>2&&($+=h[V>>20&15]+h[V>>16&15])),$},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,N=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,J=0,$=this.outputBits>>3,V;q?V=new ArrayBuffer(F+1<<2):V=new ArrayBuffer($);for(var ee=new Uint32Array(V);J>8&255,$[V+2]=ee>>16&255,$[V+3]=ee>>24&255;J%E===0&&k(N)}return q&&(V=J<<2,ee=N[K],$[V]=ee&255,q>1&&($[V+1]=ee>>8&255),q>2&&($[V+2]=ee>>16&255)),$};function R(E,N,F){g.call(this,E,N,F)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var k=function(E){var N,F,q,K,J,$,V,ee,G,Y,_r,ie,ne,xr,se,oe,Er,ae,fe,Sr,ce,he,Ir,ue,de,Mr,le,pe,Ar,ge,be,Rr,ve,me,Tr,ye,we,Dr,_e,xe,Pr,Ee,Se,Nr,Ie,Me,Cr,Ae,Re,Or,Te,De,Lr,Pe,Ne,nr,Be,ke,jt,Vt,$t,Ht,Gt;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],J=E[1]^E[11]^E[21]^E[31]^E[41],$=E[2]^E[12]^E[22]^E[32]^E[42],V=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],Y=E[6]^E[16]^E[26]^E[36]^E[46],_r=E[7]^E[17]^E[27]^E[37]^E[47],ie=E[8]^E[18]^E[28]^E[38]^E[48],ne=E[9]^E[19]^E[29]^E[39]^E[49],N=ie^($<<1|V>>>31),F=ne^(V<<1|$>>>31),E[0]^=N,E[1]^=F,E[10]^=N,E[11]^=F,E[20]^=N,E[21]^=F,E[30]^=N,E[31]^=F,E[40]^=N,E[41]^=F,N=K^(ee<<1|G>>>31),F=J^(G<<1|ee>>>31),E[2]^=N,E[3]^=F,E[12]^=N,E[13]^=F,E[22]^=N,E[23]^=F,E[32]^=N,E[33]^=F,E[42]^=N,E[43]^=F,N=$^(Y<<1|_r>>>31),F=V^(_r<<1|Y>>>31),E[4]^=N,E[5]^=F,E[14]^=N,E[15]^=F,E[24]^=N,E[25]^=F,E[34]^=N,E[35]^=F,E[44]^=N,E[45]^=F,N=ee^(ie<<1|ne>>>31),F=G^(ne<<1|ie>>>31),E[6]^=N,E[7]^=F,E[16]^=N,E[17]^=F,E[26]^=N,E[27]^=F,E[36]^=N,E[37]^=F,E[46]^=N,E[47]^=F,N=Y^(K<<1|J>>>31),F=_r^(J<<1|K>>>31),E[8]^=N,E[9]^=F,E[18]^=N,E[19]^=F,E[28]^=N,E[29]^=F,E[38]^=N,E[39]^=F,E[48]^=N,E[49]^=F,xr=E[0],se=E[1],Me=E[11]<<4|E[10]>>>28,Cr=E[10]<<4|E[11]>>>28,pe=E[20]<<3|E[21]>>>29,Ar=E[21]<<3|E[20]>>>29,Vt=E[31]<<9|E[30]>>>23,$t=E[30]<<9|E[31]>>>23,Ee=E[40]<<18|E[41]>>>14,Se=E[41]<<18|E[40]>>>14,me=E[2]<<1|E[3]>>>31,Tr=E[3]<<1|E[2]>>>31,oe=E[13]<<12|E[12]>>>20,Er=E[12]<<12|E[13]>>>20,Ae=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,ge=E[33]<<13|E[32]>>>19,be=E[32]<<13|E[33]>>>19,Ht=E[42]<<2|E[43]>>>30,Gt=E[43]<<2|E[42]>>>30,Pe=E[5]<<30|E[4]>>>2,Ne=E[4]<<30|E[5]>>>2,ye=E[14]<<6|E[15]>>>26,we=E[15]<<6|E[14]>>>26,ae=E[25]<<11|E[24]>>>21,fe=E[24]<<11|E[25]>>>21,Or=E[34]<<15|E[35]>>>17,Te=E[35]<<15|E[34]>>>17,Rr=E[45]<<29|E[44]>>>3,ve=E[44]<<29|E[45]>>>3,ue=E[6]<<28|E[7]>>>4,de=E[7]<<28|E[6]>>>4,nr=E[17]<<23|E[16]>>>9,Be=E[16]<<23|E[17]>>>9,Dr=E[26]<<25|E[27]>>>7,_e=E[27]<<25|E[26]>>>7,Sr=E[36]<<21|E[37]>>>11,ce=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Lr=E[46]<<24|E[47]>>>8,Nr=E[8]<<27|E[9]>>>5,Ie=E[9]<<27|E[8]>>>5,Mr=E[18]<<20|E[19]>>>12,le=E[19]<<20|E[18]>>>12,ke=E[29]<<7|E[28]>>>25,jt=E[28]<<7|E[29]>>>25,xe=E[38]<<8|E[39]>>>24,Pr=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Ir=E[49]<<14|E[48]>>>18,E[0]=xr^~oe&ae,E[1]=se^~Er&fe,E[10]=ue^~Mr&pe,E[11]=de^~le&Ar,E[20]=me^~ye&Dr,E[21]=Tr^~we&_e,E[30]=Nr^~Me&Ae,E[31]=Ie^~Cr&Re,E[40]=Pe^~nr&ke,E[41]=Ne^~Be&jt,E[2]=oe^~ae&Sr,E[3]=Er^~fe&ce,E[12]=Mr^~pe&ge,E[13]=le^~Ar&be,E[22]=ye^~Dr&xe,E[23]=we^~_e&Pr,E[32]=Me^~Ae&Or,E[33]=Cr^~Re&Te,E[42]=nr^~ke&Vt,E[43]=Be^~jt&$t,E[4]=ae^~Sr&he,E[5]=fe^~ce&Ir,E[14]=pe^~ge&Rr,E[15]=Ar^~be&ve,E[24]=Dr^~xe&Ee,E[25]=_e^~Pr&Se,E[34]=Ae^~Or&De,E[35]=Re^~Te&Lr,E[44]=ke^~Vt&Ht,E[45]=jt^~$t&Gt,E[6]=Sr^~he&xr,E[7]=ce^~Ir&se,E[16]=ge^~Rr&ue,E[17]=be^~ve&de,E[26]=xe^~Ee&me,E[27]=Pr^~Se&Tr,E[36]=Or^~De&Nr,E[37]=Te^~Lr&Ie,E[46]=Vt^~Ht&Pe,E[47]=$t^~Gt&Ne,E[8]=he^~xr&oe,E[9]=Ir^~se&Er,E[18]=Rr^~ue&Mr,E[19]=ve^~de&le,E[28]=Ee^~me&ye,E[29]=Se^~Tr&we,E[38]=De^~Nr&Me,E[39]=Lr^~Ie&Cr,E[48]=Ht^~Pe&nr,E[49]=Gt^~Ne&Be,E[0]^=T[q],E[1]^=T[q+1]};if(o)ka.exports=a;else{for(v=0;v{});var Ph=Z((Gp,Dh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var u=function(){};u.prototype=a.prototype,p.prototype=new u,p.prototype.constructor=p}function n(p,a,u){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(u=a,a=10),this._init(p||0,a||10,u||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,u){return a.cmp(u)>0?a:u},n.min=function(a,u){return a.cmp(u)<0?a:u},n.prototype._init=function(a,u,v){if(typeof a=="number")return this._initNumber(a,u,v);if(typeof a=="object")return this._initArray(a,u,v);u==="hex"&&(u=16),t(u===(u|0)&&u>=2&&u<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)c=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[m]|=c<>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);else if(v==="le")for(_=0,m=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,m++);return this._strip()};function o(p,a){var u=p.charCodeAt(a);if(u>=48&&u<=57)return u-48;if(u>=65&&u<=70)return u-55;if(u>=97&&u<=102)return u-87;t(!1,"Invalid character in "+p)}function f(p,a,u){var v=o(p,u);return u-1>=a&&(v|=o(p,u-1)<<4),v}n.prototype._parseHex=function(a,u,v){this.length=Math.ceil((a.length-u)/6),this.words=new Array(this.length);for(var _=0;_=u;_-=2)x=f(a,u,_)<=18?(m-=18,c+=1,this.words[c]|=x>>>26):m+=8;else{var A=a.length-u;for(_=A%2===0?u+1:u;_=18?(m-=18,c+=1,this.words[c]|=x>>>26):m+=8}this._strip()};function d(p,a,u,v){for(var _=0,m=0,c=Math.min(p.length,u),x=a;x=49?m=A-49+10:A>=17?m=A-17+10:m=A,t(A>=0&&m1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,u){a=a||10,u=u|0||1;var v;if(a===16||a==="hex"){v="";for(var _=0,m=0,c=0;c>>24-_&16777215,_+=2,_>=26&&(_-=26,c--),m!==0||c!==this.length-1?v=y[6-A.length]+A+v:v=A+v}for(m!==0&&(v=m.toString(16)+v);v.length%u!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];v="";var k=this.clone();for(k.negative=0;!k.isZero();){var E=k.modrn(R).toString(a);k=k.idivn(R),k.isZero()?v=E+v:v=y[g-E.length]+E+v}for(this.isZero()&&(v="0"+v);v.length%u!==0;)v="0"+v;return this.negative!==0&&(v="-"+v),v}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,u){return this.toArrayLike(s,a,u)}),n.prototype.toArray=function(a,u){return this.toArrayLike(Array,a,u)};var M=function(a,u){return a.allocUnsafe?a.allocUnsafe(u):new a(u)};n.prototype.toArrayLike=function(a,u,v){this._strip();var _=this.byteLength(),m=v||Math.max(1,_);t(_<=m,"byte array longer than desired length"),t(m>0,"Requested array length <= 0");var c=M(a,m),x=u==="le"?"LE":"BE";return this["_toArrayLike"+x](c,_),c},n.prototype._toArrayLikeLE=function(a,u){for(var v=0,_=0,m=0,c=0;m>8&255),v>16&255),c===6?(v>24&255),_=0,c=0):(_=x>>>24,c+=2)}if(v=0&&(a[v--]=x>>8&255),v>=0&&(a[v--]=x>>16&255),c===6?(v>=0&&(a[v--]=x>>24&255),_=0,c=0):(_=x>>>24,c+=2)}if(v>=0)for(a[v--]=_;v>=0;)a[v--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var u=a,v=0;return u>=4096&&(v+=13,u>>>=13),u>=64&&(v+=7,u>>>=7),u>=8&&(v+=4,u>>>=4),u>=2&&(v+=2,u>>>=2),v+u},n.prototype._zeroBits=function(a){if(a===0)return 26;var u=a,v=0;return u&8191||(v+=13,u>>>=13),u&127||(v+=7,u>>>=7),u&15||(v+=4,u>>>=4),u&3||(v+=2,u>>>=2),u&1||v++,v},n.prototype.bitLength=function(){var a=this.words[this.length-1],u=this._countBits(a);return(this.length-1)*26+u};function T(p){for(var a=new Array(p.bitLength()),u=0;u>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,u=0;ua.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var u;this.length>a.length?u=a:u=this;for(var v=0;va.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var u,v;this.length>a.length?(u=this,v=a):(u=a,v=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var u=Math.ceil(a/26)|0,v=a%26;this._expand(u),v>0&&u--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-v),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,u){t(typeof a=="number"&&a>=0);var v=a/26|0,_=a%26;return this._expand(v+1),u?this.words[v]=this.words[v]|1<<_:this.words[v]=this.words[v]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var u;if(this.negative!==0&&a.negative===0)return this.negative=0,u=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,u=this.isub(a),a.negative=1,u._normSign();var v,_;this.length>a.length?(v=this,_=a):(v=a,_=this);for(var m=0,c=0;c<_.length;c++)u=(v.words[c]|0)+(_.words[c]|0)+m,this.words[c]=u&67108863,m=u>>>26;for(;m!==0&&c>>26;if(this.length=v.length,m!==0)this.words[this.length]=m,this.length++;else if(v!==this)for(;ca.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var u=this.iadd(a);return a.negative=1,u._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var v=this.cmp(a);if(v===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,m;v>0?(_=this,m=a):(_=a,m=this);for(var c=0,x=0;x>26,this.words[x]=u&67108863;for(;c!==0&&x<_.length;x++)u=(_.words[x]|0)+c,c=u>>26,this.words[x]=u&67108863;if(c===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function C(p,a,u){u.negative=a.negative^p.negative;var v=p.length+a.length|0;u.length=v,v=v-1|0;var _=p.words[0]|0,m=a.words[0]|0,c=_*m,x=c&67108863,A=c/67108864|0;u.words[0]=x;for(var g=1;g>>26,k=A&67108863,E=Math.min(g,a.length-1),N=Math.max(0,g-p.length+1);N<=E;N++){var F=g-N|0;_=p.words[F]|0,m=a.words[N]|0,c=_*m+k,R+=c/67108864|0,k=c&67108863}u.words[g]=k|0,A=R|0}return A!==0?u.words[g]=A|0:u.length--,u._strip()}var P=function(a,u,v){var _=a.words,m=u.words,c=v.words,x=0,A,g,R,k=_[0]|0,E=k&8191,N=k>>>13,F=_[1]|0,q=F&8191,K=F>>>13,J=_[2]|0,$=J&8191,V=J>>>13,ee=_[3]|0,G=ee&8191,Y=ee>>>13,_r=_[4]|0,ie=_r&8191,ne=_r>>>13,xr=_[5]|0,se=xr&8191,oe=xr>>>13,Er=_[6]|0,ae=Er&8191,fe=Er>>>13,Sr=_[7]|0,ce=Sr&8191,he=Sr>>>13,Ir=_[8]|0,ue=Ir&8191,de=Ir>>>13,Mr=_[9]|0,le=Mr&8191,pe=Mr>>>13,Ar=m[0]|0,ge=Ar&8191,be=Ar>>>13,Rr=m[1]|0,ve=Rr&8191,me=Rr>>>13,Tr=m[2]|0,ye=Tr&8191,we=Tr>>>13,Dr=m[3]|0,_e=Dr&8191,xe=Dr>>>13,Pr=m[4]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=m[5]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=m[6]|0,Ae=Cr&8191,Re=Cr>>>13,Or=m[7]|0,Te=Or&8191,De=Or>>>13,Lr=m[8]|0,Pe=Lr&8191,Ne=Lr>>>13,nr=m[9]|0,Be=nr&8191,ke=nr>>>13;v.negative=a.negative^u.negative,v.length=19,A=Math.imul(E,ge),g=Math.imul(E,be),g=g+Math.imul(N,ge)|0,R=Math.imul(N,be);var jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(jt>>>26)|0,jt&=67108863,A=Math.imul(q,ge),g=Math.imul(q,be),g=g+Math.imul(K,ge)|0,R=Math.imul(K,be),A=A+Math.imul(E,ve)|0,g=g+Math.imul(E,me)|0,g=g+Math.imul(N,ve)|0,R=R+Math.imul(N,me)|0;var Vt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,A=Math.imul($,ge),g=Math.imul($,be),g=g+Math.imul(V,ge)|0,R=Math.imul(V,be),A=A+Math.imul(q,ve)|0,g=g+Math.imul(q,me)|0,g=g+Math.imul(K,ve)|0,R=R+Math.imul(K,me)|0,A=A+Math.imul(E,ye)|0,g=g+Math.imul(E,we)|0,g=g+Math.imul(N,ye)|0,R=R+Math.imul(N,we)|0;var $t=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+($t>>>26)|0,$t&=67108863,A=Math.imul(G,ge),g=Math.imul(G,be),g=g+Math.imul(Y,ge)|0,R=Math.imul(Y,be),A=A+Math.imul($,ve)|0,g=g+Math.imul($,me)|0,g=g+Math.imul(V,ve)|0,R=R+Math.imul(V,me)|0,A=A+Math.imul(q,ye)|0,g=g+Math.imul(q,we)|0,g=g+Math.imul(K,ye)|0,R=R+Math.imul(K,we)|0,A=A+Math.imul(E,_e)|0,g=g+Math.imul(E,xe)|0,g=g+Math.imul(N,_e)|0,R=R+Math.imul(N,xe)|0;var Ht=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,A=Math.imul(ie,ge),g=Math.imul(ie,be),g=g+Math.imul(ne,ge)|0,R=Math.imul(ne,be),A=A+Math.imul(G,ve)|0,g=g+Math.imul(G,me)|0,g=g+Math.imul(Y,ve)|0,R=R+Math.imul(Y,me)|0,A=A+Math.imul($,ye)|0,g=g+Math.imul($,we)|0,g=g+Math.imul(V,ye)|0,R=R+Math.imul(V,we)|0,A=A+Math.imul(q,_e)|0,g=g+Math.imul(q,xe)|0,g=g+Math.imul(K,_e)|0,R=R+Math.imul(K,xe)|0,A=A+Math.imul(E,Ee)|0,g=g+Math.imul(E,Se)|0,g=g+Math.imul(N,Ee)|0,R=R+Math.imul(N,Se)|0;var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(se,ge),g=Math.imul(se,be),g=g+Math.imul(oe,ge)|0,R=Math.imul(oe,be),A=A+Math.imul(ie,ve)|0,g=g+Math.imul(ie,me)|0,g=g+Math.imul(ne,ve)|0,R=R+Math.imul(ne,me)|0,A=A+Math.imul(G,ye)|0,g=g+Math.imul(G,we)|0,g=g+Math.imul(Y,ye)|0,R=R+Math.imul(Y,we)|0,A=A+Math.imul($,_e)|0,g=g+Math.imul($,xe)|0,g=g+Math.imul(V,_e)|0,R=R+Math.imul(V,xe)|0,A=A+Math.imul(q,Ee)|0,g=g+Math.imul(q,Se)|0,g=g+Math.imul(K,Ee)|0,R=R+Math.imul(K,Se)|0,A=A+Math.imul(E,Ie)|0,g=g+Math.imul(E,Me)|0,g=g+Math.imul(N,Ie)|0,R=R+Math.imul(N,Me)|0;var Zi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,A=Math.imul(ae,ge),g=Math.imul(ae,be),g=g+Math.imul(fe,ge)|0,R=Math.imul(fe,be),A=A+Math.imul(se,ve)|0,g=g+Math.imul(se,me)|0,g=g+Math.imul(oe,ve)|0,R=R+Math.imul(oe,me)|0,A=A+Math.imul(ie,ye)|0,g=g+Math.imul(ie,we)|0,g=g+Math.imul(ne,ye)|0,R=R+Math.imul(ne,we)|0,A=A+Math.imul(G,_e)|0,g=g+Math.imul(G,xe)|0,g=g+Math.imul(Y,_e)|0,R=R+Math.imul(Y,xe)|0,A=A+Math.imul($,Ee)|0,g=g+Math.imul($,Se)|0,g=g+Math.imul(V,Ee)|0,R=R+Math.imul(V,Se)|0,A=A+Math.imul(q,Ie)|0,g=g+Math.imul(q,Me)|0,g=g+Math.imul(K,Ie)|0,R=R+Math.imul(K,Me)|0,A=A+Math.imul(E,Ae)|0,g=g+Math.imul(E,Re)|0,g=g+Math.imul(N,Ae)|0,R=R+Math.imul(N,Re)|0;var Qi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,A=Math.imul(ce,ge),g=Math.imul(ce,be),g=g+Math.imul(he,ge)|0,R=Math.imul(he,be),A=A+Math.imul(ae,ve)|0,g=g+Math.imul(ae,me)|0,g=g+Math.imul(fe,ve)|0,R=R+Math.imul(fe,me)|0,A=A+Math.imul(se,ye)|0,g=g+Math.imul(se,we)|0,g=g+Math.imul(oe,ye)|0,R=R+Math.imul(oe,we)|0,A=A+Math.imul(ie,_e)|0,g=g+Math.imul(ie,xe)|0,g=g+Math.imul(ne,_e)|0,R=R+Math.imul(ne,xe)|0,A=A+Math.imul(G,Ee)|0,g=g+Math.imul(G,Se)|0,g=g+Math.imul(Y,Ee)|0,R=R+Math.imul(Y,Se)|0,A=A+Math.imul($,Ie)|0,g=g+Math.imul($,Me)|0,g=g+Math.imul(V,Ie)|0,R=R+Math.imul(V,Me)|0,A=A+Math.imul(q,Ae)|0,g=g+Math.imul(q,Re)|0,g=g+Math.imul(K,Ae)|0,R=R+Math.imul(K,Re)|0,A=A+Math.imul(E,Te)|0,g=g+Math.imul(E,De)|0,g=g+Math.imul(N,Te)|0,R=R+Math.imul(N,De)|0;var en=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(en>>>26)|0,en&=67108863,A=Math.imul(ue,ge),g=Math.imul(ue,be),g=g+Math.imul(de,ge)|0,R=Math.imul(de,be),A=A+Math.imul(ce,ve)|0,g=g+Math.imul(ce,me)|0,g=g+Math.imul(he,ve)|0,R=R+Math.imul(he,me)|0,A=A+Math.imul(ae,ye)|0,g=g+Math.imul(ae,we)|0,g=g+Math.imul(fe,ye)|0,R=R+Math.imul(fe,we)|0,A=A+Math.imul(se,_e)|0,g=g+Math.imul(se,xe)|0,g=g+Math.imul(oe,_e)|0,R=R+Math.imul(oe,xe)|0,A=A+Math.imul(ie,Ee)|0,g=g+Math.imul(ie,Se)|0,g=g+Math.imul(ne,Ee)|0,R=R+Math.imul(ne,Se)|0,A=A+Math.imul(G,Ie)|0,g=g+Math.imul(G,Me)|0,g=g+Math.imul(Y,Ie)|0,R=R+Math.imul(Y,Me)|0,A=A+Math.imul($,Ae)|0,g=g+Math.imul($,Re)|0,g=g+Math.imul(V,Ae)|0,R=R+Math.imul(V,Re)|0,A=A+Math.imul(q,Te)|0,g=g+Math.imul(q,De)|0,g=g+Math.imul(K,Te)|0,R=R+Math.imul(K,De)|0,A=A+Math.imul(E,Pe)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(N,Pe)|0,R=R+Math.imul(N,Ne)|0;var tn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(tn>>>26)|0,tn&=67108863,A=Math.imul(le,ge),g=Math.imul(le,be),g=g+Math.imul(pe,ge)|0,R=Math.imul(pe,be),A=A+Math.imul(ue,ve)|0,g=g+Math.imul(ue,me)|0,g=g+Math.imul(de,ve)|0,R=R+Math.imul(de,me)|0,A=A+Math.imul(ce,ye)|0,g=g+Math.imul(ce,we)|0,g=g+Math.imul(he,ye)|0,R=R+Math.imul(he,we)|0,A=A+Math.imul(ae,_e)|0,g=g+Math.imul(ae,xe)|0,g=g+Math.imul(fe,_e)|0,R=R+Math.imul(fe,xe)|0,A=A+Math.imul(se,Ee)|0,g=g+Math.imul(se,Se)|0,g=g+Math.imul(oe,Ee)|0,R=R+Math.imul(oe,Se)|0,A=A+Math.imul(ie,Ie)|0,g=g+Math.imul(ie,Me)|0,g=g+Math.imul(ne,Ie)|0,R=R+Math.imul(ne,Me)|0,A=A+Math.imul(G,Ae)|0,g=g+Math.imul(G,Re)|0,g=g+Math.imul(Y,Ae)|0,R=R+Math.imul(Y,Re)|0,A=A+Math.imul($,Te)|0,g=g+Math.imul($,De)|0,g=g+Math.imul(V,Te)|0,R=R+Math.imul(V,De)|0,A=A+Math.imul(q,Pe)|0,g=g+Math.imul(q,Ne)|0,g=g+Math.imul(K,Pe)|0,R=R+Math.imul(K,Ne)|0,A=A+Math.imul(E,Be)|0,g=g+Math.imul(E,ke)|0,g=g+Math.imul(N,Be)|0,R=R+Math.imul(N,ke)|0;var rn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(rn>>>26)|0,rn&=67108863,A=Math.imul(le,ve),g=Math.imul(le,me),g=g+Math.imul(pe,ve)|0,R=Math.imul(pe,me),A=A+Math.imul(ue,ye)|0,g=g+Math.imul(ue,we)|0,g=g+Math.imul(de,ye)|0,R=R+Math.imul(de,we)|0,A=A+Math.imul(ce,_e)|0,g=g+Math.imul(ce,xe)|0,g=g+Math.imul(he,_e)|0,R=R+Math.imul(he,xe)|0,A=A+Math.imul(ae,Ee)|0,g=g+Math.imul(ae,Se)|0,g=g+Math.imul(fe,Ee)|0,R=R+Math.imul(fe,Se)|0,A=A+Math.imul(se,Ie)|0,g=g+Math.imul(se,Me)|0,g=g+Math.imul(oe,Ie)|0,R=R+Math.imul(oe,Me)|0,A=A+Math.imul(ie,Ae)|0,g=g+Math.imul(ie,Re)|0,g=g+Math.imul(ne,Ae)|0,R=R+Math.imul(ne,Re)|0,A=A+Math.imul(G,Te)|0,g=g+Math.imul(G,De)|0,g=g+Math.imul(Y,Te)|0,R=R+Math.imul(Y,De)|0,A=A+Math.imul($,Pe)|0,g=g+Math.imul($,Ne)|0,g=g+Math.imul(V,Pe)|0,R=R+Math.imul(V,Ne)|0,A=A+Math.imul(q,Be)|0,g=g+Math.imul(q,ke)|0,g=g+Math.imul(K,Be)|0,R=R+Math.imul(K,ke)|0;var nn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nn>>>26)|0,nn&=67108863,A=Math.imul(le,ye),g=Math.imul(le,we),g=g+Math.imul(pe,ye)|0,R=Math.imul(pe,we),A=A+Math.imul(ue,_e)|0,g=g+Math.imul(ue,xe)|0,g=g+Math.imul(de,_e)|0,R=R+Math.imul(de,xe)|0,A=A+Math.imul(ce,Ee)|0,g=g+Math.imul(ce,Se)|0,g=g+Math.imul(he,Ee)|0,R=R+Math.imul(he,Se)|0,A=A+Math.imul(ae,Ie)|0,g=g+Math.imul(ae,Me)|0,g=g+Math.imul(fe,Ie)|0,R=R+Math.imul(fe,Me)|0,A=A+Math.imul(se,Ae)|0,g=g+Math.imul(se,Re)|0,g=g+Math.imul(oe,Ae)|0,R=R+Math.imul(oe,Re)|0,A=A+Math.imul(ie,Te)|0,g=g+Math.imul(ie,De)|0,g=g+Math.imul(ne,Te)|0,R=R+Math.imul(ne,De)|0,A=A+Math.imul(G,Pe)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(Y,Pe)|0,R=R+Math.imul(Y,Ne)|0,A=A+Math.imul($,Be)|0,g=g+Math.imul($,ke)|0,g=g+Math.imul(V,Be)|0,R=R+Math.imul(V,ke)|0;var sn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(sn>>>26)|0,sn&=67108863,A=Math.imul(le,_e),g=Math.imul(le,xe),g=g+Math.imul(pe,_e)|0,R=Math.imul(pe,xe),A=A+Math.imul(ue,Ee)|0,g=g+Math.imul(ue,Se)|0,g=g+Math.imul(de,Ee)|0,R=R+Math.imul(de,Se)|0,A=A+Math.imul(ce,Ie)|0,g=g+Math.imul(ce,Me)|0,g=g+Math.imul(he,Ie)|0,R=R+Math.imul(he,Me)|0,A=A+Math.imul(ae,Ae)|0,g=g+Math.imul(ae,Re)|0,g=g+Math.imul(fe,Ae)|0,R=R+Math.imul(fe,Re)|0,A=A+Math.imul(se,Te)|0,g=g+Math.imul(se,De)|0,g=g+Math.imul(oe,Te)|0,R=R+Math.imul(oe,De)|0,A=A+Math.imul(ie,Pe)|0,g=g+Math.imul(ie,Ne)|0,g=g+Math.imul(ne,Pe)|0,R=R+Math.imul(ne,Ne)|0,A=A+Math.imul(G,Be)|0,g=g+Math.imul(G,ke)|0,g=g+Math.imul(Y,Be)|0,R=R+Math.imul(Y,ke)|0;var on=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(on>>>26)|0,on&=67108863,A=Math.imul(le,Ee),g=Math.imul(le,Se),g=g+Math.imul(pe,Ee)|0,R=Math.imul(pe,Se),A=A+Math.imul(ue,Ie)|0,g=g+Math.imul(ue,Me)|0,g=g+Math.imul(de,Ie)|0,R=R+Math.imul(de,Me)|0,A=A+Math.imul(ce,Ae)|0,g=g+Math.imul(ce,Re)|0,g=g+Math.imul(he,Ae)|0,R=R+Math.imul(he,Re)|0,A=A+Math.imul(ae,Te)|0,g=g+Math.imul(ae,De)|0,g=g+Math.imul(fe,Te)|0,R=R+Math.imul(fe,De)|0,A=A+Math.imul(se,Pe)|0,g=g+Math.imul(se,Ne)|0,g=g+Math.imul(oe,Pe)|0,R=R+Math.imul(oe,Ne)|0,A=A+Math.imul(ie,Be)|0,g=g+Math.imul(ie,ke)|0,g=g+Math.imul(ne,Be)|0,R=R+Math.imul(ne,ke)|0;var an=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(an>>>26)|0,an&=67108863,A=Math.imul(le,Ie),g=Math.imul(le,Me),g=g+Math.imul(pe,Ie)|0,R=Math.imul(pe,Me),A=A+Math.imul(ue,Ae)|0,g=g+Math.imul(ue,Re)|0,g=g+Math.imul(de,Ae)|0,R=R+Math.imul(de,Re)|0,A=A+Math.imul(ce,Te)|0,g=g+Math.imul(ce,De)|0,g=g+Math.imul(he,Te)|0,R=R+Math.imul(he,De)|0,A=A+Math.imul(ae,Pe)|0,g=g+Math.imul(ae,Ne)|0,g=g+Math.imul(fe,Pe)|0,R=R+Math.imul(fe,Ne)|0,A=A+Math.imul(se,Be)|0,g=g+Math.imul(se,ke)|0,g=g+Math.imul(oe,Be)|0,R=R+Math.imul(oe,ke)|0;var fn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fn>>>26)|0,fn&=67108863,A=Math.imul(le,Ae),g=Math.imul(le,Re),g=g+Math.imul(pe,Ae)|0,R=Math.imul(pe,Re),A=A+Math.imul(ue,Te)|0,g=g+Math.imul(ue,De)|0,g=g+Math.imul(de,Te)|0,R=R+Math.imul(de,De)|0,A=A+Math.imul(ce,Pe)|0,g=g+Math.imul(ce,Ne)|0,g=g+Math.imul(he,Pe)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(ae,Be)|0,g=g+Math.imul(ae,ke)|0,g=g+Math.imul(fe,Be)|0,R=R+Math.imul(fe,ke)|0;var cn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cn>>>26)|0,cn&=67108863,A=Math.imul(le,Te),g=Math.imul(le,De),g=g+Math.imul(pe,Te)|0,R=Math.imul(pe,De),A=A+Math.imul(ue,Pe)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(de,Pe)|0,R=R+Math.imul(de,Ne)|0,A=A+Math.imul(ce,Be)|0,g=g+Math.imul(ce,ke)|0,g=g+Math.imul(he,Be)|0,R=R+Math.imul(he,ke)|0;var fc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fc>>>26)|0,fc&=67108863,A=Math.imul(le,Pe),g=Math.imul(le,Ne),g=g+Math.imul(pe,Pe)|0,R=Math.imul(pe,Ne),A=A+Math.imul(ue,Be)|0,g=g+Math.imul(ue,ke)|0,g=g+Math.imul(de,Be)|0,R=R+Math.imul(de,ke)|0;var cc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cc>>>26)|0,cc&=67108863,A=Math.imul(le,Be),g=Math.imul(le,ke),g=g+Math.imul(pe,Be)|0,R=Math.imul(pe,ke);var hc=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(hc>>>26)|0,hc&=67108863,c[0]=jt,c[1]=Vt,c[2]=$t,c[3]=Ht,c[4]=Gt,c[5]=Zi,c[6]=Qi,c[7]=en,c[8]=tn,c[9]=rn,c[10]=nn,c[11]=sn,c[12]=on,c[13]=an,c[14]=fn,c[15]=cn,c[16]=fc,c[17]=cc,c[18]=hc,x!==0&&(c[19]=x,v.length++),v};Math.imul||(P=C);function U(p,a,u){u.negative=a.negative^p.negative,u.length=p.length+a.length;for(var v=0,_=0,m=0;m>>26)|0,_+=c>>>26,c&=67108863}u.words[m]=x,v=c,c=_}return v!==0?u.words[m]=v:u.length--,u._strip()}function B(p,a,u){return U(p,a,u)}n.prototype.mulTo=function(a,u){var v,_=this.length+a.length;return this.length===10&&a.length===10?v=P(this,a,u):_<63?v=C(this,a,u):_<1024?v=U(this,a,u):v=B(this,a,u),v};function z(p,a){this.x=p,this.y=a}z.prototype.makeRBT=function(a){for(var u=new Array(a),v=n.prototype._countBits(a)-1,_=0;_>=1;return _},z.prototype.permute=function(a,u,v,_,m,c){for(var x=0;x>>1)m++;return 1<>>13,v[2*c+1]=m&8191,m=m>>>13;for(c=2*u;c<_;++c)v[c]=0;t(m===0),t((m&-8192)===0)},z.prototype.stub=function(a){for(var u=new Array(a),v=0;v>=26,v+=m/67108864|0,v+=c>>>26,this.words[_]=c&67108863}return v!==0&&(this.words[_]=v,this.length++),u?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var u=T(a);if(u.length===0)return new n(1);for(var v=this,_=0;_=0);var u=a%26,v=(a-u)/26,_=67108863>>>26-u<<26-u,m;if(u!==0){var c=0;for(m=0;m>>26-u}c&&(this.words[m]=c,this.length++)}if(v!==0){for(m=this.length-1;m>=0;m--)this.words[m+v]=this.words[m];for(m=0;m=0);var _;u?_=(u-u%26)/26:_=0;var m=a%26,c=Math.min((a-m)/26,this.length),x=67108863^67108863>>>m<c)for(this.length-=c,g=0;g=0&&(R!==0||g>=_);g--){var k=this.words[g]|0;this.words[g]=R<<26-m|k>>>m,R=k&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,u,v){return t(this.negative===0),this.iushrn(a,u,v)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var u=a%26,v=(a-u)/26,_=1<=0);var u=a%26,v=(a-u)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=v)return this;if(u!==0&&v++,this.length=Math.min(v,this.length),u!==0){var _=67108863^67108863>>>u<=67108864;u++)this.words[u]-=67108864,u===this.length-1?this.words[u+1]=1:this.words[u+1]++;return this.length=Math.max(this.length,u+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var u=0;u>26)-(A/67108864|0),this.words[m+v]=c&67108863}for(;m>26,this.words[m+v]=c&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,m=0;m>26,this.words[m]=c&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,u){var v=this.length-a.length,_=this.clone(),m=a,c=m.words[m.length-1]|0,x=this._countBits(c);v=26-x,v!==0&&(m=m.ushln(v),_.iushln(v),c=m.words[m.length-1]|0);var A=_.length-m.length,g;if(u!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var N=(_.words[m.length+E]|0)*67108864+(_.words[m.length+E-1]|0);for(N=Math.min(N/c|0,67108863),_._ishlnsubmul(m,N,E);_.negative!==0;)N--,_.negative=0,_._ishlnsubmul(m,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=N)}return g&&g._strip(),_._strip(),u!=="div"&&v!==0&&_.iushrn(v),{div:g||null,mod:_}},n.prototype.divmod=function(a,u,v){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,m,c;return this.negative!==0&&a.negative===0?(c=this.neg().divmod(a,u),u!=="mod"&&(_=c.div.neg()),u!=="div"&&(m=c.mod.neg(),v&&m.negative!==0&&m.iadd(a)),{div:_,mod:m}):this.negative===0&&a.negative!==0?(c=this.divmod(a.neg(),u),u!=="mod"&&(_=c.div.neg()),{div:_,mod:c.mod}):this.negative&a.negative?(c=this.neg().divmod(a.neg(),u),u!=="div"&&(m=c.mod.neg(),v&&m.negative!==0&&m.isub(a)),{div:c.div,mod:m}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?u==="div"?{div:this.divn(a.words[0]),mod:null}:u==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,u)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var u=this.divmod(a);if(u.mod.isZero())return u.div;var v=u.div.negative!==0?u.mod.isub(a):u.mod,_=a.ushrn(1),m=a.andln(1),c=v.cmp(_);return c<0||m===1&&c===0?u.div:u.div.negative!==0?u.div.isubn(1):u.div.iaddn(1)},n.prototype.modrn=function(a){var u=a<0;u&&(a=-a),t(a<=67108863);for(var v=(1<<26)%a,_=0,m=this.length-1;m>=0;m--)_=(v*_+(this.words[m]|0))%a;return u?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var u=a<0;u&&(a=-a),t(a<=67108863);for(var v=0,_=this.length-1;_>=0;_--){var m=(this.words[_]|0)+v*67108864;this.words[_]=m/a|0,v=m%a}return this._strip(),u?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var u=this,v=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var _=new n(1),m=new n(0),c=new n(0),x=new n(1),A=0;u.isEven()&&v.isEven();)u.iushrn(1),v.iushrn(1),++A;for(var g=v.clone(),R=u.clone();!u.isZero();){for(var k=0,E=1;!(u.words[0]&E)&&k<26;++k,E<<=1);if(k>0)for(u.iushrn(k);k-- >0;)(_.isOdd()||m.isOdd())&&(_.iadd(g),m.isub(R)),_.iushrn(1),m.iushrn(1);for(var N=0,F=1;!(v.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(v.iushrn(N);N-- >0;)(c.isOdd()||x.isOdd())&&(c.iadd(g),x.isub(R)),c.iushrn(1),x.iushrn(1);u.cmp(v)>=0?(u.isub(v),_.isub(c),m.isub(x)):(v.isub(u),c.isub(_),x.isub(m))}return{a:c,b:x,gcd:v.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var u=this,v=a.clone();u.negative!==0?u=u.umod(a):u=u.clone();for(var _=new n(1),m=new n(0),c=v.clone();u.cmpn(1)>0&&v.cmpn(1)>0;){for(var x=0,A=1;!(u.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(u.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(c),_.iushrn(1);for(var g=0,R=1;!(v.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(v.iushrn(g);g-- >0;)m.isOdd()&&m.iadd(c),m.iushrn(1);u.cmp(v)>=0?(u.isub(v),_.isub(m)):(v.isub(u),m.isub(_))}var k;return u.cmpn(1)===0?k=_:k=m,k.cmpn(0)<0&&k.iadd(a),k},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var u=this.clone(),v=a.clone();u.negative=0,v.negative=0;for(var _=0;u.isEven()&&v.isEven();_++)u.iushrn(1),v.iushrn(1);do{for(;u.isEven();)u.iushrn(1);for(;v.isEven();)v.iushrn(1);var m=u.cmp(v);if(m<0){var c=u;u=v,v=c}else if(m===0||v.cmpn(1)===0)break;u.isub(v)}while(!0);return v.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var u=a%26,v=(a-u)/26,_=1<>>26,x&=67108863,this.words[c]=x}return m!==0&&(this.words[c]=m,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var u=a<0;if(this.negative!==0&&!u)return-1;if(this.negative===0&&u)return 1;this._strip();var v;if(this.length>1)v=1;else{u&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;v=_===a?0:_a.length)return 1;if(this.length=0;v--){var _=this.words[v]|0,m=a.words[v]|0;if(_!==m){_m&&(u=1);break}}return u},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var j={k256:null,p224:null,p192:null,p25519:null};function H(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var u=a,v;do this.split(u,this.tmp),u=this.imulK(u),u=u.iadd(this.tmp),v=u.bitLength();while(v>this.n);var _=v0?u.isub(this.p):u.strip!==void 0?u.strip():u._strip(),u},H.prototype.split=function(a,u){a.iushrn(this.n,0,u)},H.prototype.imulK=function(a){return a.imul(this.k)};function L(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,H),L.prototype.split=function(a,u){for(var v=4194303,_=Math.min(a.length,9),m=0;m<_;m++)u.words[m]=a.words[m];if(u.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var c=a.words[9];for(u.words[u.length++]=c&v,m=10;m>>22,c=x}c>>>=22,a.words[m-10]=c,c===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var u=0,v=0;v>>=26,a.words[v]=m,u=_}return u!==0&&(a.words[a.length++]=u),a},n._prime=function(a){if(j[a])return j[a];var u;if(a==="k256")u=new L;else if(a==="p224")u=new O;else if(a==="p192")u=new W;else if(a==="p25519")u=new D;else throw new Error("Unknown prime "+a);return j[a]=u,u};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,u){t((a.negative|u.negative)===0,"red works only with positives"),t(a.red&&a.red===u.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(h(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,u){this._verify2(a,u);var v=a.add(u);return v.cmp(this.m)>=0&&v.isub(this.m),v._forceRed(this)},l.prototype.iadd=function(a,u){this._verify2(a,u);var v=a.iadd(u);return v.cmp(this.m)>=0&&v.isub(this.m),v},l.prototype.sub=function(a,u){this._verify2(a,u);var v=a.sub(u);return v.cmpn(0)<0&&v.iadd(this.m),v._forceRed(this)},l.prototype.isub=function(a,u){this._verify2(a,u);var v=a.isub(u);return v.cmpn(0)<0&&v.iadd(this.m),v},l.prototype.shl=function(a,u){return this._verify1(a),this.imod(a.ushln(u))},l.prototype.imul=function(a,u){return this._verify2(a,u),this.imod(a.imul(u))},l.prototype.mul=function(a,u){return this._verify2(a,u),this.imod(a.mul(u))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var u=this.m.andln(3);if(t(u%2===1),u===3){var v=this.m.add(new n(1)).iushrn(2);return this.pow(a,v)}for(var _=this.m.subn(1),m=0;!_.isZero()&&_.andln(1)===0;)m++,_.iushrn(1);t(!_.isZero());var c=new n(1).toRed(this),x=c.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),k=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),N=m;E.cmp(c)!==0;){for(var F=E,q=0;F.cmp(c)!==0;q++)F=F.redSqr();t(q=0;m--){for(var R=u.words[m],k=g-1;k>=0;k--){var E=R>>k&1;if(c!==_[0]&&(c=this.sqr(c)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==v&&(m!==0||k!==0))&&(c=this.mul(c,_[x]),A=0,x=0)}g=26}return c},l.prototype.convertTo=function(a){var u=a.umod(this.m);return u===a?u.clone():u},l.prototype.convertFrom=function(a){var u=a.clone();return u.red=null,u},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var u=this.imod(a.mul(this.rinv));return u.red=null,u},w.prototype.imul=function(a,u){if(a.isZero()||u.isZero())return a.words[0]=0,a.length=1,a;var v=a.imul(u),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),c=m;return m.cmp(this.m)>=0?c=m.isub(this.m):m.cmpn(0)<0&&(c=m.iadd(this.m)),c._forceRed(this)},w.prototype.mul=function(a,u){if(a.isZero()||u.isZero())return new n(0)._forceRed(this);var v=a.mul(u),_=v.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),m=v.isub(_).iushrn(this.shift),c=m;return m.cmp(this.m)>=0?c=m.isub(this.m):m.cmpn(0)<0&&(c=m.iadd(this.m)),c._forceRed(this)},w.prototype.invm=function(a){var u=this.imod(a._invmp(this.m).mul(this.r2));return u._forceRed(this)}})(typeof Dh>"u"||Dh,Gp)});var Di=Z((UA,o1)=>{o1.exports=s1;function s1(r,e){if(!r)throw new Error(e||"Assertion failed")}s1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var co=Z((zA,Oh)=>{typeof Object.create=="function"?Oh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Oh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var fr=Z(Ve=>{"use strict";var jw=Di(),Vw=co();Ve.inherits=Vw;function $w(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Hw(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):$w(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ve.htonl=a1;function Ww(r,e){for(var t="",i=0;i>>0}return s}Ve.join32=Jw;function Yw(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ve.split32=Yw;function Xw(r,e){return r>>>e|r<<32-e}Ve.rotr32=Xw;function Zw(r,e){return r<>>32-e}Ve.rotl32=Zw;function Qw(r,e){return r+e>>>0}Ve.sum32=Qw;function e5(r,e,t){return r+e+t>>>0}Ve.sum32_3=e5;function t5(r,e,t,i){return r+e+t+i>>>0}Ve.sum32_4=t5;function r5(r,e,t,i,n){return r+e+t+i+n>>>0}Ve.sum32_5=r5;function i5(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}Ve.sum64=i5;function n5(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ve.sum64_hi=n5;function s5(r,e,t,i){var n=e+i;return n>>>0}Ve.sum64_lo=s5;function o5(r,e,t,i,n,s,o,f){var d=0,h=e;h=h+i>>>0,d+=h>>0,d+=h>>0,d+=h>>0}Ve.sum64_4_hi=o5;function a5(r,e,t,i,n,s,o,f){var d=e+i+s+f;return d>>>0}Ve.sum64_4_lo=a5;function f5(r,e,t,i,n,s,o,f,d,h){var b=0,y=e;y=y+i>>>0,b+=y>>0,b+=y>>0,b+=y>>0,b+=y>>0}Ve.sum64_5_hi=f5;function c5(r,e,t,i,n,s,o,f,d,h){var b=e+i+s+f+h;return b>>>0}Ve.sum64_5_lo=c5;function h5(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ve.rotr64_hi=h5;function u5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.rotr64_lo=u5;function d5(r,e,t){return r>>>t}Ve.shr64_hi=d5;function l5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.shr64_lo=l5});var os=Z(u1=>{"use strict";var h1=fr(),p5=Di();function Ga(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}u1.BlockHash=Ga;Ga.prototype.update=function(e,t){if(e=h1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=h1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var g5=fr(),zr=g5.rotr32;function b5(r,e,t,i){if(r===0)return d1(e,t,i);if(r===1||r===3)return p1(e,t,i);if(r===2)return l1(e,t,i)}ui.ft_1=b5;function d1(r,e,t){return r&e^~r&t}ui.ch32=d1;function l1(r,e,t){return r&e^r&t^e&t}ui.maj32=l1;function p1(r,e,t){return r^e^t}ui.p32=p1;function v5(r){return zr(r,2)^zr(r,13)^zr(r,22)}ui.s0_256=v5;function m5(r){return zr(r,6)^zr(r,11)^zr(r,25)}ui.s1_256=m5;function y5(r){return zr(r,7)^zr(r,18)^r>>>3}ui.g0_256=y5;function w5(r){return zr(r,17)^zr(r,19)^r>>>10}ui.g1_256=w5});var v1=Z((jA,b1)=>{"use strict";var as=fr(),_5=os(),x5=Lh(),Fh=as.rotl32,ho=as.sum32,E5=as.sum32_5,S5=x5.ft_1,g1=_5.BlockHash,I5=[1518500249,1859775393,2400959708,3395469782];function Br(){if(!(this instanceof Br))return new Br;g1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}as.inherits(Br,g1);b1.exports=Br;Br.blockSize=512;Br.outSize=160;Br.hmacStrength=80;Br.padLength=64;Br.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var fs=fr(),M5=os(),cs=Lh(),A5=Di(),cr=fs.sum32,R5=fs.sum32_4,T5=fs.sum32_5,D5=cs.ch32,P5=cs.maj32,N5=cs.s0_256,C5=cs.s1_256,O5=cs.g0_256,L5=cs.g1_256,m1=M5.BlockHash,F5=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function kr(){if(!(this instanceof kr))return new kr;m1.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=F5,this.W=new Array(64)}fs.inherits(kr,m1);y1.exports=kr;kr.blockSize=512;kr.outSize=256;kr.hmacStrength=192;kr.padLength=64;kr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Uh=fr(),w1=qh();function di(){if(!(this instanceof di))return new di;w1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Uh.inherits(di,w1);_1.exports=di;di.blockSize=512;di.outSize=224;di.hmacStrength=192;di.padLength=64;di.prototype._digest=function(e){return e==="hex"?Uh.toHex32(this.h.slice(0,7),"big"):Uh.split32(this.h.slice(0,7),"big")}});var kh=Z((HA,M1)=>{"use strict";var Ot=fr(),q5=os(),U5=Di(),Kr=Ot.rotr64_hi,jr=Ot.rotr64_lo,E1=Ot.shr64_hi,S1=Ot.shr64_lo,Pi=Ot.sum64,zh=Ot.sum64_hi,Bh=Ot.sum64_lo,z5=Ot.sum64_4_hi,B5=Ot.sum64_4_lo,k5=Ot.sum64_5_hi,K5=Ot.sum64_5_lo,I1=q5.BlockHash,j5=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function hr(){if(!(this instanceof hr))return new hr;I1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=j5,this.W=new Array(160)}Ot.inherits(hr,I1);M1.exports=hr;hr.blockSize=1024;hr.outSize=512;hr.hmacStrength=192;hr.padLength=128;hr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Kh=fr(),A1=kh();function li(){if(!(this instanceof li))return new li;A1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Kh.inherits(li,A1);R1.exports=li;li.blockSize=1024;li.outSize=384;li.hmacStrength=192;li.padLength=128;li.prototype._digest=function(e){return e==="hex"?Kh.toHex32(this.h.slice(0,12),"big"):Kh.split32(this.h.slice(0,12),"big")}});var D1=Z(hs=>{"use strict";hs.sha1=v1();hs.sha224=x1();hs.sha256=qh();hs.sha384=T1();hs.sha512=kh()});var F1=Z(L1=>{"use strict";var wn=fr(),r8=os(),Wa=wn.rotl32,P1=wn.sum32,uo=wn.sum32_3,N1=wn.sum32_4,O1=r8.BlockHash;function Vr(){if(!(this instanceof Vr))return new Vr;O1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}wn.inherits(Vr,O1);L1.ripemd160=Vr;Vr.blockSize=512;Vr.outSize=160;Vr.hmacStrength=192;Vr.padLength=64;Vr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],d=i,h=n,b=s,y=o,S=f,I=0;I<80;I++){var M=P1(Wa(N1(i,C1(I,n,s,o),e[s8[I]+t],i8(I)),a8[I]),f);i=f,f=o,o=Wa(s,10),s=n,n=M,M=P1(Wa(N1(d,C1(79-I,h,b,y),e[o8[I]+t],n8(I)),f8[I]),S),d=S,S=y,y=Wa(b,10),b=h,h=M}M=uo(this.h[1],s,y),this.h[1]=uo(this.h[2],o,S),this.h[2]=uo(this.h[3],f,d),this.h[3]=uo(this.h[4],i,h),this.h[4]=uo(this.h[0],n,b),this.h[0]=M};Vr.prototype._digest=function(e){return e==="hex"?wn.toHex32(this.h,"little"):wn.split32(this.h,"little")};function C1(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function i8(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function n8(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var s8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o8=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],a8=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f8=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var U1=Z((YA,q1)=>{"use strict";var c8=fr(),h8=Di();function us(r,e,t){if(!(this instanceof us))return new us(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(c8.toArray(e,t))}q1.exports=us;us.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),h8(e.length<=this.blockSize);for(var t=e.length;t{var pt=z1;pt.utils=fr();pt.common=os();pt.sha=D1();pt.ripemd=F1();pt.hmac=U1();pt.sha1=pt.sha.sha1;pt.sha256=pt.sha.sha256;pt.sha224=pt.sha.sha224;pt.sha384=pt.sha.sha384;pt.sha512=pt.sha.sha512;pt.ripemd160=pt.ripemd.ripemd160});var X1=Z(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var Et=Hn(),Qh=Jt(),_8=20;function x8(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],d=t[7]<<24|t[6]<<16|t[5]<<8|t[4],h=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],C=e[7]<<24|e[6]<<16|e[5]<<8|e[4],P=e[11]<<24|e[10]<<16|e[9]<<8|e[8],U=e[15]<<24|e[14]<<16|e[13]<<8|e[12],B=i,z=n,j=s,H=o,L=f,O=d,W=h,D=b,l=y,w=S,p=I,a=M,u=T,v=C,_=P,m=U,c=0;c<_8;c+=2)B=B+L|0,u^=B,u=u>>>16|u<<16,l=l+u|0,L^=l,L=L>>>20|L<<12,z=z+O|0,v^=z,v=v>>>16|v<<16,w=w+v|0,O^=w,O=O>>>20|O<<12,j=j+W|0,_^=j,_=_>>>16|_<<16,p=p+_|0,W^=p,W=W>>>20|W<<12,H=H+D|0,m^=H,m=m>>>16|m<<16,a=a+m|0,D^=a,D=D>>>20|D<<12,j=j+W|0,_^=j,_=_>>>24|_<<8,p=p+_|0,W^=p,W=W>>>25|W<<7,H=H+D|0,m^=H,m=m>>>24|m<<8,a=a+m|0,D^=a,D=D>>>25|D<<7,z=z+O|0,v^=z,v=v>>>24|v<<8,w=w+v|0,O^=w,O=O>>>25|O<<7,B=B+L|0,u^=B,u=u>>>24|u<<8,l=l+u|0,L^=l,L=L>>>25|L<<7,B=B+O|0,m^=B,m=m>>>16|m<<16,p=p+m|0,O^=p,O=O>>>20|O<<12,z=z+W|0,u^=z,u=u>>>16|u<<16,a=a+u|0,W^=a,W=W>>>20|W<<12,j=j+D|0,v^=j,v=v>>>16|v<<16,l=l+v|0,D^=l,D=D>>>20|D<<12,H=H+L|0,_^=H,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,j=j+D|0,v^=j,v=v>>>24|v<<8,l=l+v|0,D^=l,D=D>>>25|D<<7,H=H+L|0,_^=H,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,z=z+W|0,u^=z,u=u>>>24|u<<8,a=a+u|0,W^=a,W=W>>>25|W<<7,B=B+O|0,m^=B,m=m>>>24|m<<8,p=p+m|0,O^=p,O=O>>>25|O<<7;Et.writeUint32LE(B+i|0,r,0),Et.writeUint32LE(z+n|0,r,4),Et.writeUint32LE(j+s|0,r,8),Et.writeUint32LE(H+o|0,r,12),Et.writeUint32LE(L+f|0,r,16),Et.writeUint32LE(O+d|0,r,20),Et.writeUint32LE(W+h|0,r,24),Et.writeUint32LE(D+b|0,r,28),Et.writeUint32LE(l+y|0,r,32),Et.writeUint32LE(w+S|0,r,36),Et.writeUint32LE(p+I|0,r,40),Et.writeUint32LE(a+M|0,r,44),Et.writeUint32LE(u+T|0,r,48),Et.writeUint32LE(v+C|0,r,52),Et.writeUint32LE(_+P|0,r,56),Et.writeUint32LE(m+U|0,r,60)}function Y1(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var rf=Z(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});function I8(r,e,t){return~(r-1)&e|r-1&t}ls.select=I8;function M8(r,e){return(r|0)-(e|0)-1>>>31&1}ls.lessOrEqual=M8;function Z1(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}ls.compare=Z1;function A8(r,e){return r.length===0||e.length===0?!1:Z1(r,e)!==0}ls.equal=A8});var eg=Z(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var R8=rf(),nf=Jt();pi.DIGEST_LENGTH=16;var Q1=function(){function r(e){this.digestLength=pi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var d=e[12]|e[13]<<8;this._r[7]=(f>>>11|d<<5)&8065;var h=e[14]|e[15]<<8;this._r[8]=(d>>>8|h<<8)&8191,this._r[9]=h>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],d=this._h[3],h=this._h[4],b=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],C=this._r[1],P=this._r[2],U=this._r[3],B=this._r[4],z=this._r[5],j=this._r[6],H=this._r[7],L=this._r[8],O=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var D=e[t+2]|e[t+3]<<8;o+=(W>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;d+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;h+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;y+=(p>>>14|a<<2)&8191;var u=e[t+12]|e[t+13]<<8;S+=(a>>>11|u<<5)&8191;var v=e[t+14]|e[t+15]<<8;I+=(u>>>8|v<<8)&8191,M+=v>>>5|n;var _=0,m=_;m+=s*T,m+=o*(5*O),m+=f*(5*L),m+=d*(5*H),m+=h*(5*j),_=m>>>13,m&=8191,m+=b*(5*z),m+=y*(5*B),m+=S*(5*U),m+=I*(5*P),m+=M*(5*C),_+=m>>>13,m&=8191;var c=_;c+=s*C,c+=o*T,c+=f*(5*O),c+=d*(5*L),c+=h*(5*H),_=c>>>13,c&=8191,c+=b*(5*j),c+=y*(5*z),c+=S*(5*B),c+=I*(5*U),c+=M*(5*P),_+=c>>>13,c&=8191;var x=_;x+=s*P,x+=o*C,x+=f*T,x+=d*(5*O),x+=h*(5*L),_=x>>>13,x&=8191,x+=b*(5*H),x+=y*(5*j),x+=S*(5*z),x+=I*(5*B),x+=M*(5*U),_+=x>>>13,x&=8191;var A=_;A+=s*U,A+=o*P,A+=f*C,A+=d*T,A+=h*(5*O),_=A>>>13,A&=8191,A+=b*(5*L),A+=y*(5*H),A+=S*(5*j),A+=I*(5*z),A+=M*(5*B),_+=A>>>13,A&=8191;var g=_;g+=s*B,g+=o*U,g+=f*P,g+=d*C,g+=h*T,_=g>>>13,g&=8191,g+=b*(5*O),g+=y*(5*L),g+=S*(5*H),g+=I*(5*j),g+=M*(5*z),_+=g>>>13,g&=8191;var R=_;R+=s*z,R+=o*B,R+=f*U,R+=d*P,R+=h*C,_=R>>>13,R&=8191,R+=b*T,R+=y*(5*O),R+=S*(5*L),R+=I*(5*H),R+=M*(5*j),_+=R>>>13,R&=8191;var k=_;k+=s*j,k+=o*z,k+=f*B,k+=d*U,k+=h*P,_=k>>>13,k&=8191,k+=b*C,k+=y*T,k+=S*(5*O),k+=I*(5*L),k+=M*(5*H),_+=k>>>13,k&=8191;var E=_;E+=s*H,E+=o*j,E+=f*z,E+=d*B,E+=h*U,_=E>>>13,E&=8191,E+=b*P,E+=y*C,E+=S*T,E+=I*(5*O),E+=M*(5*L),_+=E>>>13,E&=8191;var N=_;N+=s*L,N+=o*H,N+=f*j,N+=d*z,N+=h*B,_=N>>>13,N&=8191,N+=b*U,N+=y*P,N+=S*C,N+=I*T,N+=M*(5*O),_+=N>>>13,N&=8191;var F=_;F+=s*O,F+=o*L,F+=f*H,F+=d*j,F+=h*z,_=F>>>13,F&=8191,F+=b*B,F+=y*U,F+=S*P,F+=I*C,F+=M*T,_+=F>>>13,F&=8191,_=(_<<2)+_|0,_=_+m|0,m=_&8191,_=_>>>13,c+=_,s=m,o=c,f=x,d=A,h=g,b=R,y=k,S=E,I=N,M=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=d,this._h[4]=h,this._h[5]=b,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});var sf=X1(),P8=eg(),po=Jt(),tg=Hn(),N8=rf();gi.KEY_LENGTH=32;gi.NONCE_LENGTH=12;gi.TAG_LENGTH=16;var rg=new Uint8Array(16),C8=function(){function r(e){if(this.nonceLength=gi.NONCE_LENGTH,this.tagLength=gi.TAG_LENGTH,e.length!==gi.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);sf.stream(this._key,s,o,4);var f=t.length+this.tagLength,d;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");d=n}else d=new Uint8Array(f);return sf.streamXOR(this._key,s,t,d,4),this._authenticate(d.subarray(d.length-this.tagLength,d.length),o,d.subarray(0,d.length-this.tagLength),i),po.wipe(s),d},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(rg.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(rg.subarray(i.length%16));var o=new Uint8Array(8);n&&tg.writeUint64LE(n.length,o),s.update(o),tg.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),d=0;d{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});function O8(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}eu.isSerializableHash=O8});var og=Z(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Gr=ng(),L8=rf(),F8=Jt(),sg=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ag=og(),fg=Jt(),U8=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ag.hmac(this._hash,i,t);this._hmac=new ag.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Oi,"__esModule",{value:!0});var af=Hn(),of=Jt();Oi.DIGEST_LENGTH=32;Oi.BLOCK_SIZE=64;var hg=function(){function r(){this.digestLength=Oi.DIGEST_LENGTH,this.blockSize=Oi.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){of.wipe(this._buffer),of.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ru(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ru(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){of.wipe(e.state),e.buffer&&of.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Oi.SHA256=hg;var z8=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ru(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],d=e[3],h=e[4],b=e[5],y=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=af.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],C=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var P=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(C+r[I-7]|0)+(P+r[I-16]|0)}for(var I=0;I<64;I++){var C=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&b^~h&y)|0)+(S+(z8[I]+r[I]|0)|0)|0,P=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=y,y=b,b=h,h=d+C|0,d=f,f=o,o=s,s=C+P|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=d,e[4]+=h,e[5]+=b,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function B8(r){var e=new hg;e.update(r);var t=e.digest();return e.clean(),t}Oi.hash=B8});var gg=Z(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.sharedKey=Qe.generateKeyPair=Qe.generateKeyPairFromSeed=Qe.scalarMultBase=Qe.scalarMult=Qe.SHARED_KEY_LENGTH=Qe.SECRET_KEY_LENGTH=Qe.PUBLIC_KEY_LENGTH=void 0;var k8=Js(),K8=Jt();Qe.PUBLIC_KEY_LENGTH=32;Qe.SECRET_KEY_LENGTH=32;Qe.SHARED_KEY_LENGTH=32;function Wr(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function $8(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ff(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function cf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function bi(r,e,t){let i,n,s=0,o=0,f=0,d=0,h=0,b=0,y=0,S=0,I=0,M=0,T=0,C=0,P=0,U=0,B=0,z=0,j=0,H=0,L=0,O=0,W=0,D=0,l=0,w=0,p=0,a=0,u=0,v=0,_=0,m=0,c=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,d+=i*R,h+=i*k,b+=i*E,y+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,C+=i*$,P+=i*V,U+=i*ee,B+=i*G,z+=i*Y,i=e[1],o+=i*x,f+=i*A,d+=i*g,h+=i*R,b+=i*k,y+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,C+=i*J,P+=i*$,U+=i*V,B+=i*ee,z+=i*G,j+=i*Y,i=e[2],f+=i*x,d+=i*A,h+=i*g,b+=i*R,y+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,C+=i*K,P+=i*J,U+=i*$,B+=i*V,z+=i*ee,j+=i*G,H+=i*Y,i=e[3],d+=i*x,h+=i*A,b+=i*g,y+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,C+=i*q,P+=i*K,U+=i*J,B+=i*$,z+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],h+=i*x,b+=i*A,y+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,C+=i*F,P+=i*q,U+=i*K,B+=i*J,z+=i*$,j+=i*V,H+=i*ee,L+=i*G,O+=i*Y,i=e[5],b+=i*x,y+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,C+=i*N,P+=i*F,U+=i*q,B+=i*K,z+=i*J,j+=i*$,H+=i*V,L+=i*ee,O+=i*G,W+=i*Y,i=e[6],y+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,C+=i*E,P+=i*N,U+=i*F,B+=i*q,z+=i*K,j+=i*J,H+=i*$,L+=i*V,O+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,C+=i*k,P+=i*E,U+=i*N,B+=i*F,z+=i*q,j+=i*K,H+=i*J,L+=i*$,O+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,C+=i*R,P+=i*k,U+=i*E,B+=i*N,z+=i*F,j+=i*q,H+=i*K,L+=i*J,O+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,C+=i*g,P+=i*R,U+=i*k,B+=i*E,z+=i*N,j+=i*F,H+=i*q,L+=i*K,O+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,C+=i*A,P+=i*g,U+=i*R,B+=i*k,z+=i*E,j+=i*N,H+=i*F,L+=i*q,O+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],C+=i*x,P+=i*A,U+=i*g,B+=i*R,z+=i*k,j+=i*E,H+=i*N,L+=i*F,O+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,u+=i*Y,i=e[12],P+=i*x,U+=i*A,B+=i*g,z+=i*R,j+=i*k,H+=i*E,L+=i*N,O+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,u+=i*G,v+=i*Y,i=e[13],U+=i*x,B+=i*A,z+=i*g,j+=i*R,H+=i*k,L+=i*E,O+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,u+=i*ee,v+=i*G,_+=i*Y,i=e[14],B+=i*x,z+=i*A,j+=i*g,H+=i*R,L+=i*k,O+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,u+=i*V,v+=i*ee,_+=i*G,m+=i*Y,i=e[15],z+=i*x,j+=i*A,H+=i*g,L+=i*R,O+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,u+=i*$,v+=i*V,_+=i*ee,m+=i*G,c+=i*Y,s+=38*j,o+=38*H,f+=38*L,d+=38*O,h+=38*W,b+=38*D,y+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*u,C+=38*v,P+=38*_,U+=38*m,B+=38*c,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=d+n+65535,n=Math.floor(i/65536),d=i-n*65536,i=h+n+65535,n=Math.floor(i/65536),h=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=C+n+65535,n=Math.floor(i/65536),C=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=d,r[4]=h,r[5]=b,r[6]=y,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=C,r[12]=P,r[13]=U,r[14]=B,r[15]=z}function vo(r,e){bi(r,e,e)}function H8(r,e){let t=Wr();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)vo(t,t),i!==2&&i!==4&&bi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function nu(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=Wr(),s=Wr(),o=Wr(),f=Wr(),d=Wr(),h=Wr();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,$8(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;bo(n,s,M),bo(o,f,M),ff(d,n,o),cf(n,n,o),ff(o,s,f),cf(s,s,f),vo(f,d),vo(h,n),bi(n,o,n),bi(o,s,d),ff(d,n,o),cf(n,n,o),vo(s,n),cf(o,f,h),bi(n,o,j8),ff(n,n,f),bi(o,o,n),bi(n,f,h),bi(f,s,i),vo(s,d),bo(n,s,M),bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),y=i.subarray(16);H8(b,b),bi(y,y,b);let S=new Uint8Array(32);return V8(S,y),S}Qe.scalarMult=nu;function lg(r){return nu(r,dg)}Qe.scalarMultBase=lg;function pg(r){if(r.length!==Qe.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${Qe.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:lg(e),secretKey:e}}Qe.generateKeyPairFromSeed=pg;function G8(r){let e=(0,k8.randomBytes)(32,r),t=pg(e);return(0,K8.wipe)(e),t}Qe.generateKeyPair=G8;function W8(r,e,t=!1){if(r.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=nu(r,e);if(t){let n=0;for(let s=0;s{J8.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var Jr=Z((vg,su)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)v=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[u]|=v<<_&67108863,this.words[u+1]=v>>>26-_&67108863,_+=24,_>=26&&(_-=26,u++);else if(p==="le")for(a=0,u=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,u++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(u-=18,v+=1,this.words[v]|=_>>>26):u+=8;else{var m=l.length-w;for(a=m%2===0?w+1:w;a=18?(u-=18,v+=1,this.words[v]|=_>>>26):u+=8}this.strip()};function d(D,l,w,p){for(var a=0,u=Math.min(D.length,w),v=l;v=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,u=1;u<=67108863;u*=w)a++;a--,u=u/w|0;for(var v=l.length-p,_=v%a,m=Math.min(v,v-_)+p,c=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,u=0,v=0;v>>24-a&16777215,u!==0||v!==this.length-1?p=h[6-m.length]+m+p:p=m+p,a+=2,a>=26&&(a-=26,v--)}for(u!==0&&(p=u.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var c=b[l],x=y[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=h[c-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),u=p||Math.max(1,a);t(a<=u,"byte array longer than desired length"),t(u>0,"Requested array length <= 0"),this.strip();var v=w==="le",_=new l(u),m,c,x=this.clone();if(v){for(c=0;!x.isZero();c++)m=x.andln(255),x.iushrn(8),_[c]=m;for(;c=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var u=0,v=0;v>>26;for(;u!==0&&v>>26;if(this.length=p.length,u!==0)this.words[this.length]=u,this.length++;else if(p!==this)for(;vl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,u;p>0?(a=this,u=l):(a=l,u=this);for(var v=0,_=0;_>26,this.words[_]=w&67108863;for(;v!==0&&_>26,this.words[_]=w&67108863;if(v===0&&_>>26,A=m&67108863,g=Math.min(c,l.length-1),R=Math.max(0,c-D.length+1);R<=g;R++){var k=c-R|0;a=D.words[k]|0,u=l.words[R]|0,v=a*u+A,x+=v/67108864|0,A=v&67108863}w.words[c]=A|0,m=x|0}return m!==0?w.words[c]=m|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,u=w.words,v=p.words,_=0,m,c,x,A=a[0]|0,g=A&8191,R=A>>>13,k=a[1]|0,E=k&8191,N=k>>>13,F=a[2]|0,q=F&8191,K=F>>>13,J=a[3]|0,$=J&8191,V=J>>>13,ee=a[4]|0,G=ee&8191,Y=ee>>>13,_r=a[5]|0,ie=_r&8191,ne=_r>>>13,xr=a[6]|0,se=xr&8191,oe=xr>>>13,Er=a[7]|0,ae=Er&8191,fe=Er>>>13,Sr=a[8]|0,ce=Sr&8191,he=Sr>>>13,Ir=a[9]|0,ue=Ir&8191,de=Ir>>>13,Mr=u[0]|0,le=Mr&8191,pe=Mr>>>13,Ar=u[1]|0,ge=Ar&8191,be=Ar>>>13,Rr=u[2]|0,ve=Rr&8191,me=Rr>>>13,Tr=u[3]|0,ye=Tr&8191,we=Tr>>>13,Dr=u[4]|0,_e=Dr&8191,xe=Dr>>>13,Pr=u[5]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=u[6]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=u[7]|0,Ae=Cr&8191,Re=Cr>>>13,Or=u[8]|0,Te=Or&8191,De=Or>>>13,Lr=u[9]|0,Pe=Lr&8191,Ne=Lr>>>13;p.negative=l.negative^w.negative,p.length=19,m=Math.imul(g,le),c=Math.imul(g,pe),c=c+Math.imul(R,le)|0,x=Math.imul(R,pe);var nr=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(nr>>>26)|0,nr&=67108863,m=Math.imul(E,le),c=Math.imul(E,pe),c=c+Math.imul(N,le)|0,x=Math.imul(N,pe),m=m+Math.imul(g,ge)|0,c=c+Math.imul(g,be)|0,c=c+Math.imul(R,ge)|0,x=x+Math.imul(R,be)|0;var Be=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Be>>>26)|0,Be&=67108863,m=Math.imul(q,le),c=Math.imul(q,pe),c=c+Math.imul(K,le)|0,x=Math.imul(K,pe),m=m+Math.imul(E,ge)|0,c=c+Math.imul(E,be)|0,c=c+Math.imul(N,ge)|0,x=x+Math.imul(N,be)|0,m=m+Math.imul(g,ve)|0,c=c+Math.imul(g,me)|0,c=c+Math.imul(R,ve)|0,x=x+Math.imul(R,me)|0;var ke=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(ke>>>26)|0,ke&=67108863,m=Math.imul($,le),c=Math.imul($,pe),c=c+Math.imul(V,le)|0,x=Math.imul(V,pe),m=m+Math.imul(q,ge)|0,c=c+Math.imul(q,be)|0,c=c+Math.imul(K,ge)|0,x=x+Math.imul(K,be)|0,m=m+Math.imul(E,ve)|0,c=c+Math.imul(E,me)|0,c=c+Math.imul(N,ve)|0,x=x+Math.imul(N,me)|0,m=m+Math.imul(g,ye)|0,c=c+Math.imul(g,we)|0,c=c+Math.imul(R,ye)|0,x=x+Math.imul(R,we)|0;var jt=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(jt>>>26)|0,jt&=67108863,m=Math.imul(G,le),c=Math.imul(G,pe),c=c+Math.imul(Y,le)|0,x=Math.imul(Y,pe),m=m+Math.imul($,ge)|0,c=c+Math.imul($,be)|0,c=c+Math.imul(V,ge)|0,x=x+Math.imul(V,be)|0,m=m+Math.imul(q,ve)|0,c=c+Math.imul(q,me)|0,c=c+Math.imul(K,ve)|0,x=x+Math.imul(K,me)|0,m=m+Math.imul(E,ye)|0,c=c+Math.imul(E,we)|0,c=c+Math.imul(N,ye)|0,x=x+Math.imul(N,we)|0,m=m+Math.imul(g,_e)|0,c=c+Math.imul(g,xe)|0,c=c+Math.imul(R,_e)|0,x=x+Math.imul(R,xe)|0;var Vt=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,m=Math.imul(ie,le),c=Math.imul(ie,pe),c=c+Math.imul(ne,le)|0,x=Math.imul(ne,pe),m=m+Math.imul(G,ge)|0,c=c+Math.imul(G,be)|0,c=c+Math.imul(Y,ge)|0,x=x+Math.imul(Y,be)|0,m=m+Math.imul($,ve)|0,c=c+Math.imul($,me)|0,c=c+Math.imul(V,ve)|0,x=x+Math.imul(V,me)|0,m=m+Math.imul(q,ye)|0,c=c+Math.imul(q,we)|0,c=c+Math.imul(K,ye)|0,x=x+Math.imul(K,we)|0,m=m+Math.imul(E,_e)|0,c=c+Math.imul(E,xe)|0,c=c+Math.imul(N,_e)|0,x=x+Math.imul(N,xe)|0,m=m+Math.imul(g,Ee)|0,c=c+Math.imul(g,Se)|0,c=c+Math.imul(R,Ee)|0,x=x+Math.imul(R,Se)|0;var $t=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+($t>>>26)|0,$t&=67108863,m=Math.imul(se,le),c=Math.imul(se,pe),c=c+Math.imul(oe,le)|0,x=Math.imul(oe,pe),m=m+Math.imul(ie,ge)|0,c=c+Math.imul(ie,be)|0,c=c+Math.imul(ne,ge)|0,x=x+Math.imul(ne,be)|0,m=m+Math.imul(G,ve)|0,c=c+Math.imul(G,me)|0,c=c+Math.imul(Y,ve)|0,x=x+Math.imul(Y,me)|0,m=m+Math.imul($,ye)|0,c=c+Math.imul($,we)|0,c=c+Math.imul(V,ye)|0,x=x+Math.imul(V,we)|0,m=m+Math.imul(q,_e)|0,c=c+Math.imul(q,xe)|0,c=c+Math.imul(K,_e)|0,x=x+Math.imul(K,xe)|0,m=m+Math.imul(E,Ee)|0,c=c+Math.imul(E,Se)|0,c=c+Math.imul(N,Ee)|0,x=x+Math.imul(N,Se)|0,m=m+Math.imul(g,Ie)|0,c=c+Math.imul(g,Me)|0,c=c+Math.imul(R,Ie)|0,x=x+Math.imul(R,Me)|0;var Ht=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,m=Math.imul(ae,le),c=Math.imul(ae,pe),c=c+Math.imul(fe,le)|0,x=Math.imul(fe,pe),m=m+Math.imul(se,ge)|0,c=c+Math.imul(se,be)|0,c=c+Math.imul(oe,ge)|0,x=x+Math.imul(oe,be)|0,m=m+Math.imul(ie,ve)|0,c=c+Math.imul(ie,me)|0,c=c+Math.imul(ne,ve)|0,x=x+Math.imul(ne,me)|0,m=m+Math.imul(G,ye)|0,c=c+Math.imul(G,we)|0,c=c+Math.imul(Y,ye)|0,x=x+Math.imul(Y,we)|0,m=m+Math.imul($,_e)|0,c=c+Math.imul($,xe)|0,c=c+Math.imul(V,_e)|0,x=x+Math.imul(V,xe)|0,m=m+Math.imul(q,Ee)|0,c=c+Math.imul(q,Se)|0,c=c+Math.imul(K,Ee)|0,x=x+Math.imul(K,Se)|0,m=m+Math.imul(E,Ie)|0,c=c+Math.imul(E,Me)|0,c=c+Math.imul(N,Ie)|0,x=x+Math.imul(N,Me)|0,m=m+Math.imul(g,Ae)|0,c=c+Math.imul(g,Re)|0,c=c+Math.imul(R,Ae)|0,x=x+Math.imul(R,Re)|0;var Gt=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,m=Math.imul(ce,le),c=Math.imul(ce,pe),c=c+Math.imul(he,le)|0,x=Math.imul(he,pe),m=m+Math.imul(ae,ge)|0,c=c+Math.imul(ae,be)|0,c=c+Math.imul(fe,ge)|0,x=x+Math.imul(fe,be)|0,m=m+Math.imul(se,ve)|0,c=c+Math.imul(se,me)|0,c=c+Math.imul(oe,ve)|0,x=x+Math.imul(oe,me)|0,m=m+Math.imul(ie,ye)|0,c=c+Math.imul(ie,we)|0,c=c+Math.imul(ne,ye)|0,x=x+Math.imul(ne,we)|0,m=m+Math.imul(G,_e)|0,c=c+Math.imul(G,xe)|0,c=c+Math.imul(Y,_e)|0,x=x+Math.imul(Y,xe)|0,m=m+Math.imul($,Ee)|0,c=c+Math.imul($,Se)|0,c=c+Math.imul(V,Ee)|0,x=x+Math.imul(V,Se)|0,m=m+Math.imul(q,Ie)|0,c=c+Math.imul(q,Me)|0,c=c+Math.imul(K,Ie)|0,x=x+Math.imul(K,Me)|0,m=m+Math.imul(E,Ae)|0,c=c+Math.imul(E,Re)|0,c=c+Math.imul(N,Ae)|0,x=x+Math.imul(N,Re)|0,m=m+Math.imul(g,Te)|0,c=c+Math.imul(g,De)|0,c=c+Math.imul(R,Te)|0,x=x+Math.imul(R,De)|0;var Zi=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Zi>>>26)|0,Zi&=67108863,m=Math.imul(ue,le),c=Math.imul(ue,pe),c=c+Math.imul(de,le)|0,x=Math.imul(de,pe),m=m+Math.imul(ce,ge)|0,c=c+Math.imul(ce,be)|0,c=c+Math.imul(he,ge)|0,x=x+Math.imul(he,be)|0,m=m+Math.imul(ae,ve)|0,c=c+Math.imul(ae,me)|0,c=c+Math.imul(fe,ve)|0,x=x+Math.imul(fe,me)|0,m=m+Math.imul(se,ye)|0,c=c+Math.imul(se,we)|0,c=c+Math.imul(oe,ye)|0,x=x+Math.imul(oe,we)|0,m=m+Math.imul(ie,_e)|0,c=c+Math.imul(ie,xe)|0,c=c+Math.imul(ne,_e)|0,x=x+Math.imul(ne,xe)|0,m=m+Math.imul(G,Ee)|0,c=c+Math.imul(G,Se)|0,c=c+Math.imul(Y,Ee)|0,x=x+Math.imul(Y,Se)|0,m=m+Math.imul($,Ie)|0,c=c+Math.imul($,Me)|0,c=c+Math.imul(V,Ie)|0,x=x+Math.imul(V,Me)|0,m=m+Math.imul(q,Ae)|0,c=c+Math.imul(q,Re)|0,c=c+Math.imul(K,Ae)|0,x=x+Math.imul(K,Re)|0,m=m+Math.imul(E,Te)|0,c=c+Math.imul(E,De)|0,c=c+Math.imul(N,Te)|0,x=x+Math.imul(N,De)|0,m=m+Math.imul(g,Pe)|0,c=c+Math.imul(g,Ne)|0,c=c+Math.imul(R,Pe)|0,x=x+Math.imul(R,Ne)|0;var Qi=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,m=Math.imul(ue,ge),c=Math.imul(ue,be),c=c+Math.imul(de,ge)|0,x=Math.imul(de,be),m=m+Math.imul(ce,ve)|0,c=c+Math.imul(ce,me)|0,c=c+Math.imul(he,ve)|0,x=x+Math.imul(he,me)|0,m=m+Math.imul(ae,ye)|0,c=c+Math.imul(ae,we)|0,c=c+Math.imul(fe,ye)|0,x=x+Math.imul(fe,we)|0,m=m+Math.imul(se,_e)|0,c=c+Math.imul(se,xe)|0,c=c+Math.imul(oe,_e)|0,x=x+Math.imul(oe,xe)|0,m=m+Math.imul(ie,Ee)|0,c=c+Math.imul(ie,Se)|0,c=c+Math.imul(ne,Ee)|0,x=x+Math.imul(ne,Se)|0,m=m+Math.imul(G,Ie)|0,c=c+Math.imul(G,Me)|0,c=c+Math.imul(Y,Ie)|0,x=x+Math.imul(Y,Me)|0,m=m+Math.imul($,Ae)|0,c=c+Math.imul($,Re)|0,c=c+Math.imul(V,Ae)|0,x=x+Math.imul(V,Re)|0,m=m+Math.imul(q,Te)|0,c=c+Math.imul(q,De)|0,c=c+Math.imul(K,Te)|0,x=x+Math.imul(K,De)|0,m=m+Math.imul(E,Pe)|0,c=c+Math.imul(E,Ne)|0,c=c+Math.imul(N,Pe)|0,x=x+Math.imul(N,Ne)|0;var en=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(en>>>26)|0,en&=67108863,m=Math.imul(ue,ve),c=Math.imul(ue,me),c=c+Math.imul(de,ve)|0,x=Math.imul(de,me),m=m+Math.imul(ce,ye)|0,c=c+Math.imul(ce,we)|0,c=c+Math.imul(he,ye)|0,x=x+Math.imul(he,we)|0,m=m+Math.imul(ae,_e)|0,c=c+Math.imul(ae,xe)|0,c=c+Math.imul(fe,_e)|0,x=x+Math.imul(fe,xe)|0,m=m+Math.imul(se,Ee)|0,c=c+Math.imul(se,Se)|0,c=c+Math.imul(oe,Ee)|0,x=x+Math.imul(oe,Se)|0,m=m+Math.imul(ie,Ie)|0,c=c+Math.imul(ie,Me)|0,c=c+Math.imul(ne,Ie)|0,x=x+Math.imul(ne,Me)|0,m=m+Math.imul(G,Ae)|0,c=c+Math.imul(G,Re)|0,c=c+Math.imul(Y,Ae)|0,x=x+Math.imul(Y,Re)|0,m=m+Math.imul($,Te)|0,c=c+Math.imul($,De)|0,c=c+Math.imul(V,Te)|0,x=x+Math.imul(V,De)|0,m=m+Math.imul(q,Pe)|0,c=c+Math.imul(q,Ne)|0,c=c+Math.imul(K,Pe)|0,x=x+Math.imul(K,Ne)|0;var tn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(tn>>>26)|0,tn&=67108863,m=Math.imul(ue,ye),c=Math.imul(ue,we),c=c+Math.imul(de,ye)|0,x=Math.imul(de,we),m=m+Math.imul(ce,_e)|0,c=c+Math.imul(ce,xe)|0,c=c+Math.imul(he,_e)|0,x=x+Math.imul(he,xe)|0,m=m+Math.imul(ae,Ee)|0,c=c+Math.imul(ae,Se)|0,c=c+Math.imul(fe,Ee)|0,x=x+Math.imul(fe,Se)|0,m=m+Math.imul(se,Ie)|0,c=c+Math.imul(se,Me)|0,c=c+Math.imul(oe,Ie)|0,x=x+Math.imul(oe,Me)|0,m=m+Math.imul(ie,Ae)|0,c=c+Math.imul(ie,Re)|0,c=c+Math.imul(ne,Ae)|0,x=x+Math.imul(ne,Re)|0,m=m+Math.imul(G,Te)|0,c=c+Math.imul(G,De)|0,c=c+Math.imul(Y,Te)|0,x=x+Math.imul(Y,De)|0,m=m+Math.imul($,Pe)|0,c=c+Math.imul($,Ne)|0,c=c+Math.imul(V,Pe)|0,x=x+Math.imul(V,Ne)|0;var rn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(rn>>>26)|0,rn&=67108863,m=Math.imul(ue,_e),c=Math.imul(ue,xe),c=c+Math.imul(de,_e)|0,x=Math.imul(de,xe),m=m+Math.imul(ce,Ee)|0,c=c+Math.imul(ce,Se)|0,c=c+Math.imul(he,Ee)|0,x=x+Math.imul(he,Se)|0,m=m+Math.imul(ae,Ie)|0,c=c+Math.imul(ae,Me)|0,c=c+Math.imul(fe,Ie)|0,x=x+Math.imul(fe,Me)|0,m=m+Math.imul(se,Ae)|0,c=c+Math.imul(se,Re)|0,c=c+Math.imul(oe,Ae)|0,x=x+Math.imul(oe,Re)|0,m=m+Math.imul(ie,Te)|0,c=c+Math.imul(ie,De)|0,c=c+Math.imul(ne,Te)|0,x=x+Math.imul(ne,De)|0,m=m+Math.imul(G,Pe)|0,c=c+Math.imul(G,Ne)|0,c=c+Math.imul(Y,Pe)|0,x=x+Math.imul(Y,Ne)|0;var nn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(nn>>>26)|0,nn&=67108863,m=Math.imul(ue,Ee),c=Math.imul(ue,Se),c=c+Math.imul(de,Ee)|0,x=Math.imul(de,Se),m=m+Math.imul(ce,Ie)|0,c=c+Math.imul(ce,Me)|0,c=c+Math.imul(he,Ie)|0,x=x+Math.imul(he,Me)|0,m=m+Math.imul(ae,Ae)|0,c=c+Math.imul(ae,Re)|0,c=c+Math.imul(fe,Ae)|0,x=x+Math.imul(fe,Re)|0,m=m+Math.imul(se,Te)|0,c=c+Math.imul(se,De)|0,c=c+Math.imul(oe,Te)|0,x=x+Math.imul(oe,De)|0,m=m+Math.imul(ie,Pe)|0,c=c+Math.imul(ie,Ne)|0,c=c+Math.imul(ne,Pe)|0,x=x+Math.imul(ne,Ne)|0;var sn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(sn>>>26)|0,sn&=67108863,m=Math.imul(ue,Ie),c=Math.imul(ue,Me),c=c+Math.imul(de,Ie)|0,x=Math.imul(de,Me),m=m+Math.imul(ce,Ae)|0,c=c+Math.imul(ce,Re)|0,c=c+Math.imul(he,Ae)|0,x=x+Math.imul(he,Re)|0,m=m+Math.imul(ae,Te)|0,c=c+Math.imul(ae,De)|0,c=c+Math.imul(fe,Te)|0,x=x+Math.imul(fe,De)|0,m=m+Math.imul(se,Pe)|0,c=c+Math.imul(se,Ne)|0,c=c+Math.imul(oe,Pe)|0,x=x+Math.imul(oe,Ne)|0;var on=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(on>>>26)|0,on&=67108863,m=Math.imul(ue,Ae),c=Math.imul(ue,Re),c=c+Math.imul(de,Ae)|0,x=Math.imul(de,Re),m=m+Math.imul(ce,Te)|0,c=c+Math.imul(ce,De)|0,c=c+Math.imul(he,Te)|0,x=x+Math.imul(he,De)|0,m=m+Math.imul(ae,Pe)|0,c=c+Math.imul(ae,Ne)|0,c=c+Math.imul(fe,Pe)|0,x=x+Math.imul(fe,Ne)|0;var an=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(an>>>26)|0,an&=67108863,m=Math.imul(ue,Te),c=Math.imul(ue,De),c=c+Math.imul(de,Te)|0,x=Math.imul(de,De),m=m+Math.imul(ce,Pe)|0,c=c+Math.imul(ce,Ne)|0,c=c+Math.imul(he,Pe)|0,x=x+Math.imul(he,Ne)|0;var fn=(_+m|0)+((c&8191)<<13)|0;_=(x+(c>>>13)|0)+(fn>>>26)|0,fn&=67108863,m=Math.imul(ue,Pe),c=Math.imul(ue,Ne),c=c+Math.imul(de,Pe)|0,x=Math.imul(de,Ne);var cn=(_+m|0)+((c&8191)<<13)|0;return _=(x+(c>>>13)|0)+(cn>>>26)|0,cn&=67108863,v[0]=nr,v[1]=Be,v[2]=ke,v[3]=jt,v[4]=Vt,v[5]=$t,v[6]=Ht,v[7]=Gt,v[8]=Zi,v[9]=Qi,v[10]=en,v[11]=tn,v[12]=rn,v[13]=nn,v[14]=sn,v[15]=on,v[16]=an,v[17]=fn,v[18]=cn,_!==0&&(v[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,u=0;u>>26)|0,a+=v>>>26,v&=67108863}w.words[u]=_,p=v,v=a}return p!==0?w.words[u]=p:w.length--,w.strip()}function C(D,l,w){var p=new P;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=C(this,l,w),p};function P(D,l){this.x=D,this.y=l}P.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},P.prototype.permute=function(l,w,p,a,u,v){for(var _=0;_>>1)u++;return 1<>>13,p[2*v+1]=u&8191,u=u>>>13;for(v=2*w;v>=26,w+=a/67108864|0,w+=u>>>26,this.words[p]=u&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,u;if(w!==0){var v=0;for(u=0;u>>26-w}v&&(this.words[u]=v,this.length++)}if(p!==0){for(u=this.length-1;u>=0;u--)this.words[u+p]=this.words[u];for(u=0;u=0);var a;w?a=(w-w%26)/26:a=0;var u=l%26,v=Math.min((l-u)/26,this.length),_=67108863^67108863>>>u<v)for(this.length-=v,c=0;c=0&&(x!==0||c>=a);c--){var A=this.words[c]|0;this.words[c]=x<<26-u|A>>>u,x=A&_}return m&&x!==0&&(m.words[m.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(m/67108864|0),this.words[u+p]=v&67108863}for(;u>26,this.words[u+p]=v&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,u=0;u>26,this.words[u]=v&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),u=l,v=u.words[u.length-1]|0,_=this._countBits(v);p=26-_,p!==0&&(u=u.ushln(p),a.iushln(p),v=u.words[u.length-1]|0);var m=a.length-u.length,c;if(w!=="mod"){c=new n(null),c.length=m+1,c.words=new Array(c.length);for(var x=0;x=0;g--){var R=(a.words[u.length+g]|0)*67108864+(a.words[u.length+g-1]|0);for(R=Math.min(R/v|0,67108863),a._ishlnsubmul(u,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(u,1,g),a.isZero()||(a.negative^=1);c&&(c.words[g]=R)}return c&&c.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:c||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,u,v;return this.negative!==0&&l.negative===0?(v=this.neg().divmod(l,w),w!=="mod"&&(a=v.div.neg()),w!=="div"&&(u=v.mod.neg(),p&&u.negative!==0&&u.iadd(l)),{div:a,mod:u}):this.negative===0&&l.negative!==0?(v=this.divmod(l.neg(),w),w!=="mod"&&(a=v.div.neg()),{div:a,mod:v.mod}):this.negative&l.negative?(v=this.neg().divmod(l.neg(),w),w!=="div"&&(u=v.mod.neg(),p&&u.negative!==0&&u.isub(l)),{div:v.div,mod:u}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),u=l.andln(1),v=p.cmp(a);return v<0||u===1&&v===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),u=new n(0),v=new n(0),_=new n(1),m=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++m;for(var c=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(c),u.isub(x)),a.iushrn(1),u.iushrn(1);for(var R=0,k=1;!(p.words[0]&k)&&R<26;++R,k<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(v.isOdd()||_.isOdd())&&(v.iadd(c),_.isub(x)),v.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(v),u.isub(_)):(p.isub(w),v.isub(a),_.isub(u))}return{a:v,b:_,gcd:p.iushln(m)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),u=new n(0),v=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,m=1;!(w.words[0]&m)&&_<26;++_,m<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(v),a.iushrn(1);for(var c=0,x=1;!(p.words[0]&x)&&c<26;++c,x<<=1);if(c>0)for(p.iushrn(c);c-- >0;)u.isOdd()&&u.iadd(v),u.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(u)):(p.isub(w),u.isub(a))}var A;return w.cmpn(1)===0?A=a:A=u,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var u=w.cmp(p);if(u<0){var v=w;w=p,p=v}else if(u===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[v]=_}return u!==0&&(this.words[v]=u,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,u=l.words[p]|0;if(a!==u){au&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new O(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var U={k256:null,p224:null,p192:null,p25519:null};function B(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}B.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},B.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},B.prototype.split=function(l,w){l.iushrn(this.n,0,w)},B.prototype.imulK=function(l){return l.imul(this.k)};function z(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(z,B),z.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),u=0;u>>22,v=_}v>>>=22,l.words[u-10]=v,v===0&&l.length>10?l.length-=10:l.length-=9},z.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=u,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(U[l])return U[l];var w;if(l==="k256")w=new z;else if(l==="p224")w=new j;else if(l==="p192")w=new H;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return U[l]=w,w};function O(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}O.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},O.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},O.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},O.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},O.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},O.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},O.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},O.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},O.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},O.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},O.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},O.prototype.isqr=function(l){return this.imul(l,l.clone())},O.prototype.sqr=function(l){return this.mul(l,l)},O.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),u=0;!a.isZero()&&a.andln(1)===0;)u++,a.iushrn(1);t(!a.isZero());var v=new n(1).toRed(this),_=v.redNeg(),m=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new n(2*c*c).toRed(this);this.pow(c,m).cmp(_)!==0;)c.redIAdd(_);for(var x=this.pow(c,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=u;g.cmp(v)!==0;){for(var k=g,E=0;k.cmp(v)!==0;E++)k=k.redSqr();t(E=0;u--){for(var x=w.words[u],A=c-1;A>=0;A--){var g=x>>A&1;if(v!==a[0]&&(v=this.sqr(v)),g===0&&_===0){m=0;continue}_<<=1,_|=g,m++,!(m!==p&&(u!==0||A!==0))&&(v=this.mul(v,a[_]),m=0,_=0)}c=26}return v},O.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},O.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(D){O.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,O),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=p.isub(a).iushrn(this.shift),v=u;return u.cmp(this.m)>=0?v=u.isub(this.m):u.cmpn(0)<0&&(v=u.iadd(this.m)),v._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),u=p.isub(a).iushrn(this.shift),v=u;return u.cmp(this.m)>=0?v=u.isub(this.m):u.cmpn(0)<0&&(v=u.iadd(this.m)),v._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof su>"u"||su,vg)});var ou=Z(wg=>{"use strict";var hf=wg;function Y8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}hf.toArray=Y8;function mg(r){return r.length===1?"0"+r:r}hf.zero2=mg;function yg(r){for(var e="",t=0;t{"use strict";var dr=_g,X8=Jr(),Z8=Di(),uf=ou();dr.assert=Z8;dr.toArray=uf.toArray;dr.zero2=uf.zero2;dr.toHex=uf.toHex;dr.encode=uf.encode;function Q8(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-d:f=d,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}dr.getNAF=Q8;function e4(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var d;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?d=-o:d=o):d=0,t[0].push(d);var h;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?h=-f:h=f):h=0,t[1].push(h),2*i===d+1&&(i=1-i),2*n===h+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}dr.getJSF=e4;function t4(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}dr.cachedProperty=t4;function r4(r){return typeof r=="string"?dr.toArray(r,"hex"):r}dr.parseBytes=r4;function i4(r){return new X8(r,"hex","le")}dr.intFromLE=i4});var hu=Z((KR,cu)=>{var au;cu.exports=function(e){return au||(au=new Li(null)),au.generate(e)};function Li(r){this.rand=r}cu.exports.Rand=Li;Li.prototype.generate=function(e){return this._rand(e)};Li.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var xn=Jr(),mo=Bt(),df=mo.getNAF,n4=mo.getJSF,lf=mo.assert;function Fi(r,e){this.type=r,this.p=new xn(e.p,16),this.red=e.prime?xn.red(e.prime):xn.mont(this.p),this.zero=new xn(0).toRed(this.red),this.one=new xn(1).toRed(this.red),this.two=new xn(2).toRed(this.red),this.n=e.n&&new xn(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}xg.exports=Fi;Fi.prototype.point=function(){throw new Error("Not implemented")};Fi.prototype.validate=function(){throw new Error("Not implemented")};Fi.prototype._fixedNafMul=function(e,t){lf(e.precomputed);var i=e._getDoubles(),n=df(t,1,this._bitLength),s=(1<=f;h--)d=(d<<1)+n[h];o.push(d)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;d--){for(var h=0;d>=0&&o[d]===0;d--)h++;if(d>=0&&h++,f=f.dblp(h),d<0)break;var b=o[d];lf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};Fi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,d=this._wnafT3,h=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){d[M]=df(i[M],o[M],this._bitLength),d[T]=df(i[T],o[T],this._bitLength),h=Math.max(d[M].length,h),h=Math.max(d[T].length,h);continue}var C=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(C[1]=t[M].add(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].add(t[T].neg())):(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],U=n4(i[M],i[T]);for(h=Math.max(U[0].length,h),d[M]=new Array(h),d[T]=new Array(h),y=0;y=0;b--){for(var L=0;b>=0;){var O=!0;for(y=0;y=0&&L++,j=j.dblp(L),b<0)break;for(y=0;y0?S=f[y][W-1>>1]:W<0&&(S=f[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Qt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var s4=Bt(),et=Jr(),uu=co(),ps=yo(),o4=s4.assert;function er(r){ps.call(this,"short",r),this.a=new et(r.a,16).toRed(this.red),this.b=new et(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}uu(er,ps);Eg.exports=er;er.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new et(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new et(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],o4(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new et(f.a,16),b:new et(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};er.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:et.mont(e),i=new et(2).toRed(t).redInvm(),n=i.redNeg(),s=new et(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};er.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new et(1),o=new et(0),f=new et(0),d=new et(1),h,b,y,S,I,M,T,C=0,P,U;i.cmpn(0)!==0;){var B=n.div(i);P=n.sub(B.mul(i)),U=f.sub(B.mul(s));var z=d.sub(B.mul(o));if(!y&&P.cmp(t)<0)h=T.neg(),b=s,y=P.neg(),S=U;else if(y&&++C===2)break;T=P,n=i,i=P,f=s,s=U,d=o,o=z}I=P.neg(),M=U;var j=y.sqr().add(S.sqr()),H=I.sqr().add(M.sqr());return H.cmp(j)>=0&&(I=h,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};er.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),d=o.mul(n.a),h=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(d),S=h.add(b).neg();return{k1:y,k2:S}};er.prototype.pointFromX=function(e,t){e=new et(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};er.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};er.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ct.prototype.isInfinity=function(){return this.inf};ct.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ct.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ct.prototype.getX=function(){return this.x.fromRed()};ct.prototype.getY=function(){return this.y.fromRed()};ct.prototype.mul=function(e){return e=new et(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ct.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ct.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ct.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ct.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ct.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function bt(r,e,t,i){ps.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new et(0)):(this.x=new et(e,16),this.y=new et(t,16),this.z=new et(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}uu(bt,ps.BasePoint);er.prototype.jpoint=function(e,t,i){return new bt(this,e,t,i)};bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),d=n.redSub(s),h=o.redSub(f);if(d.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=d.redSqr(),y=b.redMul(d),S=n.redMul(b),I=h.redSqr().redIAdd(y).redISub(S).redISub(S),M=h.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(I,M,T)};bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),d=s.redSub(o);if(f.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),b=h.redMul(f),y=i.redMul(h),S=d.redSqr().redIAdd(b).redISub(y).redISub(y),I=d.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};bt.prototype.inspect=function(){return this.isInfinity()?"":""};bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Ag=Z(($R,Mg)=>{"use strict";var gs=Jr(),Ig=co(),pf=yo(),a4=Bt();function bs(r){pf.call(this,"mont",r),this.a=new gs(r.a,16).toRed(this.red),this.b=new gs(r.b,16).toRed(this.red),this.i4=new gs(4).toRed(this.red).redInvm(),this.two=new gs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Ig(bs,pf);Mg.exports=bs;bs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function ht(r,e,t){pf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new gs(e,16),this.z=new gs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Ig(ht,pf.BasePoint);bs.prototype.decodePoint=function(e,t){return this.point(a4.toArray(e,t),1)};bs.prototype.point=function(e,t){return new ht(this,e,t)};bs.prototype.pointFromJSON=function(e){return ht.fromJSON(this,e)};ht.prototype.precompute=function(){};ht.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};ht.fromJSON=function(e,t){return new ht(e,t[0],t[1]||e.one)};ht.prototype.inspect=function(){return this.isInfinity()?"":""};ht.prototype.isInfinity=function(){return this.z.cmpn(0)===0};ht.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};ht.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),d=s.redMul(n),h=t.z.redMul(f.redAdd(d).redSqr()),b=t.x.redMul(f.redISub(d).redSqr());return this.curve.point(h,b)};ht.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};ht.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};ht.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};ht.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Dg=Z((HR,Tg)=>{"use strict";var f4=Bt(),vi=Jr(),Rg=co(),gf=yo(),c4=f4.assert;function Yr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,gf.call(this,"edwards",r),this.a=new vi(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new vi(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new vi(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c4(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Rg(Yr,gf);Tg.exports=Yr;Yr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Yr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Yr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Yr.prototype.pointFromX=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var d=f.fromRed().isOdd();return(t&&!d||!t&&d)&&(f=f.redNeg()),this.point(e,f)};Yr.prototype.pointFromY=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};Yr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ge(r,e,t,i,n){gf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new vi(e,16),this.y=new vi(t,16),this.z=i?new vi(i,16):this.curve.one,this.t=n&&new vi(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Rg(Ge,gf.BasePoint);Yr.prototype.pointFromJSON=function(e){return Ge.fromJSON(this,e)};Yr.prototype.point=function(e,t,i,n){return new Ge(this,e,t,i,n)};Ge.fromJSON=function(e,t){return new Ge(e,t[0],t[1],t[2])};Ge.prototype.inspect=function(){return this.isInfinity()?"":""};Ge.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ge.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),d=n.redSub(t),h=s.redMul(f),b=o.redMul(d),y=s.redMul(d),S=f.redMul(o);return this.curve.point(h,b,S,y)};Ge.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,d,h;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(d=this.z.redSqr(),h=b.redSub(d).redISub(d),n=e.redSub(t).redISub(i).redMul(h),s=b.redMul(f.redSub(i)),o=b.redMul(h))}else f=t.redAdd(i),d=this.curve._mulC(this.z).redSqr(),h=f.redSub(d).redSub(d),n=this.curve._mulC(e.redISub(f)).redMul(h),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(h);return this.curve.point(n,s,o)};Ge.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ge.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),d=s.redAdd(n),h=i.redAdd(t),b=o.redMul(f),y=d.redMul(h),S=o.redMul(h),I=f.redMul(d);return this.curve.point(b,y,I,S)};Ge.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),d=i.redAdd(o),h=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(h),y,S;return this.curve.twisted?(y=t.redMul(d).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(d)):(y=t.redMul(d).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(d)),this.curve.point(b,y,S)};Ge.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ge.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ge.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ge.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ge.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ge.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ge.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ge.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ge.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ge.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ge.prototype.toP=Ge.prototype.normalize;Ge.prototype.mixedAdd=Ge.prototype.add});var du=Z(Pg=>{"use strict";var bf=Pg;bf.base=yo();bf.short=Sg();bf.mont=Ag();bf.edwards=Dg()});var Cg=Z((WR,Ng)=>{Ng.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var vf=Z(Fg=>{"use strict";var pu=Fg,qi=lo(),lu=du(),h4=Bt(),Og=h4.assert;function Lg(r){r.type==="short"?this.curve=new lu.short(r):r.type==="edwards"?this.curve=new lu.edwards(r):this.curve=new lu.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,Og(this.g.validate(),"Invalid curve"),Og(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}pu.PresetCurve=Lg;function Ui(r,e){Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,get:function(){var t=new Lg(e);return Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,value:t}),t}})}Ui("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:qi.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});Ui("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:qi.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});Ui("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:qi.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});Ui("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:qi.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});Ui("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:qi.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});Ui("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:qi.sha256,gRed:!1,g:["9"]});Ui("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:qi.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var gu;try{gu=Cg()}catch{gu=void 0}Ui("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:qi.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",gu]})});var zg=Z((YR,Ug)=>{"use strict";var u4=lo(),En=ou(),qg=Di();function zi(r){if(!(this instanceof zi))return new zi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=En.toArray(r.entropy,r.entropyEnc||"hex"),t=En.toArray(r.nonce,r.nonceEnc||"hex"),i=En.toArray(r.pers,r.persEnc||"hex");qg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}Ug.exports=zi;zi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};zi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=En.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var d4=Jr(),l4=Bt(),bu=l4.assert;function St(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}Bg.exports=St;St.fromPublic=function(e,t,i){return t instanceof St?t:new St(e,{pub:t,pubEnc:i})};St.fromPrivate=function(e,t,i){return t instanceof St?t:new St(e,{priv:t,privEnc:i})};St.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};St.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};St.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};St.prototype._importPrivate=function(e,t){this.priv=new d4(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};St.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?bu(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&bu(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};St.prototype.derive=function(e){return e.validate()||bu(e.validate(),"public point not validated"),e.mul(this.priv).getX()};St.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};St.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};St.prototype.inspect=function(){return""}});var Vg=Z((ZR,jg)=>{"use strict";var mf=Jr(),yu=Bt(),p4=yu.assert;function yf(r,e){if(r instanceof yf)return r;this._importDER(r,e)||(p4(r.r&&r.s,"Signature without r or s"),this.r=new mf(r.r,16),this.s=new mf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}jg.exports=yf;function g4(){this.place=0}function vu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Kg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}yf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Kg(t),i=Kg(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];mu(n,t.length),n=n.concat(t),n.push(2),mu(n,i.length);var s=n.concat(i),o=[48];return mu(o,s.length),o=o.concat(s),yu.encode(o,e)}});var Wg=Z((QR,Gg)=>{"use strict";var Sn=Jr(),$g=zg(),b4=Bt(),wu=vf(),v4=hu(),Hg=b4.assert,_u=kg(),wf=Vg();function tr(r){if(!(this instanceof tr))return new tr(r);typeof r=="string"&&(Hg(Object.prototype.hasOwnProperty.call(wu,r),"Unknown curve "+r),r=wu[r]),r instanceof wu.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}Gg.exports=tr;tr.prototype.keyPair=function(e){return new _u(this,e)};tr.prototype.keyFromPrivate=function(e,t){return _u.fromPrivate(this,e,t)};tr.prototype.keyFromPublic=function(e,t){return _u.fromPublic(this,e,t)};tr.prototype.genKeyPair=function(e){e||(e={});for(var t=new $g({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Sn(2));;){var s=new Sn(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};tr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};tr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Sn(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),d=new $g({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new Sn(1)),b=0;;b++){var y=n.k?n.k(b):new Sn(d.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var C=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),C^=1),new wf({r:M,s:T,recoveryParam:C})}}}}}};tr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Sn(e,16)),i=this.keyFromPublic(i,n),t=new wf(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),d=f.mul(e).umod(this.n),h=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};tr.prototype.recoverPubKey=function(r,e,t,i){Hg((3&t)===t,"The recovery param is more than two bits"),e=new wf(e,i);var n=this.n,s=new Sn(r),o=e.r,f=e.s,d=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),d):o=this.curve.pointFromX(o,d);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};tr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new wf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Zg=Z((eT,Xg)=>{"use strict";var wo=Bt(),Yg=wo.assert,Jg=wo.parseBytes,vs=wo.cachedProperty;function ut(r,e){this.eddsa=r,this._secret=Jg(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Jg(e.pub)}ut.fromPublic=function(e,t){return t instanceof ut?t:new ut(e,{pub:t})};ut.fromSecret=function(e,t){return t instanceof ut?t:new ut(e,{secret:t})};ut.prototype.secret=function(){return this._secret};vs(ut,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});vs(ut,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});vs(ut,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});vs(ut,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});vs(ut,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});vs(ut,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});ut.prototype.sign=function(e){return Yg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};ut.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};ut.prototype.getSecret=function(e){return Yg(this._secret,"KeyPair is public only"),wo.encode(this.secret(),e)};ut.prototype.getPublic=function(e){return wo.encode(this.pubBytes(),e)};Xg.exports=ut});var tb=Z((tT,eb)=>{"use strict";var m4=Jr(),_f=Bt(),Qg=_f.assert,xf=_f.cachedProperty,y4=_f.parseBytes;function In(r,e){this.eddsa=r,typeof e!="object"&&(e=y4(e)),Array.isArray(e)&&(Qg(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Qg(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof m4&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}xf(In,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});xf(In,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});xf(In,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});xf(In,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});In.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};In.prototype.toHex=function(){return _f.encode(this.toBytes(),"hex").toUpperCase()};eb.exports=In});var ob=Z((rT,sb)=>{"use strict";var w4=lo(),_4=vf(),ms=Bt(),x4=ms.assert,ib=ms.parseBytes,nb=Zg(),rb=tb();function Lt(r){if(x4(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Lt))return new Lt(r);r=_4[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=w4.sha512}sb.exports=Lt;Lt.prototype.sign=function(e,t){e=ib(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),d=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:d,Rencoded:o})};Lt.prototype.verify=function(e,t,i){if(e=ib(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Lt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Mn=ab;Mn.version=bg().version;Mn.utils=Bt();Mn.rand=hu();Mn.curve=du();Mn.curves=vf();Mn.ec=Wg();Mn.eddsa=ob()});var vv=Z(Vi=>{"use strict";Object.defineProperty(Vi,"__esModule",{value:!0});Vi.isBrowserCryptoAvailable=Vi.getSubtleCrypto=Vi.getBrowerCrypto=void 0;function Wu(){return window?.crypto||window?.msCrypto||{}}Vi.getBrowerCrypto=Wu;function bv(){let r=Wu();return r.subtle||r.webkitSubtle}Vi.getSubtleCrypto=bv;function U_(){return!!Wu()&&!!bv()}Vi.isBrowserCryptoAvailable=U_});var wv=Z($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isBrowser=$i.isNode=$i.isReactNative=void 0;function mv(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}$i.isReactNative=mv;function yv(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}$i.isNode=yv;function z_(){return!mv()&&!yv()}$i.isBrowser=z_});var Ju=Z(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});var _v=(zn(),qs(Un));_v.__exportStar(vv(),Lf);_v.__exportStar(wv(),Lf)});var Rv=Z((UT,Av)=>{"use strict";Av.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var dm=Z((qo,Ns)=>{var X_=200,cd="__lodash_hash_undefined__",Jf=1,jv=2,Vv=9007199254740991,Kf="[object Arguments]",rd="[object Array]",Z_="[object AsyncFunction]",$v="[object Boolean]",Hv="[object Date]",Gv="[object Error]",Wv="[object Function]",Q_="[object GeneratorFunction]",jf="[object Map]",Jv="[object Number]",ex="[object Null]",Ps="[object Object]",Nv="[object Promise]",tx="[object Proxy]",Yv="[object RegExp]",Vf="[object Set]",Xv="[object String]",rx="[object Symbol]",ix="[object Undefined]",id="[object WeakMap]",Zv="[object ArrayBuffer]",$f="[object DataView]",nx="[object Float32Array]",sx="[object Float64Array]",ox="[object Int8Array]",ax="[object Int16Array]",fx="[object Int32Array]",cx="[object Uint8Array]",hx="[object Uint8ClampedArray]",ux="[object Uint16Array]",dx="[object Uint32Array]",lx=/[\\^$.*+?()[\]{}|]/g,px=/^\[object .+?Constructor\]$/,gx=/^(?:0|[1-9]\d*)$/,Je={};Je[nx]=Je[sx]=Je[ox]=Je[ax]=Je[fx]=Je[cx]=Je[hx]=Je[ux]=Je[dx]=!0;Je[Kf]=Je[rd]=Je[Zv]=Je[$v]=Je[$f]=Je[Hv]=Je[Gv]=Je[Wv]=Je[jf]=Je[Jv]=Je[Ps]=Je[Yv]=Je[Vf]=Je[Xv]=Je[id]=!1;var Qv=typeof window=="object"&&window&&window.Object===Object&&window,bx=typeof self=="object"&&self&&self.Object===Object&&self,_i=Qv||bx||Function("return this")(),em=typeof qo=="object"&&qo&&!qo.nodeType&&qo,Cv=em&&typeof Ns=="object"&&Ns&&!Ns.nodeType&&Ns,tm=Cv&&Cv.exports===em,Qu=tm&&Qv.process,Ov=function(){try{return Qu&&Qu.binding&&Qu.binding("util")}catch{}}(),Lv=Ov&&Ov.isTypedArray;function vx(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function Gx(r,e){var t=this.__data__,i=Xf(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}xi.prototype.clear=jx;xi.prototype.delete=Vx;xi.prototype.get=$x;xi.prototype.has=Hx;xi.prototype.set=Gx;function On(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var h=s.get(r);if(h&&s.get(e))return h==e;var b=-1,y=!0,S=t&jv?new Gf:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=Vv}function hm(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function Bo(r){return r!=null&&typeof r=="object"}var um=Lv?_x(Lv):hE;function SE(r){return xE(r)?oE(r):uE(r)}function IE(){return[]}function ME(){return!1}Ns.exports=EE});var Ei=qe(hn());var Pl=qe(hn()),sa=qe(jn());var sr=class{};var mc=class extends sr{constructor(e){super()}},Dl=sa.FIVE_SECONDS,un={pulse:"heartbeat_pulse"},na=class r extends mc{constructor(e){super(e),this.events=new Pl.EventEmitter,this.interval=Dl,this.interval=e?.interval||Dl}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,sa.toMiliseconds)(this.interval))}pulse(){this.events.emit(un.pulse)}};var r2=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,i2=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n2=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function s2(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){o2(r);return}return e}function o2(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Bs(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!n2.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(r2.test(r)||i2.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,s2)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function a2(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ot(r,...e){try{return a2(r(...e))}catch(t){return Promise.reject(t)}}function f2(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function c2(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ks(r){if(f2(r))return String(r);if(c2(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ks(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Nl(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var yc="base64:";function Cl(r){if(typeof r=="string")return r;Nl();let e=Buffer.from(r).toString("base64");return yc+e}function Ol(r){return typeof r!="string"||!r.startsWith(yc)?r:(Nl(),Buffer.from(r.slice(yc.length),"base64"))}function Pt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Ll(...r){return Pt(r.join(":"))}function Ks(r){return r=Pt(r),r?r+":":""}var h2="memory",u2=()=>{let r=new Map;return{name:h2,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Ul(r={}){let e={mounts:{"":r.driver||u2()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=h=>{for(let b of e.mountpoints)if(h.startsWith(b))return{base:b,relativeKey:h.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:h,driver:e.mounts[""]}},i=(h,b)=>e.mountpoints.filter(y=>y.startsWith(h)||b&&h.startsWith(y)).map(y=>({relativeBase:h.length>y.length?h.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(h,b)=>{if(e.watching){b=Pt(b);for(let y of e.watchListeners)y(h,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let h in e.mounts)e.unwatch[h]=await Fl(e.mounts[h],n,h)}},o=async()=>{if(e.watching){for(let h in e.unwatch)await e.unwatch[h]();e.unwatch={},e.watching=!1}},f=(h,b,y)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of h){let T=typeof M=="string",C=Pt(T?M:M.key),P=T?void 0:M.value,U=T||!M.options?b:{...b,...M.options},B=t(C);I(B).items.push({key:C,value:P,relativeKey:B.relativeKey,options:U})}return Promise.all([...S.values()].map(M=>y(M))).then(M=>M.flat())},d={hasItem(h,b={}){h=Pt(h);let{relativeKey:y,driver:S}=t(h);return ot(S.hasItem,y,b)},getItem(h,b={}){h=Pt(h);let{relativeKey:y,driver:S}=t(h);return ot(S.getItem,y,b).then(I=>Bs(I))},getItems(h,b){return f(h,b,y=>y.driver.getItems?ot(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:Ll(y.base,I.key),value:Bs(I.value)}))):Promise.all(y.items.map(S=>ot(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Bs(I)})))))},getItemRaw(h,b={}){h=Pt(h);let{relativeKey:y,driver:S}=t(h);return S.getItemRaw?ot(S.getItemRaw,y,b):ot(S.getItem,y,b).then(I=>Ol(I))},async setItem(h,b,y={}){if(b===void 0)return d.removeItem(h);h=Pt(h);let{relativeKey:S,driver:I}=t(h);I.setItem&&(await ot(I.setItem,S,ks(b),y),I.watch||n("update",h))},async setItems(h,b){await f(h,b,async y=>{if(y.driver.setItems)return ot(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:ks(S.value),options:S.options})),b);y.driver.setItem&&await Promise.all(y.items.map(S=>ot(y.driver.setItem,S.relativeKey,ks(S.value),S.options)))})},async setItemRaw(h,b,y={}){if(b===void 0)return d.removeItem(h,y);h=Pt(h);let{relativeKey:S,driver:I}=t(h);if(I.setItemRaw)await ot(I.setItemRaw,S,b,y);else if(I.setItem)await ot(I.setItem,S,Cl(b),y);else return;I.watch||n("update",h)},async removeItem(h,b={}){typeof b=="boolean"&&(b={removeMeta:b}),h=Pt(h);let{relativeKey:y,driver:S}=t(h);S.removeItem&&(await ot(S.removeItem,y,b),(b.removeMeta||b.removeMata)&&await ot(S.removeItem,y+"$",b),S.watch||n("remove",h))},async getMeta(h,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),h=Pt(h);let{relativeKey:y,driver:S}=t(h),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ot(S.getMeta,y,b)),!b.nativeOnly){let M=await ot(S.getItem,y+"$",b).then(T=>Bs(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(h,b,y={}){return this.setItem(h+"$",b,y)},removeMeta(h,b={}){return this.removeItem(h+"$",b)},async getKeys(h,b={}){h=Ks(h);let y=i(h,!0),S=[],I=[];for(let M of y){let T=await ot(M.driver.getKeys,M.relativeBase,b);for(let C of T){let P=M.mountpoint+Pt(C);S.some(U=>P.startsWith(U))||I.push(P)}S=[M.mountpoint,...S.filter(C=>!C.startsWith(M.mountpoint))]}return h?I.filter(M=>M.startsWith(h)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(h,b={}){h=Ks(h),await Promise.all(i(h,!1).map(async y=>{if(y.driver.clear)return ot(y.driver.clear,y.relativeBase,b);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",b);return Promise.all(S.map(I=>y.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(h=>ql(h)))},async watch(h){return await s(),e.watchListeners.push(h),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==h),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(h,b){if(h=Ks(h),h&&e.mounts[h])throw new Error(`already mounted at ${h}`);return h&&(e.mountpoints.push(h),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[h]=b,e.watching&&Promise.resolve(Fl(b,n,h)).then(y=>{e.unwatch[h]=y}).catch(console.error),d},async unmount(h,b=!0){h=Ks(h),!(!h||!e.mounts[h])&&(e.watching&&h in e.unwatch&&(e.unwatch[h](),delete e.unwatch[h]),b&&await ql(e.mounts[h]),e.mountpoints=e.mountpoints.filter(y=>y!==h),delete e.mounts[h])},getMount(h=""){h=Pt(h)+":";let b=t(h);return{driver:b.driver,base:b.base}},getMounts(h="",b={}){return h=Pt(h),i(h,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(h,b={})=>d.getKeys(h,b),get:(h,b={})=>d.getItem(h,b),set:(h,b,y={})=>d.setItem(h,b,y),has:(h,b={})=>d.hasItem(h,b),del:(h,b={})=>d.removeItem(h,b),remove:(h,b={})=>d.removeItem(h,b)};return d}function Fl(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ql(r){typeof r.dispose=="function"&&await ot(r.dispose)}function dn(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function _c(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=dn(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var wc;function js(){return wc||(wc=_c("keyval-store","keyval")),wc}function xc(r,e=js()){return e("readonly",t=>dn(t.get(r)))}function zl(r,e,t=js()){return t("readwrite",i=>(i.put(e,r),dn(i.transaction)))}function Bl(r,e=js()){return e("readwrite",t=>(t.delete(r),dn(t.transaction)))}function kl(r=js()){return r("readwrite",e=>(e.clear(),dn(e.transaction)))}function d2(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},dn(r.transaction)}function Kl(r=js()){return r("readonly",e=>{if(e.getAllKeys)return dn(e.getAllKeys());let t=[];return d2(e,i=>t.push(i.key)).then(()=>t)})}var l2=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),p2=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Fr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return p2(r)}catch{return r}}function Wt(r){return typeof r=="string"?r:l2(r)||""}var g2="idb-keyval",b2=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=_c(r.dbName,r.storeName)),{name:g2,options:r,async hasItem(n){return!(typeof await xc(t(n),i)>"u")},async getItem(n){return await xc(t(n),i)??null},setItem(n,s){return zl(t(n),s,i)},removeItem(n){return Bl(t(n),i)},getKeys(){return Kl(i)},clear(){return kl(i)}}},v2="WALLET_CONNECT_V2_INDEXED_DB",m2="keyvaluestorage",Sc=class{constructor(){this.indexedDb=Ul({driver:b2({dbName:v2,storeName:m2})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Wt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},Ec=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},oa={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ec<"u"&&Ec.localStorage?oa.exports=Ec.localStorage:typeof window<"u"&&window.localStorage?oa.exports=window.localStorage:oa.exports=new e})();function y2(r){var e;return[r[0],Fr((e=r[1])!=null?e:"")]}var Ic=class{constructor(){this.localStorage=oa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(y2)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Fr(t)}async setItem(e,t){this.localStorage.setItem(e,Wt(t))}async removeItem(e){this.localStorage.removeItem(e)}},w2="wc_storage_version",jl=1,_2=async(r,e,t)=>{let i=w2,n=await e.getItem(i);if(n&&n>=jl){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let d=f.toLowerCase();if(d.includes("wc@")||d.includes("walletconnect")||d.includes("wc_")||d.includes("wallet_connect")){let h=await r.getItem(f);await e.setItem(f,h),o.push(f)}}await e.setItem(i,jl),t(e),x2(r,o)},x2=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},aa=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new Ic;this.storage=e;try{let t=new Sc;_2(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var ai=qe(Rc()),Hs=qe(Rc());var L2={level:"info"},Gs="custom_context",Nc=1e3*1024,Tc=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ha=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Tc(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},ua=class{constructor(e,t=Nc){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===ai.levels.values.error?console.error(e):t===ai.levels.values.warn?console.warn(e):t===ai.levels.values.debug?console.debug(e):t===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Wt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Wt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Dc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Pc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},F2=Object.defineProperty,q2=Object.defineProperties,U2=Object.getOwnPropertyDescriptors,Yl=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,B2=Object.prototype.propertyIsEnumerable,Xl=(r,e,t)=>e in r?F2(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e)=>{for(var t in e||(e={}))z2.call(e,t)&&Xl(r,t,e[t]);if(Yl)for(var t of Yl(e))B2.call(e,t)&&Xl(r,t,e[t]);return r},la=(r,e)=>q2(r,U2(e));function Ws(r){return la(da({},r),{level:r?.level||L2.level})}function k2(r,e=Gs){return r[e]||""}function K2(r,e,t=Gs){return r[t]=e,r}function yt(r,e=Gs){let t="";return typeof r.bindings>"u"?t=k2(r,e):t=r.bindings().context||"",t}function j2(r,e,t=Gs){let i=yt(r,t);return i.trim()?`${i}/${e}`:e}function lt(r,e,t=Gs){let i=j2(r,e,t),n=r.child({context:i});return K2(n,i,t)}function V2(r){var e,t;let i=new Dc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace",browser:la(da({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function $2(r){var e;let t=new Pc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Zl(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?V2(r):$2(r)}var Ql=qe(hn()),pa=class extends sr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var ga=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},ba=class{constructor(e,t){this.logger=e,this.core=t}},va=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}},ma=class extends sr{constructor(e){super()}},ya=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var wa=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}};var _a=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t}};var xa=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Ea=class{constructor(e,t){this.projectId=e,this.logger=t}},Sa=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Ia=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Ma=class{constructor(e){this.client=e}};var re=qe(jn());var so=qe(T0()),op=qe(Js()),ap=qe(jn());var D0="EdDSA",P0="JWT",Zs=".",Qs="base64url",Xc="utf8",Zc="utf8",N0=":",C0="did",O0="key",Qc="base58btc",L0="z",F0="K36";function eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function bn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var nh={};Dt(nh,{identity:()=>$3});function B3(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,z=new Uint8Array(B);P!==U;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,z[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");C=H,P++}for(var O=B-C;O!==B&&z[O]===0;)O++;for(var W=d.repeat(T);O>>0,B=new Uint8Array(U);M[T];){var z=t[M.charCodeAt(T)];if(z===255)return;for(var j=0,H=U-1;(z!==0||j>>0,B[H]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=U-P;L!==U&&B[L]===0;)L++;for(var O=new Uint8Array(C+(U-L)),W=C;L!==U;)O[W++]=B[L++];return O}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var k3=B3,K3=k3,q0=K3;var FI=new Uint8Array(0);var U0=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var z0=r=>new TextEncoder().encode(r),B0=r=>new TextDecoder().decode(r);var eh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},th=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K0(this,e)}},rh=class{constructor(e){this.decoders=e}or(e){return K0(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},K0=(r,e)=>new rh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ih=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,t,i),this.decoder=new th(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Yn=({name:r,prefix:e,encode:t,decode:i})=>new ih(r,e,t,i),Ri=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=q0(t,e);return Yn({prefix:r,name:e,encode:i,decode:s=>ci(n(s))})},j3=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[h++]=255&d>>f)}if(f>=t||255&d<<8-f)throw new SyntaxError("Unexpected end of data");return o},V3=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Yn({prefix:e,name:r,encode(n){return V3(n,i,t)},decode(n){return j3(n,i,t,r)}});var $3=Yn({prefix:"\0",name:"identity",encode:r=>B0(r),decode:r=>z0(r)});var sh={};Dt(sh,{base2:()=>H3});var H3=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oh={};Dt(oh,{base8:()=>G3});var G3=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah={};Dt(ah,{base10:()=>W3});var W3=Ri({prefix:"9",name:"base10",alphabet:"0123456789"});var fh={};Dt(fh,{base16:()=>J3,base16upper:()=>Y3});var J3=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y3=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ch={};Dt(ch,{base32:()=>Xn,base32hex:()=>e6,base32hexpad:()=>r6,base32hexpadupper:()=>i6,base32hexupper:()=>t6,base32pad:()=>Z3,base32padupper:()=>Q3,base32upper:()=>X3,base32z:()=>n6});var Xn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X3=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z3=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q3=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hh={};Dt(hh,{base36:()=>s6,base36upper:()=>o6});var s6=Ri({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o6=Ri({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uh={};Dt(uh,{base58btc:()=>Ur,base58flickr:()=>a6});var Ur=Ri({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),a6=Ri({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh={};Dt(dh,{base64:()=>f6,base64pad:()=>c6,base64url:()=>h6,base64urlpad:()=>u6});var f6=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),u6=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lh={};Dt(lh,{base256emoji:()=>b6});var j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),d6=j0.reduce((r,e,t)=>(r[t]=e,r),[]),l6=j0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function p6(r){return r.reduce((e,t)=>(e+=d6[t],e),"")}function g6(r){let e=[];for(let t of r){let i=l6[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var b6=Yn({prefix:"\u{1F680}",name:"base256emoji",encode:p6,decode:g6});var vh={};Dt(vh,{sha256:()=>L6,sha512:()=>F6});var v6=H0,V0=128,m6=127,y6=~m6,w6=Math.pow(2,31);function H0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=w6;)e[t++]=r&255|V0,r/=128;for(;r&y6;)e[t++]=r&255|V0,r>>>=7;return e[t]=r|0,H0.bytes=t-i+1,e}var _6=ph,x6=128,$0=127;function ph(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw ph.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&$0)<=x6);return ph.bytes=s-i,t}var E6=Math.pow(2,7),S6=Math.pow(2,14),I6=Math.pow(2,21),M6=Math.pow(2,28),A6=Math.pow(2,35),R6=Math.pow(2,42),T6=Math.pow(2,49),D6=Math.pow(2,56),P6=Math.pow(2,63),N6=function(r){return r[to.decode(r,e),to.decode.bytes],Zn=(r,e,t=0)=>(to.encode(r,e,t),e),Qn=r=>to.encodingLength(r);var vn=(r,e)=>{let t=e.byteLength,i=Qn(r),n=i+Qn(t),s=new Uint8Array(n+t);return Zn(r,s,0),Zn(t,s,i),s.set(e,n),new es(r,t,e,s)},G0=r=>{let e=ci(r),[t,i]=ro(e),[n,s]=ro(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new es(t,n,o,e)},W0=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&U0(r.bytes,e.bytes),es=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var bh=({name:r,code:e,encode:t})=>new gh(r,e,t),gh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?vn(this.code,t):t.then(i=>vn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var Y0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),L6=bh({name:"sha2-256",code:18,encode:Y0("SHA-256")}),F6=bh({name:"sha2-512",code:19,encode:Y0("SHA-512")});var mh={};Dt(mh,{identity:()=>z6});var X0=0,q6="identity",Z0=ci,U6=r=>vn(X0,Z0(r)),z6={code:X0,name:q6,encode:Z0,digest:U6};var iM=new TextEncoder,nM=new TextDecoder;var La=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oa,byteLength:Oa,code:Ca,version:Ca,multihash:Ca,bytes:Ca,_baseCache:Oa,asCID:Oa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==no)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=vn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&W0(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return j6(t,n,e||Ur.encoder);default:return V6(t,n,e||Xn.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return G6(/^0\.0/,W6),!!(e&&(e[ep]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||Q0(t,i,n.bytes))}else if(e!=null&&e[ep]===!0){let{version:t,multihash:i,code:n}=e,s=G0(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==no)throw new Error(`Version 0 CID must use dag-pb (code: ${no}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Q0(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,no,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=ci(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new es(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=ro(e.subarray(t));return t+=S,y},n=i(),s=no;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),d=i(),h=t+d,b=h-o;return{version:n,codec:s,multihashCode:f,digestSize:d,multihashSize:b,size:h}}static parse(e,t){let[i,n]=K6(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},K6=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ur;return[Ur.prefix,t.decode(`${Ur.prefix}${r}`)]}case Ur.prefix:{let t=e||Ur;return[Ur.prefix,t.decode(r)]}case Xn.prefix:{let t=e||Xn;return[Xn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},j6=(r,e,t)=>{let{prefix:i}=t;if(i!==Ur.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},V6=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},no=112,$6=18,Q0=(r,e,t)=>{let i=Qn(r),n=i+Qn(e),s=new Uint8Array(n+t.byteLength);return Zn(r,s,0),Zn(e,s,i),s.set(t,n),s},ep=Symbol.for("@ipld/js-cid/CID"),Ca={writable:!1,configurable:!1,enumerable:!0},Oa={writable:!1,enumerable:!1,configurable:!1},H6="0.0.0-dev",G6=(r,e)=>{if(r.test(H6))console.warn(e);else throw new Error(e)},W6=`CID.isCID(v) is deprecated and will be removed in the next major release. +var _y=Object.create;var Jo=Object.defineProperty;var xy=Object.getOwnPropertyDescriptor;var Ey=Object.getOwnPropertyNames;var Sy=Object.getPrototypeOf,Iy=Object.prototype.hasOwnProperty;var al=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var My=(r,e)=>()=>(r&&(e=r(r=0)),e);var Z=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Dt=(r,e)=>{for(var t in e)Jo(r,t,{get:e[t],enumerable:!0})},Wo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ey(e))!Iy.call(r,n)&&n!==t&&Jo(r,n,{get:()=>e[n],enumerable:!(i=xy(e,n))||i.enumerable});return r},qt=(r,e,t)=>(Wo(r,e,"default"),t&&Wo(t,e,"default")),qe=(r,e,t)=>(t=r!=null?_y(Sy(r)):{},Wo(e||!r||!r.__esModule?Jo(t,"default",{value:r,enumerable:!0}):t,r)),qs=r=>Wo(Jo({},"__esModule",{value:!0}),r);var un=Z((BS,uc)=>{"use strict";var qn=typeof Reflect=="object"?Reflect:null,fl=qn&&typeof qn.apply=="function"?qn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Yo;qn&&typeof qn.ownKeys=="function"?Yo=qn.ownKeys:Object.getOwnPropertySymbols?Yo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yo=function(e){return Object.getOwnPropertyNames(e)};function Ay(r){console&&console.warn&&console.warn(r)}var hl=Number.isNaN||function(e){return e!==e};function Ke(){Ke.init.call(this)}uc.exports=Ke;uc.exports.once=Py;Ke.EventEmitter=Ke;Ke.prototype._events=void 0;Ke.prototype._eventsCount=0;Ke.prototype._maxListeners=void 0;var cl=10;function Xo(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ke,"defaultMaxListeners",{enumerable:!0,get:function(){return cl},set:function(r){if(typeof r!="number"||r<0||hl(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");cl=r}});Ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ke.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||hl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ul(r){return r._maxListeners===void 0?Ke.defaultMaxListeners:r._maxListeners}Ke.prototype.getMaxListeners=function(){return ul(this)};Ke.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var u=s[e];if(u===void 0)return!1;if(typeof u=="function")fl(u,this,t);else for(var c=u.length,b=bl(u,c),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,Ay(f)}return r}Ke.prototype.addListener=function(e,t){return dl(this,e,t,!1)};Ke.prototype.on=Ke.prototype.addListener;Ke.prototype.prependListener=function(e,t){return dl(this,e,t,!0)};function Ry(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ll(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=Ry.bind(i);return n.listener=t,i.wrapFn=n,n}Ke.prototype.once=function(e,t){return Xo(t),this.on(e,ll(this,e,t)),this};Ke.prototype.prependOnceListener=function(e,t){return Xo(t),this.prependListener(e,ll(this,e,t)),this};Ke.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Xo(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Ty(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ke.prototype.off=Ke.prototype.removeListener;Ke.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function pl(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?Dy(n):bl(n,n.length)}Ke.prototype.listeners=function(e){return pl(this,e,!0)};Ke.prototype.rawListeners=function(e){return pl(this,e,!1)};Ke.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):gl.call(r,e)};Ke.prototype.listenerCount=gl;function gl(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ke.prototype.eventNames=function(){return this._eventsCount>0?Yo(this._events):[]};function bl(r,e){for(var t=new Array(e),i=0;ilc,__asyncDelegator:()=>$y,__asyncGenerator:()=>Vy,__asyncValues:()=>Hy,__await:()=>Us,__awaiter:()=>Uy,__classPrivateFieldGet:()=>Yy,__classPrivateFieldSet:()=>Xy,__createBinding:()=>By,__decorate:()=>Ly,__exportStar:()=>ky,__extends:()=>Cy,__generator:()=>zy,__importDefault:()=>Jy,__importStar:()=>Wy,__makeTemplateObject:()=>Gy,__metadata:()=>qy,__param:()=>Fy,__read:()=>ml,__rest:()=>Oy,__spread:()=>Ky,__spreadArrays:()=>jy,__values:()=>pc});function Cy(r,e){dc(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Fy(r,e){return function(t,i){e(t,i,r)}}function qy(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Uy(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{c(i.next(b))}catch(v){o(v)}}function u(b){try{c(i.throw(b))}catch(v){o(v)}}function c(b){b.done?s(b.value):n(b.value).then(f,u)}c((i=i.apply(r,e||[])).next())})}function zy(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(c){return function(b){return u([c,b])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=c[0]&2?n.return:c[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,c[1])).done)return s;switch(n=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,n=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ml(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Ky(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{u(i[S](I))}catch(M){v(s[0][3],M)}}function u(S){S.value instanceof Us?Promise.resolve(S.value.v).then(c,b):v(s[0][2],S)}function c(S){f("next",S)}function b(S){f("throw",S)}function v(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function $y(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Us(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function Hy(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof pc=="function"?pc(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(c){s({value:c,done:f})},o)}}function Gy(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wy(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function Jy(r){return r&&r.__esModule?r:{default:r}}function Yy(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Xy(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var dc,lc,zn=My(()=>{dc=function(r,e){return dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},dc(r,e)};lc=function(){return lc=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.delay=void 0;function Zy(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Zo.delay=Zy});var wl=Z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.ONE_THOUSAND=Bn.ONE_HUNDRED=void 0;Bn.ONE_HUNDRED=100;Bn.ONE_THOUSAND=1e3});var _l=Z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.ONE_YEAR=Q.FOUR_WEEKS=Q.THREE_WEEKS=Q.TWO_WEEKS=Q.ONE_WEEK=Q.THIRTY_DAYS=Q.SEVEN_DAYS=Q.FIVE_DAYS=Q.THREE_DAYS=Q.ONE_DAY=Q.TWENTY_FOUR_HOURS=Q.TWELVE_HOURS=Q.SIX_HOURS=Q.THREE_HOURS=Q.ONE_HOUR=Q.SIXTY_MINUTES=Q.THIRTY_MINUTES=Q.TEN_MINUTES=Q.FIVE_MINUTES=Q.ONE_MINUTE=Q.SIXTY_SECONDS=Q.THIRTY_SECONDS=Q.TEN_SECONDS=Q.FIVE_SECONDS=Q.ONE_SECOND=void 0;Q.ONE_SECOND=1;Q.FIVE_SECONDS=5;Q.TEN_SECONDS=10;Q.THIRTY_SECONDS=30;Q.SIXTY_SECONDS=60;Q.ONE_MINUTE=Q.SIXTY_SECONDS;Q.FIVE_MINUTES=Q.ONE_MINUTE*5;Q.TEN_MINUTES=Q.ONE_MINUTE*10;Q.THIRTY_MINUTES=Q.ONE_MINUTE*30;Q.SIXTY_MINUTES=Q.ONE_MINUTE*60;Q.ONE_HOUR=Q.SIXTY_MINUTES;Q.THREE_HOURS=Q.ONE_HOUR*3;Q.SIX_HOURS=Q.ONE_HOUR*6;Q.TWELVE_HOURS=Q.ONE_HOUR*12;Q.TWENTY_FOUR_HOURS=Q.ONE_HOUR*24;Q.ONE_DAY=Q.TWENTY_FOUR_HOURS;Q.THREE_DAYS=Q.ONE_DAY*3;Q.FIVE_DAYS=Q.ONE_DAY*5;Q.SEVEN_DAYS=Q.ONE_DAY*7;Q.THIRTY_DAYS=Q.ONE_DAY*30;Q.ONE_WEEK=Q.SEVEN_DAYS;Q.TWO_WEEKS=Q.ONE_WEEK*2;Q.THREE_WEEKS=Q.ONE_WEEK*3;Q.FOUR_WEEKS=Q.ONE_WEEK*4;Q.ONE_YEAR=Q.ONE_DAY*365});var gc=Z(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});var xl=(zn(),qs(Un));xl.__exportStar(wl(),Qo);xl.__exportStar(_l(),Qo)});var Sl=Z(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.fromMiliseconds=kn.toMiliseconds=void 0;var El=gc();function Qy(r){return r*El.ONE_THOUSAND}kn.toMiliseconds=Qy;function e2(r){return Math.floor(r/El.ONE_THOUSAND)}kn.fromMiliseconds=e2});var Ml=Z(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var Il=(zn(),qs(Un));Il.__exportStar(yl(),ea);Il.__exportStar(Sl(),ea)});var Al=Z(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.Watch=void 0;var ta=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};zs.Watch=ta;zs.default=ta});var Rl=Z(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.IWatch=void 0;var bc=class{};ra.IWatch=bc});var Tl=Z(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var t2=(zn(),qs(Un));t2.__exportStar(Rl(),vc)});var jn=Z(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var ia=(zn(),qs(Un));ia.__exportStar(Ml(),Kn);ia.__exportStar(Al(),Kn);ia.__exportStar(Tl(),Kn);ia.__exportStar(gc(),Kn)});var $l=Z((lI,Vl)=>{"use strict";function E2(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}Vl.exports=S2;function S2(r,e,t){var i=t&&t.stringify||E2,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?v:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=u||e[b]==null)break;v=u||e[b]==null)break;v=u||e[b]===void 0)break;v",v=I+2,I++;break}c+=i(e[b]),v=I+2,I++;break;case 115:if(b>=u)break;v{"use strict";var Hl=$l();Jl.exports=qr;var Vs=O2().console||{},I2={mapHttpRequest:fa,mapHttpResponse:fa,wrapRequestSerializer:Mc,wrapResponseSerializer:Mc,wrapErrorSerializer:Mc,req:fa,res:fa,err:D2};function M2(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function qr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||Vs;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=M2(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",u=Object.create(t);u.log||(u.log=$s),Object.defineProperty(u,"levelVal",{get:b}),Object.defineProperty(u,"level",{get:v,set:S});let c={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:P2(r)};u.levels=qr.levels,u.level=f,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=$s,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=I,e&&(u._logEvent=Ac());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function v(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,Vn(c,u,"error","log"),Vn(c,u,"fatal","error"),Vn(c,u,"warn","error"),Vn(c,u,"info","log"),Vn(c,u,"debug","log"),Vn(c,u,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let O=T.serializers;if(n&&O){var P=Object.assign({},i,O),z=r.browser.serialize===!0?Object.keys(P):n;delete M.serializers,ca([M],z,P,this._stdErrSerialize)}function B(U){this._childLevel=(U._childLevel|0)+1,this.error=$n(U,M,"error"),this.fatal=$n(U,M,"fatal"),this.warn=$n(U,M,"warn"),this.info=$n(U,M,"info"),this.debug=$n(U,M,"debug"),this.trace=$n(U,M,"trace"),P&&(this.serializers=P,this._serialize=z),e&&(this._logEvent=Ac([].concat(U._logEvent.bindings,M)))}return B.prototype=this,new B(this)}return u}qr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};qr.stdSerializers=I2;qr.stdTimeFunctions=Object.assign({},{nullTime:Gl,epochTime:Wl,unixTime:N2,isoTime:C2});function Vn(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?$s:n[t]?n[t]:Vs[t]||Vs[i]||$s,A2(r,e,t)}function A2(r,e,t){!r.transmit&&e[t]===$s||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Vs?Vs:this;for(var u=0;u-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function $n(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.BrowserRandomSource=void 0;var e0=65536,Cc=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function H2(r){for(var e=0;e{});var r0=Z(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.NodeRandomSource=void 0;var G2=Jt(),Fc=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof al<"u"){let e=Lc();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.SystemRandomSource=void 0;var W2=t0(),J2=r0(),qc=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new W2.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new J2.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Ta.SystemRandomSource=qc});var n0=Z(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Y2(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Ut.mul=Math.imul||Y2;function X2(r,e){return r+e|0}Ut.add=X2;function Z2(r,e){return r-e|0}Ut.sub=Z2;function Q2(r,e){return r<>>32-e}Ut.rotl=Q2;function e3(r,e){return r<<32-e|r>>>e}Ut.rotr=e3;function t3(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Ut.isInteger=Number.isInteger||t3;Ut.MAX_SAFE_INTEGER=9007199254740991;Ut.isSafeInteger=function(r){return Ut.isInteger(r)&&r>=-Ut.MAX_SAFE_INTEGER&&r<=Ut.MAX_SAFE_INTEGER}});var Hn=Z(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var s0=n0();function r3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Le.readInt16BE=r3;function i3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Le.readUint16BE=i3;function n3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Le.readInt16LE=n3;function s3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Le.readUint16LE=s3;function o0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Le.writeUint16BE=o0;Le.writeInt16BE=o0;function a0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Le.writeUint16LE=a0;Le.writeInt16LE=a0;function Uc(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Le.readInt32BE=Uc;function zc(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Le.readUint32BE=zc;function Bc(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Le.readInt32LE=Bc;function kc(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Le.readUint32LE=kc;function Da(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Le.writeUint32BE=Da;Le.writeInt32BE=Da;function Pa(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Le.writeUint32LE=Pa;Le.writeInt32LE=Pa;function o3(r,e){e===void 0&&(e=0);var t=Uc(r,e),i=Uc(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Le.readInt64BE=o3;function a3(r,e){e===void 0&&(e=0);var t=zc(r,e),i=zc(r,e+4);return t*4294967296+i}Le.readUint64BE=a3;function f3(r,e){e===void 0&&(e=0);var t=Bc(r,e),i=Bc(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Le.readInt64LE=f3;function c3(r,e){e===void 0&&(e=0);var t=kc(r,e),i=kc(r,e+4);return i*4294967296+t}Le.readUint64LE=c3;function f0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Da(r/4294967296>>>0,e,t),Da(r>>>0,e,t+4),e}Le.writeUint64BE=f0;Le.writeInt64BE=f0;function c0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Pa(r>>>0,e,t),Pa(r/4294967296>>>0,e,t+4),e}Le.writeUint64LE=c0;Le.writeInt64LE=c0;function h3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Le.readUintBE=h3;function u3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Le.writeUintBE=d3;function l3(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!s0.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.randomStringForEntropy=wt.randomString=wt.randomUint32=wt.randomBytes=wt.defaultRandomSource=void 0;var x3=i0(),E3=Hn(),h0=Jt();wt.defaultRandomSource=new x3.SystemRandomSource;function Kc(r,e=wt.defaultRandomSource){return e.randomBytes(r)}wt.randomBytes=Kc;function S3(r=wt.defaultRandomSource){let e=Kc(4,r),t=(0,E3.readUint32LE)(e);return(0,h0.wipe)(e),t}wt.randomUint32=S3;var u0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function d0(r,e=u0,t=wt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Kc(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let u=o[f];u{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});var Wn=Hn(),Gn=Jt();fi.DIGEST_LENGTH=64;fi.BLOCK_SIZE=128;var p0=function(){function r(){this.digestLength=fi.DIGEST_LENGTH,this.blockSize=fi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Gn.wipe(this._buffer),Gn.wipe(this._tempHi),Gn.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Gn.wipe(e.stateHi),Gn.wipe(e.stateLo),e.buffer&&Gn.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();fi.SHA512=p0;var l0=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function jc(r,e,t,i,n,s,o){for(var f=t[0],u=t[1],c=t[2],b=t[3],v=t[4],S=t[5],I=t[6],M=t[7],T=i[0],O=i[1],P=i[2],z=i[3],B=i[4],U=i[5],j=i[6],H=i[7],L,C,W,D,l,w,p,a;o>=128;){for(var d=0;d<16;d++){var m=8*d+s;r[d]=Wn.readUint32BE(n,m),e[d]=Wn.readUint32BE(n,m+4)}for(var d=0;d<80;d++){var _=f,y=u,h=c,x=b,A=v,g=S,R=I,k=M,E=T,N=O,F=P,q=z,K=B,J=U,$=j,V=H;if(L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(v>>>14|B<<18)^(v>>>18|B<<14)^(B>>>9|v<<23),C=(B>>>14|v<<18)^(B>>>18|v<<14)^(v>>>9|B<<23),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=v&S^~v&I,C=B&U^~B&j,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=l0[d*2],C=l0[d*2+1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=r[d%16],C=e[d%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,W=p&65535|a<<16,D=l&65535|w<<16,L=W,C=D,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),C=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=f&u^f&c^u&c,C=T&O^T&P^O&P,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,k=p&65535|a<<16,V=l&65535|w<<16,L=x,C=q,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=W,C=D,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,q=l&65535|w<<16,u=_,c=y,b=h,v=x,S=A,I=g,M=R,f=k,O=E,P=N,z=F,B=q,U=K,j=J,H=$,T=V,d%16===15)for(var m=0;m<16;m++)L=r[m],C=e[m],l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=r[(m+9)%16],C=e[(m+9)%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+1)%16],D=e[(m+1)%16],L=(W>>>1|D<<31)^(W>>>8|D<<24)^W>>>7,C=(D>>>1|W<<31)^(D>>>8|W<<24)^(D>>>7|W<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+14)%16],D=e[(m+14)%16],L=(W>>>19|D<<13)^(D>>>29|W<<3)^W>>>6,C=(D>>>19|W<<13)^(W>>>29|D<<3)^(D>>>6|W<<26),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[m]=p&65535|a<<16,e[m]=l&65535|w<<16}L=f,C=T,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[0],C=i[0],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=u,C=O,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[1],C=i[1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=u=p&65535|a<<16,i[1]=O=l&65535|w<<16,L=c,C=P,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[2],C=i[2],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=c=p&65535|a<<16,i[2]=P=l&65535|w<<16,L=b,C=z,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[3],C=i[3],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=z=l&65535|w<<16,L=v,C=B,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[4],C=i[4],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=v=p&65535|a<<16,i[4]=B=l&65535|w<<16,L=S,C=U,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[5],C=i[5],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=U=l&65535|w<<16,L=I,C=j,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[6],C=i[6],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=j=l&65535|w<<16,L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[7],C=i[7],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=H=l&65535|w<<16,s+=128,o-=128}return s}function M3(r){var e=new p0;e.update(r);var t=e.digest();return e.clean(),t}fi.hash=M3});var T0=Z(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var A3=Js(),Ys=g0(),w0=Jt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function te(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,_0(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function x0(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function m0(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Xs(t,r),Xs(i,e),x0(t,i)}function E0(r){let e=new Uint8Array(32);return Xs(e,r),e[0]&1}function N3(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function pn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function bn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function je(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function gn(r,e){je(r,e,e)}function S0(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)gn(t,t),i!==2&&i!==4&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function C3(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)gn(t,t),i!==1&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Gc(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te(),c=te(),b=te();bn(t,r[1],r[0]),bn(b,e[1],e[0]),je(t,t,b),pn(i,r[0],r[1]),pn(b,e[0],e[1]),je(i,i,b),je(n,r[3],e[3]),je(n,n,D3),je(s,r[2],e[2]),pn(s,s,s),bn(o,i,t),bn(f,s,n),pn(u,s,n),pn(c,i,t),je(r[0],o,f),je(r[1],c,u),je(r[2],u,f),je(r[3],o,c)}function y0(r,e,t){for(let i=0;i<4;i++)_0(r[i],e[i],t)}function Jc(r,e){let t=te(),i=te(),n=te();S0(n,e[2]),je(t,e[0],n),je(i,e[1],n),Xs(r,i),r[31]^=E0(t)<<7}function I0(r,e,t){Ri(r[0],Hc),Ri(r[1],Jn),Ri(r[2],Jn),Ri(r[3],Hc);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;y0(r,e,n),Gc(e,r),Gc(r,r),y0(r,e,n)}}function Yc(r,e){let t=[te(),te(),te(),te()];Ri(t[0],b0),Ri(t[1],v0),Ri(t[2],Jn),je(t[3],b0,v0),I0(r,t,e)}function M0(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ys.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[te(),te(),te(),te()];Yc(i,e),Jc(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=M0;function O3(r){let e=(0,A3.randomBytes)(32,r),t=M0(e);return(0,w0.wipe)(e),t}ze.generateKeyPair=O3;function L3(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=L3;var $c=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function A0(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*$c[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*$c[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Wc(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;A0(r,e)}function F3(r,e){let t=new Float64Array(64),i=[te(),te(),te(),te()],n=(0,Ys.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ys.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Wc(f),Yc(i,f),Jc(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let u=o.digest();Wc(u);for(let c=0;c<32;c++)t[c]=f[c];for(let c=0;c<32;c++)for(let b=0;b<32;b++)t[c+b]+=u[c]*n[b];return A0(s.subarray(32),t),s}ze.sign=F3;function R0(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te();return Ri(r[2],Jn),N3(r[1],e),gn(n,r[1]),je(s,n,T3),bn(n,n,r[2]),pn(s,r[2],s),gn(o,s),gn(f,o),je(u,f,o),je(t,u,n),je(t,t,s),C3(t,t),je(t,t,n),je(t,t,s),je(t,t,s),je(r[0],t,s),gn(i,r[0]),je(i,i,s),m0(i,n)&&je(r[0],r[0],P3),gn(i,r[0]),je(i,i,s),m0(i,n)?-1:(E0(r[0])===e[31]>>7&&bn(r[0],Hc,r[0]),je(r[3],r[0],r[1]),0)}function q3(r,e,t){let i=new Uint8Array(32),n=[te(),te(),te(),te()],s=[te(),te(),te(),te()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(R0(s,r))return!1;let o=new Ys.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Wc(f),I0(n,s,f),Yc(s,t.subarray(32)),Gc(n,s),Jc(i,n),!x0(t,i)}ze.verify=q3;function U3(r){let e=[te(),te(),te(),te()];if(R0(e,r))throw new Error("Ed25519: invalid public key");let t=te(),i=te(),n=e[1];pn(t,Jn,n),bn(i,Jn,n),S0(i,i),je(t,t,i);let s=new Uint8Array(32);return Xs(s,t),s}ze.convertPublicKeyToX25519=U3;function z3(r){let e=(0,Ys.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,w0.wipe)(e),t}ze.convertSecretKeyToX25519=z3});var za=Z(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.getLocalStorage=He.getLocalStorageOrThrow=He.getCrypto=He.getCryptoOrThrow=He.getLocation=He.getLocationOrThrow=He.getNavigator=He.getNavigatorOrThrow=He.getDocument=He.getDocumentOrThrow=He.getFromWindowOrThrow=He.getFromWindow=void 0;function yn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}He.getFromWindow=yn;function rs(r){let e=yn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}He.getFromWindowOrThrow=rs;function dw(){return rs("document")}He.getDocumentOrThrow=dw;function lw(){return yn("document")}He.getDocument=lw;function pw(){return rs("navigator")}He.getNavigatorOrThrow=pw;function gw(){return yn("navigator")}He.getNavigator=gw;function bw(){return rs("location")}He.getLocationOrThrow=bw;function vw(){return yn("location")}He.getLocation=vw;function mw(){return rs("crypto")}He.getCryptoOrThrow=mw;function yw(){return yn("crypto")}He.getCrypto=yw;function ww(){return rs("localStorage")}He.getLocalStorageOrThrow=ww;function _w(){return yn("localStorage")}He.getLocalStorage=_w});var gp=Z(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.getWindowMetadata=void 0;var pp=za();function xw(){let r,e;try{r=pp.getDocumentOrThrow(),e=pp.getLocationOrThrow()}catch{return null}function t(){let v=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=M.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let P=e.protocol+"//"+e.host;if(O.indexOf("/")===0)P+=O;else{let z=e.pathname.split("/");z.pop();let B=z.join("/");P+=B+"/"+O}S.push(P)}else if(O.indexOf("//")===0){let P=e.protocol+O;S.push(P)}else S.push(O)}}return S}function i(...v){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(O)).filter(O=>O?v.includes(O):!1);if(T.length&&T){let O=M.getAttribute("content");if(O)return O}}return""}function n(){let v=i("name","og:site_name","og:title","twitter:title");return v||(v=r.title),v}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),u=e.origin,c=t();return{description:f,url:u,icons:c,name:o}}Ba.getWindowMetadata=xw});var vp=Z((zM,bp)=>{"use strict";bp.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var xp=Z((BM,_p)=>{"use strict";var wp="%[a-f0-9]{2}",mp=new RegExp("("+wp+")|([^%]+?)","gi"),yp=new RegExp("("+wp+")+","gi");function xh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],xh(t),xh(i))}function Ew(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(mp)||[],t=1;t{"use strict";Ep.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Mp=Z((KM,Ip)=>{"use strict";Ip.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Iw=vp(),Mw=xp(),Rp=Sp(),Aw=Mp(),Rw=r=>r==null,Eh=Symbol("encodeFragmentIdentifier");function Tw(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[",n,"]"].join("")]:[...t,[it(e,r),"[",it(n,r),"]=",it(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[]"].join("")]:[...t,[it(e,r),"[]=",it(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),":list="].join("")]:[...t,[it(e,r),":list=",it(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[it(t,r),e,it(n,r)].join("")]:[[i,it(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,it(e,r)]:[...t,[it(e,r),"=",it(i,r)].join("")]}}function Dw(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&hi(i,r).includes(r.arrayFormatSeparator);i=o?hi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(u=>hi(u,r)):i===null?i:hi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&hi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>hi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Tp(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function it(r,e){return e.encode?e.strict?Iw(r):encodeURIComponent(r):r}function hi(r,e){return e.decode?Mw(r):r}function Dp(r){return Array.isArray(r)?r.sort():typeof r=="object"?Dp(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Pp(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Pw(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Np(r){r=Pp(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ap(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Cp(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Tp(e.arrayFormatSeparator);let t=Dw(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Rp(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:hi(o,e),t(hi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ap(s[o],e);else i[n]=Ap(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Dp(o):n[s]=o,n},Object.create(null))}Ct.extract=Np;Ct.parse=Cp;Ct.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Tp(e.arrayFormatSeparator);let t=o=>e.skipNull&&Rw(r[o])||e.skipEmptyString&&r[o]==="",i=Tw(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?it(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?it(o,e)+"[]":f.reduce(i(o),[]).join("&"):it(o,e)+"="+it(f,e)}).filter(o=>o.length>0).join("&")};Ct.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Rp(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Cp(Np(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:hi(i,e)}:{})};Ct.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Eh]:!0},e);let t=Pp(r.url).split("?")[0]||"",i=Ct.extract(r.url),n=Ct.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ct.stringify(s,e);o&&(o=`?${o}`);let f=Pw(r.url);return r.fragmentIdentifier&&(f=`#${e[Eh]?it(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ct.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Eh]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ct.parseUrl(r,t);return Ct.stringifyUrl({url:i,query:Aw(n,e),fragmentIdentifier:s},t)};Ct.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ct.pick(r,i,t)}});var Lp=Z((VM,ka)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=window:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ka=="object"&&ka.exports,f=typeof define=="function"&&define.amd,u=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],v=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],P=[128,256],z=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),u&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var U=function(E,N,F){return function(q){return new g(E,N,E).update(q)[F]()}},j=function(E,N,F){return function(q,K){return new g(E,N,K).update(q)[F]()}},H=function(E,N,F){return function(q,K,J,$){return a["cshake"+E].update(q,K,J,$)[F]()}},L=function(E,N,F){return function(q,K,J,$){return a["kmac"+E].update(q,K,J,$)[F]()}},C=function(E,N,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}for(var q=this.blocks,K=this.byteCount,J=E.length,$=this.blockCount,V=0,ee=this.s,G,Y;V>2]|=E[V]<>2]|=Y<>2]|=(192|Y>>6)<>2]|=(128|Y&63)<=57344?(q[G>>2]|=(224|Y>>12)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<>2]|=(240|Y>>18)<>2]|=(128|Y>>12&63)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<=K){for(this.start=G-K,this.block=q[$],G=0;G<$;++G)ee[G]^=q[G];k(ee),this.reset=!0}else this.start=G}return this},g.prototype.encode=function(E,N){var F=E&255,q=1,K=[F];for(E=E>>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return N?K.push(q):K.unshift(q),this.update(K),K.length},g.prototype.encodeString=function(E){var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}var q=0,K=E.length;if(N)q=K;else for(var J=0;J=57344?q+=3:($=65536+(($&1023)<<10|E.charCodeAt(++J)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},g.prototype.bytepad=function(E,N){for(var F=this.encode(N),q=0;q>2]|=this.padding[N&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],N=1;N>4&15]+c[V&15]+c[V>>12&15]+c[V>>8&15]+c[V>>20&15]+c[V>>16&15]+c[V>>28&15]+c[V>>24&15];J%E===0&&(k(N),K=0)}return q&&(V=N[K],$+=c[V>>4&15]+c[V&15],q>1&&($+=c[V>>12&15]+c[V>>8&15]),q>2&&($+=c[V>>20&15]+c[V>>16&15])),$},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,N=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,J=0,$=this.outputBits>>3,V;q?V=new ArrayBuffer(F+1<<2):V=new ArrayBuffer($);for(var ee=new Uint32Array(V);J>8&255,$[V+2]=ee>>16&255,$[V+3]=ee>>24&255;J%E===0&&k(N)}return q&&(V=J<<2,ee=N[K],$[V]=ee&255,q>1&&($[V+1]=ee>>8&255),q>2&&($[V+2]=ee>>16&255)),$};function R(E,N,F){g.call(this,E,N,F)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var k=function(E){var N,F,q,K,J,$,V,ee,G,Y,_r,ie,ne,xr,se,oe,Er,ae,fe,Sr,ce,he,Ir,ue,de,Mr,le,pe,Ar,ge,be,Rr,ve,me,Tr,ye,we,Dr,_e,xe,Pr,Ee,Se,Nr,Ie,Me,Cr,Ae,Re,Or,Te,De,Lr,Pe,Ne,nr,Be,ke,jt,Vt,$t,Ht,Gt;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],J=E[1]^E[11]^E[21]^E[31]^E[41],$=E[2]^E[12]^E[22]^E[32]^E[42],V=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],Y=E[6]^E[16]^E[26]^E[36]^E[46],_r=E[7]^E[17]^E[27]^E[37]^E[47],ie=E[8]^E[18]^E[28]^E[38]^E[48],ne=E[9]^E[19]^E[29]^E[39]^E[49],N=ie^($<<1|V>>>31),F=ne^(V<<1|$>>>31),E[0]^=N,E[1]^=F,E[10]^=N,E[11]^=F,E[20]^=N,E[21]^=F,E[30]^=N,E[31]^=F,E[40]^=N,E[41]^=F,N=K^(ee<<1|G>>>31),F=J^(G<<1|ee>>>31),E[2]^=N,E[3]^=F,E[12]^=N,E[13]^=F,E[22]^=N,E[23]^=F,E[32]^=N,E[33]^=F,E[42]^=N,E[43]^=F,N=$^(Y<<1|_r>>>31),F=V^(_r<<1|Y>>>31),E[4]^=N,E[5]^=F,E[14]^=N,E[15]^=F,E[24]^=N,E[25]^=F,E[34]^=N,E[35]^=F,E[44]^=N,E[45]^=F,N=ee^(ie<<1|ne>>>31),F=G^(ne<<1|ie>>>31),E[6]^=N,E[7]^=F,E[16]^=N,E[17]^=F,E[26]^=N,E[27]^=F,E[36]^=N,E[37]^=F,E[46]^=N,E[47]^=F,N=Y^(K<<1|J>>>31),F=_r^(J<<1|K>>>31),E[8]^=N,E[9]^=F,E[18]^=N,E[19]^=F,E[28]^=N,E[29]^=F,E[38]^=N,E[39]^=F,E[48]^=N,E[49]^=F,xr=E[0],se=E[1],Me=E[11]<<4|E[10]>>>28,Cr=E[10]<<4|E[11]>>>28,pe=E[20]<<3|E[21]>>>29,Ar=E[21]<<3|E[20]>>>29,Vt=E[31]<<9|E[30]>>>23,$t=E[30]<<9|E[31]>>>23,Ee=E[40]<<18|E[41]>>>14,Se=E[41]<<18|E[40]>>>14,me=E[2]<<1|E[3]>>>31,Tr=E[3]<<1|E[2]>>>31,oe=E[13]<<12|E[12]>>>20,Er=E[12]<<12|E[13]>>>20,Ae=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,ge=E[33]<<13|E[32]>>>19,be=E[32]<<13|E[33]>>>19,Ht=E[42]<<2|E[43]>>>30,Gt=E[43]<<2|E[42]>>>30,Pe=E[5]<<30|E[4]>>>2,Ne=E[4]<<30|E[5]>>>2,ye=E[14]<<6|E[15]>>>26,we=E[15]<<6|E[14]>>>26,ae=E[25]<<11|E[24]>>>21,fe=E[24]<<11|E[25]>>>21,Or=E[34]<<15|E[35]>>>17,Te=E[35]<<15|E[34]>>>17,Rr=E[45]<<29|E[44]>>>3,ve=E[44]<<29|E[45]>>>3,ue=E[6]<<28|E[7]>>>4,de=E[7]<<28|E[6]>>>4,nr=E[17]<<23|E[16]>>>9,Be=E[16]<<23|E[17]>>>9,Dr=E[26]<<25|E[27]>>>7,_e=E[27]<<25|E[26]>>>7,Sr=E[36]<<21|E[37]>>>11,ce=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Lr=E[46]<<24|E[47]>>>8,Nr=E[8]<<27|E[9]>>>5,Ie=E[9]<<27|E[8]>>>5,Mr=E[18]<<20|E[19]>>>12,le=E[19]<<20|E[18]>>>12,ke=E[29]<<7|E[28]>>>25,jt=E[28]<<7|E[29]>>>25,xe=E[38]<<8|E[39]>>>24,Pr=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Ir=E[49]<<14|E[48]>>>18,E[0]=xr^~oe&ae,E[1]=se^~Er&fe,E[10]=ue^~Mr&pe,E[11]=de^~le&Ar,E[20]=me^~ye&Dr,E[21]=Tr^~we&_e,E[30]=Nr^~Me&Ae,E[31]=Ie^~Cr&Re,E[40]=Pe^~nr&ke,E[41]=Ne^~Be&jt,E[2]=oe^~ae&Sr,E[3]=Er^~fe&ce,E[12]=Mr^~pe&ge,E[13]=le^~Ar&be,E[22]=ye^~Dr&xe,E[23]=we^~_e&Pr,E[32]=Me^~Ae&Or,E[33]=Cr^~Re&Te,E[42]=nr^~ke&Vt,E[43]=Be^~jt&$t,E[4]=ae^~Sr&he,E[5]=fe^~ce&Ir,E[14]=pe^~ge&Rr,E[15]=Ar^~be&ve,E[24]=Dr^~xe&Ee,E[25]=_e^~Pr&Se,E[34]=Ae^~Or&De,E[35]=Re^~Te&Lr,E[44]=ke^~Vt&Ht,E[45]=jt^~$t&Gt,E[6]=Sr^~he&xr,E[7]=ce^~Ir&se,E[16]=ge^~Rr&ue,E[17]=be^~ve&de,E[26]=xe^~Ee&me,E[27]=Pr^~Se&Tr,E[36]=Or^~De&Nr,E[37]=Te^~Lr&Ie,E[46]=Vt^~Ht&Pe,E[47]=$t^~Gt&Ne,E[8]=he^~xr&oe,E[9]=Ir^~se&Er,E[18]=Rr^~ue&Mr,E[19]=ve^~de&le,E[28]=Ee^~me&ye,E[29]=Se^~Tr&we,E[38]=De^~Nr&Me,E[39]=Lr^~Ie&Cr,E[48]=Ht^~Pe&nr,E[49]=Gt^~Ne&Be,E[0]^=T[q],E[1]^=T[q+1]};if(o)ka.exports=a;else{for(m=0;m{});var Ph=Z((Gp,Dh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var d=function(){};d.prototype=a.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,a,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(d=a,a=10),this._init(p||0,a||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,d){return a.cmp(d)>0?a:d},n.min=function(a,d){return a.cmp(d)<0?a:d},n.prototype._init=function(a,d,m){if(typeof a=="number")return this._initNumber(a,d,m);if(typeof a=="object")return this._initArray(a,d,m);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)h=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[y]|=h<>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);else if(m==="le")for(_=0,y=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);return this._strip()};function o(p,a){var d=p.charCodeAt(a);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function f(p,a,d){var m=o(p,d);return d-1>=a&&(m|=o(p,d-1)<<4),m}n.prototype._parseHex=function(a,d,m){this.length=Math.ceil((a.length-d)/6),this.words=new Array(this.length);for(var _=0;_=d;_-=2)x=f(a,d,_)<=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8;else{var A=a.length-d;for(_=A%2===0?d+1:d;_=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8}this._strip()};function u(p,a,d,m){for(var _=0,y=0,h=Math.min(p.length,d),x=a;x=49?y=A-49+10:A>=17?y=A-17+10:y=A,t(A>=0&&y1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var v=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,d){a=a||10,d=d|0||1;var m;if(a===16||a==="hex"){m="";for(var _=0,y=0,h=0;h>>24-_&16777215,_+=2,_>=26&&(_-=26,h--),y!==0||h!==this.length-1?m=v[6-A.length]+A+m:m=A+m}for(y!==0&&(m=y.toString(16)+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];m="";var k=this.clone();for(k.negative=0;!k.isZero();){var E=k.modrn(R).toString(a);k=k.idivn(R),k.isZero()?m=E+m:m=v[g-E.length]+E+m}for(this.isZero()&&(m="0"+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,d){return this.toArrayLike(s,a,d)}),n.prototype.toArray=function(a,d){return this.toArrayLike(Array,a,d)};var M=function(a,d){return a.allocUnsafe?a.allocUnsafe(d):new a(d)};n.prototype.toArrayLike=function(a,d,m){this._strip();var _=this.byteLength(),y=m||Math.max(1,_);t(_<=y,"byte array longer than desired length"),t(y>0,"Requested array length <= 0");var h=M(a,y),x=d==="le"?"LE":"BE";return this["_toArrayLike"+x](h,_),h},n.prototype._toArrayLikeLE=function(a,d){for(var m=0,_=0,y=0,h=0;y>8&255),m>16&255),h===6?(m>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m=0&&(a[m--]=x>>8&255),m>=0&&(a[m--]=x>>16&255),h===6?(m>=0&&(a[m--]=x>>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m>=0)for(a[m--]=_;m>=0;)a[m--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var d=a,m=0;return d>=4096&&(m+=13,d>>>=13),d>=64&&(m+=7,d>>>=7),d>=8&&(m+=4,d>>>=4),d>=2&&(m+=2,d>>>=2),m+d},n.prototype._zeroBits=function(a){if(a===0)return 26;var d=a,m=0;return d&8191||(m+=13,d>>>=13),d&127||(m+=7,d>>>=7),d&15||(m+=4,d>>>=4),d&3||(m+=2,d>>>=2),d&1||m++,m},n.prototype.bitLength=function(){var a=this.words[this.length-1],d=this._countBits(a);return(this.length-1)*26+d};function T(p){for(var a=new Array(p.bitLength()),d=0;d>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,d=0;da.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var d;this.length>a.length?d=a:d=this;for(var m=0;ma.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var d,m;this.length>a.length?(d=this,m=a):(d=a,m=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var d=Math.ceil(a/26)|0,m=a%26;this._expand(d),m>0&&d--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-m),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,d){t(typeof a=="number"&&a>=0);var m=a/26|0,_=a%26;return this._expand(m+1),d?this.words[m]=this.words[m]|1<<_:this.words[m]=this.words[m]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var d;if(this.negative!==0&&a.negative===0)return this.negative=0,d=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,d=this.isub(a),a.negative=1,d._normSign();var m,_;this.length>a.length?(m=this,_=a):(m=a,_=this);for(var y=0,h=0;h<_.length;h++)d=(m.words[h]|0)+(_.words[h]|0)+y,this.words[h]=d&67108863,y=d>>>26;for(;y!==0&&h>>26;if(this.length=m.length,y!==0)this.words[this.length]=y,this.length++;else if(m!==this)for(;ha.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var d=this.iadd(a);return a.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var m=this.cmp(a);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,y;m>0?(_=this,y=a):(_=a,y=this);for(var h=0,x=0;x>26,this.words[x]=d&67108863;for(;h!==0&&x<_.length;x++)d=(_.words[x]|0)+h,h=d>>26,this.words[x]=d&67108863;if(h===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function O(p,a,d){d.negative=a.negative^p.negative;var m=p.length+a.length|0;d.length=m,m=m-1|0;var _=p.words[0]|0,y=a.words[0]|0,h=_*y,x=h&67108863,A=h/67108864|0;d.words[0]=x;for(var g=1;g>>26,k=A&67108863,E=Math.min(g,a.length-1),N=Math.max(0,g-p.length+1);N<=E;N++){var F=g-N|0;_=p.words[F]|0,y=a.words[N]|0,h=_*y+k,R+=h/67108864|0,k=h&67108863}d.words[g]=k|0,A=R|0}return A!==0?d.words[g]=A|0:d.length--,d._strip()}var P=function(a,d,m){var _=a.words,y=d.words,h=m.words,x=0,A,g,R,k=_[0]|0,E=k&8191,N=k>>>13,F=_[1]|0,q=F&8191,K=F>>>13,J=_[2]|0,$=J&8191,V=J>>>13,ee=_[3]|0,G=ee&8191,Y=ee>>>13,_r=_[4]|0,ie=_r&8191,ne=_r>>>13,xr=_[5]|0,se=xr&8191,oe=xr>>>13,Er=_[6]|0,ae=Er&8191,fe=Er>>>13,Sr=_[7]|0,ce=Sr&8191,he=Sr>>>13,Ir=_[8]|0,ue=Ir&8191,de=Ir>>>13,Mr=_[9]|0,le=Mr&8191,pe=Mr>>>13,Ar=y[0]|0,ge=Ar&8191,be=Ar>>>13,Rr=y[1]|0,ve=Rr&8191,me=Rr>>>13,Tr=y[2]|0,ye=Tr&8191,we=Tr>>>13,Dr=y[3]|0,_e=Dr&8191,xe=Dr>>>13,Pr=y[4]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=y[5]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=y[6]|0,Ae=Cr&8191,Re=Cr>>>13,Or=y[7]|0,Te=Or&8191,De=Or>>>13,Lr=y[8]|0,Pe=Lr&8191,Ne=Lr>>>13,nr=y[9]|0,Be=nr&8191,ke=nr>>>13;m.negative=a.negative^d.negative,m.length=19,A=Math.imul(E,ge),g=Math.imul(E,be),g=g+Math.imul(N,ge)|0,R=Math.imul(N,be);var jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(jt>>>26)|0,jt&=67108863,A=Math.imul(q,ge),g=Math.imul(q,be),g=g+Math.imul(K,ge)|0,R=Math.imul(K,be),A=A+Math.imul(E,ve)|0,g=g+Math.imul(E,me)|0,g=g+Math.imul(N,ve)|0,R=R+Math.imul(N,me)|0;var Vt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,A=Math.imul($,ge),g=Math.imul($,be),g=g+Math.imul(V,ge)|0,R=Math.imul(V,be),A=A+Math.imul(q,ve)|0,g=g+Math.imul(q,me)|0,g=g+Math.imul(K,ve)|0,R=R+Math.imul(K,me)|0,A=A+Math.imul(E,ye)|0,g=g+Math.imul(E,we)|0,g=g+Math.imul(N,ye)|0,R=R+Math.imul(N,we)|0;var $t=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+($t>>>26)|0,$t&=67108863,A=Math.imul(G,ge),g=Math.imul(G,be),g=g+Math.imul(Y,ge)|0,R=Math.imul(Y,be),A=A+Math.imul($,ve)|0,g=g+Math.imul($,me)|0,g=g+Math.imul(V,ve)|0,R=R+Math.imul(V,me)|0,A=A+Math.imul(q,ye)|0,g=g+Math.imul(q,we)|0,g=g+Math.imul(K,ye)|0,R=R+Math.imul(K,we)|0,A=A+Math.imul(E,_e)|0,g=g+Math.imul(E,xe)|0,g=g+Math.imul(N,_e)|0,R=R+Math.imul(N,xe)|0;var Ht=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,A=Math.imul(ie,ge),g=Math.imul(ie,be),g=g+Math.imul(ne,ge)|0,R=Math.imul(ne,be),A=A+Math.imul(G,ve)|0,g=g+Math.imul(G,me)|0,g=g+Math.imul(Y,ve)|0,R=R+Math.imul(Y,me)|0,A=A+Math.imul($,ye)|0,g=g+Math.imul($,we)|0,g=g+Math.imul(V,ye)|0,R=R+Math.imul(V,we)|0,A=A+Math.imul(q,_e)|0,g=g+Math.imul(q,xe)|0,g=g+Math.imul(K,_e)|0,R=R+Math.imul(K,xe)|0,A=A+Math.imul(E,Ee)|0,g=g+Math.imul(E,Se)|0,g=g+Math.imul(N,Ee)|0,R=R+Math.imul(N,Se)|0;var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(se,ge),g=Math.imul(se,be),g=g+Math.imul(oe,ge)|0,R=Math.imul(oe,be),A=A+Math.imul(ie,ve)|0,g=g+Math.imul(ie,me)|0,g=g+Math.imul(ne,ve)|0,R=R+Math.imul(ne,me)|0,A=A+Math.imul(G,ye)|0,g=g+Math.imul(G,we)|0,g=g+Math.imul(Y,ye)|0,R=R+Math.imul(Y,we)|0,A=A+Math.imul($,_e)|0,g=g+Math.imul($,xe)|0,g=g+Math.imul(V,_e)|0,R=R+Math.imul(V,xe)|0,A=A+Math.imul(q,Ee)|0,g=g+Math.imul(q,Se)|0,g=g+Math.imul(K,Ee)|0,R=R+Math.imul(K,Se)|0,A=A+Math.imul(E,Ie)|0,g=g+Math.imul(E,Me)|0,g=g+Math.imul(N,Ie)|0,R=R+Math.imul(N,Me)|0;var Qi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,A=Math.imul(ae,ge),g=Math.imul(ae,be),g=g+Math.imul(fe,ge)|0,R=Math.imul(fe,be),A=A+Math.imul(se,ve)|0,g=g+Math.imul(se,me)|0,g=g+Math.imul(oe,ve)|0,R=R+Math.imul(oe,me)|0,A=A+Math.imul(ie,ye)|0,g=g+Math.imul(ie,we)|0,g=g+Math.imul(ne,ye)|0,R=R+Math.imul(ne,we)|0,A=A+Math.imul(G,_e)|0,g=g+Math.imul(G,xe)|0,g=g+Math.imul(Y,_e)|0,R=R+Math.imul(Y,xe)|0,A=A+Math.imul($,Ee)|0,g=g+Math.imul($,Se)|0,g=g+Math.imul(V,Ee)|0,R=R+Math.imul(V,Se)|0,A=A+Math.imul(q,Ie)|0,g=g+Math.imul(q,Me)|0,g=g+Math.imul(K,Ie)|0,R=R+Math.imul(K,Me)|0,A=A+Math.imul(E,Ae)|0,g=g+Math.imul(E,Re)|0,g=g+Math.imul(N,Ae)|0,R=R+Math.imul(N,Re)|0;var en=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(en>>>26)|0,en&=67108863,A=Math.imul(ce,ge),g=Math.imul(ce,be),g=g+Math.imul(he,ge)|0,R=Math.imul(he,be),A=A+Math.imul(ae,ve)|0,g=g+Math.imul(ae,me)|0,g=g+Math.imul(fe,ve)|0,R=R+Math.imul(fe,me)|0,A=A+Math.imul(se,ye)|0,g=g+Math.imul(se,we)|0,g=g+Math.imul(oe,ye)|0,R=R+Math.imul(oe,we)|0,A=A+Math.imul(ie,_e)|0,g=g+Math.imul(ie,xe)|0,g=g+Math.imul(ne,_e)|0,R=R+Math.imul(ne,xe)|0,A=A+Math.imul(G,Ee)|0,g=g+Math.imul(G,Se)|0,g=g+Math.imul(Y,Ee)|0,R=R+Math.imul(Y,Se)|0,A=A+Math.imul($,Ie)|0,g=g+Math.imul($,Me)|0,g=g+Math.imul(V,Ie)|0,R=R+Math.imul(V,Me)|0,A=A+Math.imul(q,Ae)|0,g=g+Math.imul(q,Re)|0,g=g+Math.imul(K,Ae)|0,R=R+Math.imul(K,Re)|0,A=A+Math.imul(E,Te)|0,g=g+Math.imul(E,De)|0,g=g+Math.imul(N,Te)|0,R=R+Math.imul(N,De)|0;var tn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(tn>>>26)|0,tn&=67108863,A=Math.imul(ue,ge),g=Math.imul(ue,be),g=g+Math.imul(de,ge)|0,R=Math.imul(de,be),A=A+Math.imul(ce,ve)|0,g=g+Math.imul(ce,me)|0,g=g+Math.imul(he,ve)|0,R=R+Math.imul(he,me)|0,A=A+Math.imul(ae,ye)|0,g=g+Math.imul(ae,we)|0,g=g+Math.imul(fe,ye)|0,R=R+Math.imul(fe,we)|0,A=A+Math.imul(se,_e)|0,g=g+Math.imul(se,xe)|0,g=g+Math.imul(oe,_e)|0,R=R+Math.imul(oe,xe)|0,A=A+Math.imul(ie,Ee)|0,g=g+Math.imul(ie,Se)|0,g=g+Math.imul(ne,Ee)|0,R=R+Math.imul(ne,Se)|0,A=A+Math.imul(G,Ie)|0,g=g+Math.imul(G,Me)|0,g=g+Math.imul(Y,Ie)|0,R=R+Math.imul(Y,Me)|0,A=A+Math.imul($,Ae)|0,g=g+Math.imul($,Re)|0,g=g+Math.imul(V,Ae)|0,R=R+Math.imul(V,Re)|0,A=A+Math.imul(q,Te)|0,g=g+Math.imul(q,De)|0,g=g+Math.imul(K,Te)|0,R=R+Math.imul(K,De)|0,A=A+Math.imul(E,Pe)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(N,Pe)|0,R=R+Math.imul(N,Ne)|0;var rn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(rn>>>26)|0,rn&=67108863,A=Math.imul(le,ge),g=Math.imul(le,be),g=g+Math.imul(pe,ge)|0,R=Math.imul(pe,be),A=A+Math.imul(ue,ve)|0,g=g+Math.imul(ue,me)|0,g=g+Math.imul(de,ve)|0,R=R+Math.imul(de,me)|0,A=A+Math.imul(ce,ye)|0,g=g+Math.imul(ce,we)|0,g=g+Math.imul(he,ye)|0,R=R+Math.imul(he,we)|0,A=A+Math.imul(ae,_e)|0,g=g+Math.imul(ae,xe)|0,g=g+Math.imul(fe,_e)|0,R=R+Math.imul(fe,xe)|0,A=A+Math.imul(se,Ee)|0,g=g+Math.imul(se,Se)|0,g=g+Math.imul(oe,Ee)|0,R=R+Math.imul(oe,Se)|0,A=A+Math.imul(ie,Ie)|0,g=g+Math.imul(ie,Me)|0,g=g+Math.imul(ne,Ie)|0,R=R+Math.imul(ne,Me)|0,A=A+Math.imul(G,Ae)|0,g=g+Math.imul(G,Re)|0,g=g+Math.imul(Y,Ae)|0,R=R+Math.imul(Y,Re)|0,A=A+Math.imul($,Te)|0,g=g+Math.imul($,De)|0,g=g+Math.imul(V,Te)|0,R=R+Math.imul(V,De)|0,A=A+Math.imul(q,Pe)|0,g=g+Math.imul(q,Ne)|0,g=g+Math.imul(K,Pe)|0,R=R+Math.imul(K,Ne)|0,A=A+Math.imul(E,Be)|0,g=g+Math.imul(E,ke)|0,g=g+Math.imul(N,Be)|0,R=R+Math.imul(N,ke)|0;var nn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nn>>>26)|0,nn&=67108863,A=Math.imul(le,ve),g=Math.imul(le,me),g=g+Math.imul(pe,ve)|0,R=Math.imul(pe,me),A=A+Math.imul(ue,ye)|0,g=g+Math.imul(ue,we)|0,g=g+Math.imul(de,ye)|0,R=R+Math.imul(de,we)|0,A=A+Math.imul(ce,_e)|0,g=g+Math.imul(ce,xe)|0,g=g+Math.imul(he,_e)|0,R=R+Math.imul(he,xe)|0,A=A+Math.imul(ae,Ee)|0,g=g+Math.imul(ae,Se)|0,g=g+Math.imul(fe,Ee)|0,R=R+Math.imul(fe,Se)|0,A=A+Math.imul(se,Ie)|0,g=g+Math.imul(se,Me)|0,g=g+Math.imul(oe,Ie)|0,R=R+Math.imul(oe,Me)|0,A=A+Math.imul(ie,Ae)|0,g=g+Math.imul(ie,Re)|0,g=g+Math.imul(ne,Ae)|0,R=R+Math.imul(ne,Re)|0,A=A+Math.imul(G,Te)|0,g=g+Math.imul(G,De)|0,g=g+Math.imul(Y,Te)|0,R=R+Math.imul(Y,De)|0,A=A+Math.imul($,Pe)|0,g=g+Math.imul($,Ne)|0,g=g+Math.imul(V,Pe)|0,R=R+Math.imul(V,Ne)|0,A=A+Math.imul(q,Be)|0,g=g+Math.imul(q,ke)|0,g=g+Math.imul(K,Be)|0,R=R+Math.imul(K,ke)|0;var sn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(sn>>>26)|0,sn&=67108863,A=Math.imul(le,ye),g=Math.imul(le,we),g=g+Math.imul(pe,ye)|0,R=Math.imul(pe,we),A=A+Math.imul(ue,_e)|0,g=g+Math.imul(ue,xe)|0,g=g+Math.imul(de,_e)|0,R=R+Math.imul(de,xe)|0,A=A+Math.imul(ce,Ee)|0,g=g+Math.imul(ce,Se)|0,g=g+Math.imul(he,Ee)|0,R=R+Math.imul(he,Se)|0,A=A+Math.imul(ae,Ie)|0,g=g+Math.imul(ae,Me)|0,g=g+Math.imul(fe,Ie)|0,R=R+Math.imul(fe,Me)|0,A=A+Math.imul(se,Ae)|0,g=g+Math.imul(se,Re)|0,g=g+Math.imul(oe,Ae)|0,R=R+Math.imul(oe,Re)|0,A=A+Math.imul(ie,Te)|0,g=g+Math.imul(ie,De)|0,g=g+Math.imul(ne,Te)|0,R=R+Math.imul(ne,De)|0,A=A+Math.imul(G,Pe)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(Y,Pe)|0,R=R+Math.imul(Y,Ne)|0,A=A+Math.imul($,Be)|0,g=g+Math.imul($,ke)|0,g=g+Math.imul(V,Be)|0,R=R+Math.imul(V,ke)|0;var on=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(on>>>26)|0,on&=67108863,A=Math.imul(le,_e),g=Math.imul(le,xe),g=g+Math.imul(pe,_e)|0,R=Math.imul(pe,xe),A=A+Math.imul(ue,Ee)|0,g=g+Math.imul(ue,Se)|0,g=g+Math.imul(de,Ee)|0,R=R+Math.imul(de,Se)|0,A=A+Math.imul(ce,Ie)|0,g=g+Math.imul(ce,Me)|0,g=g+Math.imul(he,Ie)|0,R=R+Math.imul(he,Me)|0,A=A+Math.imul(ae,Ae)|0,g=g+Math.imul(ae,Re)|0,g=g+Math.imul(fe,Ae)|0,R=R+Math.imul(fe,Re)|0,A=A+Math.imul(se,Te)|0,g=g+Math.imul(se,De)|0,g=g+Math.imul(oe,Te)|0,R=R+Math.imul(oe,De)|0,A=A+Math.imul(ie,Pe)|0,g=g+Math.imul(ie,Ne)|0,g=g+Math.imul(ne,Pe)|0,R=R+Math.imul(ne,Ne)|0,A=A+Math.imul(G,Be)|0,g=g+Math.imul(G,ke)|0,g=g+Math.imul(Y,Be)|0,R=R+Math.imul(Y,ke)|0;var an=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(an>>>26)|0,an&=67108863,A=Math.imul(le,Ee),g=Math.imul(le,Se),g=g+Math.imul(pe,Ee)|0,R=Math.imul(pe,Se),A=A+Math.imul(ue,Ie)|0,g=g+Math.imul(ue,Me)|0,g=g+Math.imul(de,Ie)|0,R=R+Math.imul(de,Me)|0,A=A+Math.imul(ce,Ae)|0,g=g+Math.imul(ce,Re)|0,g=g+Math.imul(he,Ae)|0,R=R+Math.imul(he,Re)|0,A=A+Math.imul(ae,Te)|0,g=g+Math.imul(ae,De)|0,g=g+Math.imul(fe,Te)|0,R=R+Math.imul(fe,De)|0,A=A+Math.imul(se,Pe)|0,g=g+Math.imul(se,Ne)|0,g=g+Math.imul(oe,Pe)|0,R=R+Math.imul(oe,Ne)|0,A=A+Math.imul(ie,Be)|0,g=g+Math.imul(ie,ke)|0,g=g+Math.imul(ne,Be)|0,R=R+Math.imul(ne,ke)|0;var fn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fn>>>26)|0,fn&=67108863,A=Math.imul(le,Ie),g=Math.imul(le,Me),g=g+Math.imul(pe,Ie)|0,R=Math.imul(pe,Me),A=A+Math.imul(ue,Ae)|0,g=g+Math.imul(ue,Re)|0,g=g+Math.imul(de,Ae)|0,R=R+Math.imul(de,Re)|0,A=A+Math.imul(ce,Te)|0,g=g+Math.imul(ce,De)|0,g=g+Math.imul(he,Te)|0,R=R+Math.imul(he,De)|0,A=A+Math.imul(ae,Pe)|0,g=g+Math.imul(ae,Ne)|0,g=g+Math.imul(fe,Pe)|0,R=R+Math.imul(fe,Ne)|0,A=A+Math.imul(se,Be)|0,g=g+Math.imul(se,ke)|0,g=g+Math.imul(oe,Be)|0,R=R+Math.imul(oe,ke)|0;var cn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cn>>>26)|0,cn&=67108863,A=Math.imul(le,Ae),g=Math.imul(le,Re),g=g+Math.imul(pe,Ae)|0,R=Math.imul(pe,Re),A=A+Math.imul(ue,Te)|0,g=g+Math.imul(ue,De)|0,g=g+Math.imul(de,Te)|0,R=R+Math.imul(de,De)|0,A=A+Math.imul(ce,Pe)|0,g=g+Math.imul(ce,Ne)|0,g=g+Math.imul(he,Pe)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(ae,Be)|0,g=g+Math.imul(ae,ke)|0,g=g+Math.imul(fe,Be)|0,R=R+Math.imul(fe,ke)|0;var hn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(hn>>>26)|0,hn&=67108863,A=Math.imul(le,Te),g=Math.imul(le,De),g=g+Math.imul(pe,Te)|0,R=Math.imul(pe,De),A=A+Math.imul(ue,Pe)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(de,Pe)|0,R=R+Math.imul(de,Ne)|0,A=A+Math.imul(ce,Be)|0,g=g+Math.imul(ce,ke)|0,g=g+Math.imul(he,Be)|0,R=R+Math.imul(he,ke)|0;var fc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fc>>>26)|0,fc&=67108863,A=Math.imul(le,Pe),g=Math.imul(le,Ne),g=g+Math.imul(pe,Pe)|0,R=Math.imul(pe,Ne),A=A+Math.imul(ue,Be)|0,g=g+Math.imul(ue,ke)|0,g=g+Math.imul(de,Be)|0,R=R+Math.imul(de,ke)|0;var cc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cc>>>26)|0,cc&=67108863,A=Math.imul(le,Be),g=Math.imul(le,ke),g=g+Math.imul(pe,Be)|0,R=Math.imul(pe,ke);var hc=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(hc>>>26)|0,hc&=67108863,h[0]=jt,h[1]=Vt,h[2]=$t,h[3]=Ht,h[4]=Gt,h[5]=Qi,h[6]=en,h[7]=tn,h[8]=rn,h[9]=nn,h[10]=sn,h[11]=on,h[12]=an,h[13]=fn,h[14]=cn,h[15]=hn,h[16]=fc,h[17]=cc,h[18]=hc,x!==0&&(h[19]=x,m.length++),m};Math.imul||(P=O);function z(p,a,d){d.negative=a.negative^p.negative,d.length=p.length+a.length;for(var m=0,_=0,y=0;y>>26)|0,_+=h>>>26,h&=67108863}d.words[y]=x,m=h,h=_}return m!==0?d.words[y]=m:d.length--,d._strip()}function B(p,a,d){return z(p,a,d)}n.prototype.mulTo=function(a,d){var m,_=this.length+a.length;return this.length===10&&a.length===10?m=P(this,a,d):_<63?m=O(this,a,d):_<1024?m=z(this,a,d):m=B(this,a,d),m};function U(p,a){this.x=p,this.y=a}U.prototype.makeRBT=function(a){for(var d=new Array(a),m=n.prototype._countBits(a)-1,_=0;_>=1;return _},U.prototype.permute=function(a,d,m,_,y,h){for(var x=0;x>>1)y++;return 1<>>13,m[2*h+1]=y&8191,y=y>>>13;for(h=2*d;h<_;++h)m[h]=0;t(y===0),t((y&-8192)===0)},U.prototype.stub=function(a){for(var d=new Array(a),m=0;m>=26,m+=y/67108864|0,m+=h>>>26,this.words[_]=h&67108863}return m!==0&&(this.words[_]=m,this.length++),d?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var d=T(a);if(d.length===0)return new n(1);for(var m=this,_=0;_=0);var d=a%26,m=(a-d)/26,_=67108863>>>26-d<<26-d,y;if(d!==0){var h=0;for(y=0;y>>26-d}h&&(this.words[y]=h,this.length++)}if(m!==0){for(y=this.length-1;y>=0;y--)this.words[y+m]=this.words[y];for(y=0;y=0);var _;d?_=(d-d%26)/26:_=0;var y=a%26,h=Math.min((a-y)/26,this.length),x=67108863^67108863>>>y<h)for(this.length-=h,g=0;g=0&&(R!==0||g>=_);g--){var k=this.words[g]|0;this.words[g]=R<<26-y|k>>>y,R=k&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,d,m){return t(this.negative===0),this.iushrn(a,d,m)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var d=a%26,m=(a-d)/26,_=1<=0);var d=a%26,m=(a-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(d!==0&&m++,this.length=Math.min(m,this.length),d!==0){var _=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(A/67108864|0),this.words[y+m]=h&67108863}for(;y>26,this.words[y+m]=h&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,y=0;y>26,this.words[y]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,d){var m=this.length-a.length,_=this.clone(),y=a,h=y.words[y.length-1]|0,x=this._countBits(h);m=26-x,m!==0&&(y=y.ushln(m),_.iushln(m),h=y.words[y.length-1]|0);var A=_.length-y.length,g;if(d!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var N=(_.words[y.length+E]|0)*67108864+(_.words[y.length+E-1]|0);for(N=Math.min(N/h|0,67108863),_._ishlnsubmul(y,N,E);_.negative!==0;)N--,_.negative=0,_._ishlnsubmul(y,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=N)}return g&&g._strip(),_._strip(),d!=="div"&&m!==0&&_.iushrn(m),{div:g||null,mod:_}},n.prototype.divmod=function(a,d,m){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,y,h;return this.negative!==0&&a.negative===0?(h=this.neg().divmod(a,d),d!=="mod"&&(_=h.div.neg()),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.iadd(a)),{div:_,mod:y}):this.negative===0&&a.negative!==0?(h=this.divmod(a.neg(),d),d!=="mod"&&(_=h.div.neg()),{div:_,mod:h.mod}):this.negative&a.negative?(h=this.neg().divmod(a.neg(),d),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.isub(a)),{div:h.div,mod:y}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?d==="div"?{div:this.divn(a.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,d)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var d=this.divmod(a);if(d.mod.isZero())return d.div;var m=d.div.negative!==0?d.mod.isub(a):d.mod,_=a.ushrn(1),y=a.andln(1),h=m.cmp(_);return h<0||y===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=(1<<26)%a,_=0,y=this.length-1;y>=0;y--)_=(m*_+(this.words[y]|0))%a;return d?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=0,_=this.length-1;_>=0;_--){var y=(this.words[_]|0)+m*67108864;this.words[_]=y/a|0,m=y%a}return this._strip(),d?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=new n(0),x=new n(1),A=0;d.isEven()&&m.isEven();)d.iushrn(1),m.iushrn(1),++A;for(var g=m.clone(),R=d.clone();!d.isZero();){for(var k=0,E=1;!(d.words[0]&E)&&k<26;++k,E<<=1);if(k>0)for(d.iushrn(k);k-- >0;)(_.isOdd()||y.isOdd())&&(_.iadd(g),y.isub(R)),_.iushrn(1),y.iushrn(1);for(var N=0,F=1;!(m.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(m.iushrn(N);N-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(g),x.isub(R)),h.iushrn(1),x.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(h),y.isub(x)):(m.isub(d),h.isub(_),x.isub(y))}return{a:h,b:x,gcd:m.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=m.clone();d.cmpn(1)>0&&m.cmpn(1)>0;){for(var x=0,A=1;!(d.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(d.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(h),_.iushrn(1);for(var g=0,R=1;!(m.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(m.iushrn(g);g-- >0;)y.isOdd()&&y.iadd(h),y.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(y)):(m.isub(d),y.isub(_))}var k;return d.cmpn(1)===0?k=_:k=y,k.cmpn(0)<0&&k.iadd(a),k},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var d=this.clone(),m=a.clone();d.negative=0,m.negative=0;for(var _=0;d.isEven()&&m.isEven();_++)d.iushrn(1),m.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;m.isEven();)m.iushrn(1);var y=d.cmp(m);if(y<0){var h=d;d=m,m=h}else if(y===0||m.cmpn(1)===0)break;d.isub(m)}while(!0);return m.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var d=a%26,m=(a-d)/26,_=1<>>26,x&=67108863,this.words[h]=x}return y!==0&&(this.words[h]=y,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var d=a<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var m;if(this.length>1)m=1;else{d&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;m=_===a?0:_a.length)return 1;if(this.length=0;m--){var _=this.words[m]|0,y=a.words[m]|0;if(_!==y){_y&&(d=1);break}}return d},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var j={k256:null,p224:null,p192:null,p25519:null};function H(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var d=a,m;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),m=d.bitLength();while(m>this.n);var _=m0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},H.prototype.split=function(a,d){a.iushrn(this.n,0,d)},H.prototype.imulK=function(a){return a.imul(this.k)};function L(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,H),L.prototype.split=function(a,d){for(var m=4194303,_=Math.min(a.length,9),y=0;y<_;y++)d.words[y]=a.words[y];if(d.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var h=a.words[9];for(d.words[d.length++]=h&m,y=10;y>>22,h=x}h>>>=22,a.words[y-10]=h,h===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var d=0,m=0;m>>=26,a.words[m]=y,d=_}return d!==0&&(a.words[a.length++]=d),a},n._prime=function(a){if(j[a])return j[a];var d;if(a==="k256")d=new L;else if(a==="p224")d=new C;else if(a==="p192")d=new W;else if(a==="p25519")d=new D;else throw new Error("Unknown prime "+a);return j[a]=d,d};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,d){t((a.negative|d.negative)===0,"red works only with positives"),t(a.red&&a.red===d.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(c(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,d){this._verify2(a,d);var m=a.add(d);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},l.prototype.iadd=function(a,d){this._verify2(a,d);var m=a.iadd(d);return m.cmp(this.m)>=0&&m.isub(this.m),m},l.prototype.sub=function(a,d){this._verify2(a,d);var m=a.sub(d);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},l.prototype.isub=function(a,d){this._verify2(a,d);var m=a.isub(d);return m.cmpn(0)<0&&m.iadd(this.m),m},l.prototype.shl=function(a,d){return this._verify1(a),this.imod(a.ushln(d))},l.prototype.imul=function(a,d){return this._verify2(a,d),this.imod(a.imul(d))},l.prototype.mul=function(a,d){return this._verify2(a,d),this.imod(a.mul(d))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var m=this.m.add(new n(1)).iushrn(2);return this.pow(a,m)}for(var _=this.m.subn(1),y=0;!_.isZero()&&_.andln(1)===0;)y++,_.iushrn(1);t(!_.isZero());var h=new n(1).toRed(this),x=h.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),k=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),N=y;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;y--){for(var R=d.words[y],k=g-1;k>=0;k--){var E=R>>k&1;if(h!==_[0]&&(h=this.sqr(h)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==m&&(y!==0||k!==0))&&(h=this.mul(h,_[x]),A=0,x=0)}g=26}return h},l.prototype.convertTo=function(a){var d=a.umod(this.m);return d===a?d.clone():d},l.prototype.convertFrom=function(a){var d=a.clone();return d.red=null,d},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var d=this.imod(a.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(a,d){if(a.isZero()||d.isZero())return a.words[0]=0,a.length=1,a;var m=a.imul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(a,d){if(a.isZero()||d.isZero())return new n(0)._forceRed(this);var m=a.mul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(a){var d=this.imod(a._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof Dh>"u"||Dh,Gp)});var Pi=Z((UA,o1)=>{o1.exports=s1;function s1(r,e){if(!r)throw new Error(e||"Assertion failed")}s1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var co=Z((zA,Oh)=>{typeof Object.create=="function"?Oh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Oh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var fr=Z(Ve=>{"use strict";var jw=Pi(),Vw=co();Ve.inherits=Vw;function $w(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Hw(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):$w(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ve.htonl=a1;function Ww(r,e){for(var t="",i=0;i>>0}return s}Ve.join32=Jw;function Yw(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ve.split32=Yw;function Xw(r,e){return r>>>e|r<<32-e}Ve.rotr32=Xw;function Zw(r,e){return r<>>32-e}Ve.rotl32=Zw;function Qw(r,e){return r+e>>>0}Ve.sum32=Qw;function e5(r,e,t){return r+e+t>>>0}Ve.sum32_3=e5;function t5(r,e,t,i){return r+e+t+i>>>0}Ve.sum32_4=t5;function r5(r,e,t,i,n){return r+e+t+i+n>>>0}Ve.sum32_5=r5;function i5(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}Ve.sum64=i5;function n5(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ve.sum64_hi=n5;function s5(r,e,t,i){var n=e+i;return n>>>0}Ve.sum64_lo=s5;function o5(r,e,t,i,n,s,o,f){var u=0,c=e;c=c+i>>>0,u+=c>>0,u+=c>>0,u+=c>>0}Ve.sum64_4_hi=o5;function a5(r,e,t,i,n,s,o,f){var u=e+i+s+f;return u>>>0}Ve.sum64_4_lo=a5;function f5(r,e,t,i,n,s,o,f,u,c){var b=0,v=e;v=v+i>>>0,b+=v>>0,b+=v>>0,b+=v>>0,b+=v>>0}Ve.sum64_5_hi=f5;function c5(r,e,t,i,n,s,o,f,u,c){var b=e+i+s+f+c;return b>>>0}Ve.sum64_5_lo=c5;function h5(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ve.rotr64_hi=h5;function u5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.rotr64_lo=u5;function d5(r,e,t){return r>>>t}Ve.shr64_hi=d5;function l5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.shr64_lo=l5});var os=Z(u1=>{"use strict";var h1=fr(),p5=Pi();function Ga(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}u1.BlockHash=Ga;Ga.prototype.update=function(e,t){if(e=h1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=h1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var g5=fr(),zr=g5.rotr32;function b5(r,e,t,i){if(r===0)return d1(e,t,i);if(r===1||r===3)return p1(e,t,i);if(r===2)return l1(e,t,i)}ui.ft_1=b5;function d1(r,e,t){return r&e^~r&t}ui.ch32=d1;function l1(r,e,t){return r&e^r&t^e&t}ui.maj32=l1;function p1(r,e,t){return r^e^t}ui.p32=p1;function v5(r){return zr(r,2)^zr(r,13)^zr(r,22)}ui.s0_256=v5;function m5(r){return zr(r,6)^zr(r,11)^zr(r,25)}ui.s1_256=m5;function y5(r){return zr(r,7)^zr(r,18)^r>>>3}ui.g0_256=y5;function w5(r){return zr(r,17)^zr(r,19)^r>>>10}ui.g1_256=w5});var v1=Z((jA,b1)=>{"use strict";var as=fr(),_5=os(),x5=Lh(),Fh=as.rotl32,ho=as.sum32,E5=as.sum32_5,S5=x5.ft_1,g1=_5.BlockHash,I5=[1518500249,1859775393,2400959708,3395469782];function Br(){if(!(this instanceof Br))return new Br;g1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}as.inherits(Br,g1);b1.exports=Br;Br.blockSize=512;Br.outSize=160;Br.hmacStrength=80;Br.padLength=64;Br.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var fs=fr(),M5=os(),cs=Lh(),A5=Pi(),cr=fs.sum32,R5=fs.sum32_4,T5=fs.sum32_5,D5=cs.ch32,P5=cs.maj32,N5=cs.s0_256,C5=cs.s1_256,O5=cs.g0_256,L5=cs.g1_256,m1=M5.BlockHash,F5=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function kr(){if(!(this instanceof kr))return new kr;m1.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=F5,this.W=new Array(64)}fs.inherits(kr,m1);y1.exports=kr;kr.blockSize=512;kr.outSize=256;kr.hmacStrength=192;kr.padLength=64;kr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Uh=fr(),w1=qh();function di(){if(!(this instanceof di))return new di;w1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Uh.inherits(di,w1);_1.exports=di;di.blockSize=512;di.outSize=224;di.hmacStrength=192;di.padLength=64;di.prototype._digest=function(e){return e==="hex"?Uh.toHex32(this.h.slice(0,7),"big"):Uh.split32(this.h.slice(0,7),"big")}});var kh=Z((HA,M1)=>{"use strict";var Ot=fr(),q5=os(),U5=Pi(),Kr=Ot.rotr64_hi,jr=Ot.rotr64_lo,E1=Ot.shr64_hi,S1=Ot.shr64_lo,Ni=Ot.sum64,zh=Ot.sum64_hi,Bh=Ot.sum64_lo,z5=Ot.sum64_4_hi,B5=Ot.sum64_4_lo,k5=Ot.sum64_5_hi,K5=Ot.sum64_5_lo,I1=q5.BlockHash,j5=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function hr(){if(!(this instanceof hr))return new hr;I1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=j5,this.W=new Array(160)}Ot.inherits(hr,I1);M1.exports=hr;hr.blockSize=1024;hr.outSize=512;hr.hmacStrength=192;hr.padLength=128;hr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Kh=fr(),A1=kh();function li(){if(!(this instanceof li))return new li;A1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Kh.inherits(li,A1);R1.exports=li;li.blockSize=1024;li.outSize=384;li.hmacStrength=192;li.padLength=128;li.prototype._digest=function(e){return e==="hex"?Kh.toHex32(this.h.slice(0,12),"big"):Kh.split32(this.h.slice(0,12),"big")}});var D1=Z(hs=>{"use strict";hs.sha1=v1();hs.sha224=x1();hs.sha256=qh();hs.sha384=T1();hs.sha512=kh()});var F1=Z(L1=>{"use strict";var _n=fr(),r8=os(),Wa=_n.rotl32,P1=_n.sum32,uo=_n.sum32_3,N1=_n.sum32_4,O1=r8.BlockHash;function Vr(){if(!(this instanceof Vr))return new Vr;O1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}_n.inherits(Vr,O1);L1.ripemd160=Vr;Vr.blockSize=512;Vr.outSize=160;Vr.hmacStrength=192;Vr.padLength=64;Vr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],u=i,c=n,b=s,v=o,S=f,I=0;I<80;I++){var M=P1(Wa(N1(i,C1(I,n,s,o),e[s8[I]+t],i8(I)),a8[I]),f);i=f,f=o,o=Wa(s,10),s=n,n=M,M=P1(Wa(N1(u,C1(79-I,c,b,v),e[o8[I]+t],n8(I)),f8[I]),S),u=S,S=v,v=Wa(b,10),b=c,c=M}M=uo(this.h[1],s,v),this.h[1]=uo(this.h[2],o,S),this.h[2]=uo(this.h[3],f,u),this.h[3]=uo(this.h[4],i,c),this.h[4]=uo(this.h[0],n,b),this.h[0]=M};Vr.prototype._digest=function(e){return e==="hex"?_n.toHex32(this.h,"little"):_n.split32(this.h,"little")};function C1(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function i8(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function n8(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var s8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o8=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],a8=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f8=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var U1=Z((YA,q1)=>{"use strict";var c8=fr(),h8=Pi();function us(r,e,t){if(!(this instanceof us))return new us(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(c8.toArray(e,t))}q1.exports=us;us.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),h8(e.length<=this.blockSize);for(var t=e.length;t{var pt=z1;pt.utils=fr();pt.common=os();pt.sha=D1();pt.ripemd=F1();pt.hmac=U1();pt.sha1=pt.sha.sha1;pt.sha256=pt.sha.sha256;pt.sha224=pt.sha.sha224;pt.sha384=pt.sha.sha384;pt.sha512=pt.sha.sha512;pt.ripemd160=pt.ripemd.ripemd160});var X1=Z(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var Et=Hn(),Qh=Jt(),_8=20;function x8(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],c=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],v=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],P=e[11]<<24|e[10]<<16|e[9]<<8|e[8],z=e[15]<<24|e[14]<<16|e[13]<<8|e[12],B=i,U=n,j=s,H=o,L=f,C=u,W=c,D=b,l=v,w=S,p=I,a=M,d=T,m=O,_=P,y=z,h=0;h<_8;h+=2)B=B+L|0,d^=B,d=d>>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,U=U+C|0,m^=U,m=m>>>16|m<<16,w=w+m|0,C^=w,C=C>>>20|C<<12,j=j+W|0,_^=j,_=_>>>16|_<<16,p=p+_|0,W^=p,W=W>>>20|W<<12,H=H+D|0,y^=H,y=y>>>16|y<<16,a=a+y|0,D^=a,D=D>>>20|D<<12,j=j+W|0,_^=j,_=_>>>24|_<<8,p=p+_|0,W^=p,W=W>>>25|W<<7,H=H+D|0,y^=H,y=y>>>24|y<<8,a=a+y|0,D^=a,D=D>>>25|D<<7,U=U+C|0,m^=U,m=m>>>24|m<<8,w=w+m|0,C^=w,C=C>>>25|C<<7,B=B+L|0,d^=B,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,B=B+C|0,y^=B,y=y>>>16|y<<16,p=p+y|0,C^=p,C=C>>>20|C<<12,U=U+W|0,d^=U,d=d>>>16|d<<16,a=a+d|0,W^=a,W=W>>>20|W<<12,j=j+D|0,m^=j,m=m>>>16|m<<16,l=l+m|0,D^=l,D=D>>>20|D<<12,H=H+L|0,_^=H,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,j=j+D|0,m^=j,m=m>>>24|m<<8,l=l+m|0,D^=l,D=D>>>25|D<<7,H=H+L|0,_^=H,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,U=U+W|0,d^=U,d=d>>>24|d<<8,a=a+d|0,W^=a,W=W>>>25|W<<7,B=B+C|0,y^=B,y=y>>>24|y<<8,p=p+y|0,C^=p,C=C>>>25|C<<7;Et.writeUint32LE(B+i|0,r,0),Et.writeUint32LE(U+n|0,r,4),Et.writeUint32LE(j+s|0,r,8),Et.writeUint32LE(H+o|0,r,12),Et.writeUint32LE(L+f|0,r,16),Et.writeUint32LE(C+u|0,r,20),Et.writeUint32LE(W+c|0,r,24),Et.writeUint32LE(D+b|0,r,28),Et.writeUint32LE(l+v|0,r,32),Et.writeUint32LE(w+S|0,r,36),Et.writeUint32LE(p+I|0,r,40),Et.writeUint32LE(a+M|0,r,44),Et.writeUint32LE(d+T|0,r,48),Et.writeUint32LE(m+O|0,r,52),Et.writeUint32LE(_+P|0,r,56),Et.writeUint32LE(y+z|0,r,60)}function Y1(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var rf=Z(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});function I8(r,e,t){return~(r-1)&e|r-1&t}ls.select=I8;function M8(r,e){return(r|0)-(e|0)-1>>>31&1}ls.lessOrEqual=M8;function Z1(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}ls.compare=Z1;function A8(r,e){return r.length===0||e.length===0?!1:Z1(r,e)!==0}ls.equal=A8});var eg=Z(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var R8=rf(),nf=Jt();pi.DIGEST_LENGTH=16;var Q1=function(){function r(e){this.digestLength=pi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var u=e[12]|e[13]<<8;this._r[7]=(f>>>11|u<<5)&8065;var c=e[14]|e[15]<<8;this._r[8]=(u>>>8|c<<8)&8191,this._r[9]=c>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],u=this._h[3],c=this._h[4],b=this._h[5],v=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],O=this._r[1],P=this._r[2],z=this._r[3],B=this._r[4],U=this._r[5],j=this._r[6],H=this._r[7],L=this._r[8],C=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var D=e[t+2]|e[t+3]<<8;o+=(W>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;u+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;c+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;v+=(p>>>14|a<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(a>>>11|d<<5)&8191;var m=e[t+14]|e[t+15]<<8;I+=(d>>>8|m<<8)&8191,M+=m>>>5|n;var _=0,y=_;y+=s*T,y+=o*(5*C),y+=f*(5*L),y+=u*(5*H),y+=c*(5*j),_=y>>>13,y&=8191,y+=b*(5*U),y+=v*(5*B),y+=S*(5*z),y+=I*(5*P),y+=M*(5*O),_+=y>>>13,y&=8191;var h=_;h+=s*O,h+=o*T,h+=f*(5*C),h+=u*(5*L),h+=c*(5*H),_=h>>>13,h&=8191,h+=b*(5*j),h+=v*(5*U),h+=S*(5*B),h+=I*(5*z),h+=M*(5*P),_+=h>>>13,h&=8191;var x=_;x+=s*P,x+=o*O,x+=f*T,x+=u*(5*C),x+=c*(5*L),_=x>>>13,x&=8191,x+=b*(5*H),x+=v*(5*j),x+=S*(5*U),x+=I*(5*B),x+=M*(5*z),_+=x>>>13,x&=8191;var A=_;A+=s*z,A+=o*P,A+=f*O,A+=u*T,A+=c*(5*C),_=A>>>13,A&=8191,A+=b*(5*L),A+=v*(5*H),A+=S*(5*j),A+=I*(5*U),A+=M*(5*B),_+=A>>>13,A&=8191;var g=_;g+=s*B,g+=o*z,g+=f*P,g+=u*O,g+=c*T,_=g>>>13,g&=8191,g+=b*(5*C),g+=v*(5*L),g+=S*(5*H),g+=I*(5*j),g+=M*(5*U),_+=g>>>13,g&=8191;var R=_;R+=s*U,R+=o*B,R+=f*z,R+=u*P,R+=c*O,_=R>>>13,R&=8191,R+=b*T,R+=v*(5*C),R+=S*(5*L),R+=I*(5*H),R+=M*(5*j),_+=R>>>13,R&=8191;var k=_;k+=s*j,k+=o*U,k+=f*B,k+=u*z,k+=c*P,_=k>>>13,k&=8191,k+=b*O,k+=v*T,k+=S*(5*C),k+=I*(5*L),k+=M*(5*H),_+=k>>>13,k&=8191;var E=_;E+=s*H,E+=o*j,E+=f*U,E+=u*B,E+=c*z,_=E>>>13,E&=8191,E+=b*P,E+=v*O,E+=S*T,E+=I*(5*C),E+=M*(5*L),_+=E>>>13,E&=8191;var N=_;N+=s*L,N+=o*H,N+=f*j,N+=u*U,N+=c*B,_=N>>>13,N&=8191,N+=b*z,N+=v*P,N+=S*O,N+=I*T,N+=M*(5*C),_+=N>>>13,N&=8191;var F=_;F+=s*C,F+=o*L,F+=f*H,F+=u*j,F+=c*U,_=F>>>13,F&=8191,F+=b*B,F+=v*z,F+=S*P,F+=I*O,F+=M*T,_+=F>>>13,F&=8191,_=(_<<2)+_|0,_=_+y|0,y=_&8191,_=_>>>13,h+=_,s=y,o=h,f=x,u=A,c=g,b=R,v=k,S=E,I=N,M=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=u,this._h[4]=c,this._h[5]=b,this._h[6]=v,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});var sf=X1(),P8=eg(),po=Jt(),tg=Hn(),N8=rf();gi.KEY_LENGTH=32;gi.NONCE_LENGTH=12;gi.TAG_LENGTH=16;var rg=new Uint8Array(16),C8=function(){function r(e){if(this.nonceLength=gi.NONCE_LENGTH,this.tagLength=gi.TAG_LENGTH,e.length!==gi.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);sf.stream(this._key,s,o,4);var f=t.length+this.tagLength,u;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");u=n}else u=new Uint8Array(f);return sf.streamXOR(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),i),po.wipe(s),u},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(rg.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(rg.subarray(i.length%16));var o=new Uint8Array(8);n&&tg.writeUint64LE(n.length,o),s.update(o),tg.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),u=0;u{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});function O8(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}eu.isSerializableHash=O8});var og=Z(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Gr=ng(),L8=rf(),F8=Jt(),sg=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ag=og(),fg=Jt(),U8=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ag.hmac(this._hash,i,t);this._hmac=new ag.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});var af=Hn(),of=Jt();Li.DIGEST_LENGTH=32;Li.BLOCK_SIZE=64;var hg=function(){function r(){this.digestLength=Li.DIGEST_LENGTH,this.blockSize=Li.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){of.wipe(this._buffer),of.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ru(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ru(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){of.wipe(e.state),e.buffer&&of.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Li.SHA256=hg;var z8=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ru(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],u=e[3],c=e[4],b=e[5],v=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=af.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],O=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var P=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(O+r[I-7]|0)+(P+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&b^~c&v)|0)+(S+(z8[I]+r[I]|0)|0)|0,P=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=v,v=b,b=c,c=u+O|0,u=f,f=o,o=s,s=O+P|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=u,e[4]+=c,e[5]+=b,e[6]+=v,e[7]+=S,i+=64,n-=64}return i}function B8(r){var e=new hg;e.update(r);var t=e.digest();return e.clean(),t}Li.hash=B8});var gg=Z(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.sharedKey=Qe.generateKeyPair=Qe.generateKeyPairFromSeed=Qe.scalarMultBase=Qe.scalarMult=Qe.SHARED_KEY_LENGTH=Qe.SECRET_KEY_LENGTH=Qe.PUBLIC_KEY_LENGTH=void 0;var k8=Js(),K8=Jt();Qe.PUBLIC_KEY_LENGTH=32;Qe.SECRET_KEY_LENGTH=32;Qe.SHARED_KEY_LENGTH=32;function Wr(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function $8(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ff(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function cf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function bi(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function vo(r,e){bi(r,e,e)}function H8(r,e){let t=Wr();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)vo(t,t),i!==2&&i!==4&&bi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function nu(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=Wr(),s=Wr(),o=Wr(),f=Wr(),u=Wr(),c=Wr();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,$8(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;bo(n,s,M),bo(o,f,M),ff(u,n,o),cf(n,n,o),ff(o,s,f),cf(s,s,f),vo(f,u),vo(c,n),bi(n,o,n),bi(o,s,u),ff(u,n,o),cf(n,n,o),vo(s,n),cf(o,f,c),bi(n,o,j8),ff(n,n,f),bi(o,o,n),bi(n,f,c),bi(f,s,i),vo(s,u),bo(n,s,M),bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),v=i.subarray(16);H8(b,b),bi(v,v,b);let S=new Uint8Array(32);return V8(S,v),S}Qe.scalarMult=nu;function lg(r){return nu(r,dg)}Qe.scalarMultBase=lg;function pg(r){if(r.length!==Qe.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${Qe.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:lg(e),secretKey:e}}Qe.generateKeyPairFromSeed=pg;function G8(r){let e=(0,k8.randomBytes)(32,r),t=pg(e);return(0,K8.wipe)(e),t}Qe.generateKeyPair=G8;function W8(r,e,t=!1){if(r.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=nu(r,e);if(t){let n=0;for(let s=0;s{J8.exports={name:"elliptic",version:"6.6.0",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var Jr=Z((vg,su)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)m=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[d]|=m<<_&67108863,this.words[d+1]=m>>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);else if(p==="le")for(a=0,d=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8;else{var y=l.length-w;for(a=y%2===0?w+1:w;a=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8}this.strip()};function u(D,l,w,p){for(var a=0,d=Math.min(D.length,w),m=l;m=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=w)a++;a--,d=d/w|0;for(var m=l.length-p,_=m%a,y=Math.min(m,m-_)+p,h=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,d=0,m=0;m>>24-a&16777215,d!==0||m!==this.length-1?p=c[6-y.length]+y+p:p=y+p,a+=2,a>=26&&(a-=26,m--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=b[l],x=v[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=c[h-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),d=p||Math.max(1,a);t(a<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var m=w==="le",_=new l(d),y,h,x=this.clone();if(m){for(h=0;!x.isZero();h++)y=x.andln(255),x.iushrn(8),_[h]=y;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var d=0,m=0;m>>26;for(;d!==0&&m>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;ml.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;p>0?(a=this,d=l):(a=l,d=this);for(var m=0,_=0;_>26,this.words[_]=w&67108863;for(;m!==0&&_>26,this.words[_]=w&67108863;if(m===0&&_>>26,A=y&67108863,g=Math.min(h,l.length-1),R=Math.max(0,h-D.length+1);R<=g;R++){var k=h-R|0;a=D.words[k]|0,d=l.words[R]|0,m=a*d+A,x+=m/67108864|0,A=m&67108863}w.words[h]=A|0,y=x|0}return y!==0?w.words[h]=y|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,d=w.words,m=p.words,_=0,y,h,x,A=a[0]|0,g=A&8191,R=A>>>13,k=a[1]|0,E=k&8191,N=k>>>13,F=a[2]|0,q=F&8191,K=F>>>13,J=a[3]|0,$=J&8191,V=J>>>13,ee=a[4]|0,G=ee&8191,Y=ee>>>13,_r=a[5]|0,ie=_r&8191,ne=_r>>>13,xr=a[6]|0,se=xr&8191,oe=xr>>>13,Er=a[7]|0,ae=Er&8191,fe=Er>>>13,Sr=a[8]|0,ce=Sr&8191,he=Sr>>>13,Ir=a[9]|0,ue=Ir&8191,de=Ir>>>13,Mr=d[0]|0,le=Mr&8191,pe=Mr>>>13,Ar=d[1]|0,ge=Ar&8191,be=Ar>>>13,Rr=d[2]|0,ve=Rr&8191,me=Rr>>>13,Tr=d[3]|0,ye=Tr&8191,we=Tr>>>13,Dr=d[4]|0,_e=Dr&8191,xe=Dr>>>13,Pr=d[5]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=d[6]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=d[7]|0,Ae=Cr&8191,Re=Cr>>>13,Or=d[8]|0,Te=Or&8191,De=Or>>>13,Lr=d[9]|0,Pe=Lr&8191,Ne=Lr>>>13;p.negative=l.negative^w.negative,p.length=19,y=Math.imul(g,le),h=Math.imul(g,pe),h=h+Math.imul(R,le)|0,x=Math.imul(R,pe);var nr=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,y=Math.imul(E,le),h=Math.imul(E,pe),h=h+Math.imul(N,le)|0,x=Math.imul(N,pe),y=y+Math.imul(g,ge)|0,h=h+Math.imul(g,be)|0,h=h+Math.imul(R,ge)|0,x=x+Math.imul(R,be)|0;var Be=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Be>>>26)|0,Be&=67108863,y=Math.imul(q,le),h=Math.imul(q,pe),h=h+Math.imul(K,le)|0,x=Math.imul(K,pe),y=y+Math.imul(E,ge)|0,h=h+Math.imul(E,be)|0,h=h+Math.imul(N,ge)|0,x=x+Math.imul(N,be)|0,y=y+Math.imul(g,ve)|0,h=h+Math.imul(g,me)|0,h=h+Math.imul(R,ve)|0,x=x+Math.imul(R,me)|0;var ke=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ke>>>26)|0,ke&=67108863,y=Math.imul($,le),h=Math.imul($,pe),h=h+Math.imul(V,le)|0,x=Math.imul(V,pe),y=y+Math.imul(q,ge)|0,h=h+Math.imul(q,be)|0,h=h+Math.imul(K,ge)|0,x=x+Math.imul(K,be)|0,y=y+Math.imul(E,ve)|0,h=h+Math.imul(E,me)|0,h=h+Math.imul(N,ve)|0,x=x+Math.imul(N,me)|0,y=y+Math.imul(g,ye)|0,h=h+Math.imul(g,we)|0,h=h+Math.imul(R,ye)|0,x=x+Math.imul(R,we)|0;var jt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(jt>>>26)|0,jt&=67108863,y=Math.imul(G,le),h=Math.imul(G,pe),h=h+Math.imul(Y,le)|0,x=Math.imul(Y,pe),y=y+Math.imul($,ge)|0,h=h+Math.imul($,be)|0,h=h+Math.imul(V,ge)|0,x=x+Math.imul(V,be)|0,y=y+Math.imul(q,ve)|0,h=h+Math.imul(q,me)|0,h=h+Math.imul(K,ve)|0,x=x+Math.imul(K,me)|0,y=y+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(N,ye)|0,x=x+Math.imul(N,we)|0,y=y+Math.imul(g,_e)|0,h=h+Math.imul(g,xe)|0,h=h+Math.imul(R,_e)|0,x=x+Math.imul(R,xe)|0;var Vt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,y=Math.imul(ie,le),h=Math.imul(ie,pe),h=h+Math.imul(ne,le)|0,x=Math.imul(ne,pe),y=y+Math.imul(G,ge)|0,h=h+Math.imul(G,be)|0,h=h+Math.imul(Y,ge)|0,x=x+Math.imul(Y,be)|0,y=y+Math.imul($,ve)|0,h=h+Math.imul($,me)|0,h=h+Math.imul(V,ve)|0,x=x+Math.imul(V,me)|0,y=y+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,x=x+Math.imul(K,we)|0,y=y+Math.imul(E,_e)|0,h=h+Math.imul(E,xe)|0,h=h+Math.imul(N,_e)|0,x=x+Math.imul(N,xe)|0,y=y+Math.imul(g,Ee)|0,h=h+Math.imul(g,Se)|0,h=h+Math.imul(R,Ee)|0,x=x+Math.imul(R,Se)|0;var $t=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,y=Math.imul(se,le),h=Math.imul(se,pe),h=h+Math.imul(oe,le)|0,x=Math.imul(oe,pe),y=y+Math.imul(ie,ge)|0,h=h+Math.imul(ie,be)|0,h=h+Math.imul(ne,ge)|0,x=x+Math.imul(ne,be)|0,y=y+Math.imul(G,ve)|0,h=h+Math.imul(G,me)|0,h=h+Math.imul(Y,ve)|0,x=x+Math.imul(Y,me)|0,y=y+Math.imul($,ye)|0,h=h+Math.imul($,we)|0,h=h+Math.imul(V,ye)|0,x=x+Math.imul(V,we)|0,y=y+Math.imul(q,_e)|0,h=h+Math.imul(q,xe)|0,h=h+Math.imul(K,_e)|0,x=x+Math.imul(K,xe)|0,y=y+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(N,Ee)|0,x=x+Math.imul(N,Se)|0,y=y+Math.imul(g,Ie)|0,h=h+Math.imul(g,Me)|0,h=h+Math.imul(R,Ie)|0,x=x+Math.imul(R,Me)|0;var Ht=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,y=Math.imul(ae,le),h=Math.imul(ae,pe),h=h+Math.imul(fe,le)|0,x=Math.imul(fe,pe),y=y+Math.imul(se,ge)|0,h=h+Math.imul(se,be)|0,h=h+Math.imul(oe,ge)|0,x=x+Math.imul(oe,be)|0,y=y+Math.imul(ie,ve)|0,h=h+Math.imul(ie,me)|0,h=h+Math.imul(ne,ve)|0,x=x+Math.imul(ne,me)|0,y=y+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(Y,ye)|0,x=x+Math.imul(Y,we)|0,y=y+Math.imul($,_e)|0,h=h+Math.imul($,xe)|0,h=h+Math.imul(V,_e)|0,x=x+Math.imul(V,xe)|0,y=y+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,x=x+Math.imul(K,Se)|0,y=y+Math.imul(E,Ie)|0,h=h+Math.imul(E,Me)|0,h=h+Math.imul(N,Ie)|0,x=x+Math.imul(N,Me)|0,y=y+Math.imul(g,Ae)|0,h=h+Math.imul(g,Re)|0,h=h+Math.imul(R,Ae)|0,x=x+Math.imul(R,Re)|0;var Gt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,y=Math.imul(ce,le),h=Math.imul(ce,pe),h=h+Math.imul(he,le)|0,x=Math.imul(he,pe),y=y+Math.imul(ae,ge)|0,h=h+Math.imul(ae,be)|0,h=h+Math.imul(fe,ge)|0,x=x+Math.imul(fe,be)|0,y=y+Math.imul(se,ve)|0,h=h+Math.imul(se,me)|0,h=h+Math.imul(oe,ve)|0,x=x+Math.imul(oe,me)|0,y=y+Math.imul(ie,ye)|0,h=h+Math.imul(ie,we)|0,h=h+Math.imul(ne,ye)|0,x=x+Math.imul(ne,we)|0,y=y+Math.imul(G,_e)|0,h=h+Math.imul(G,xe)|0,h=h+Math.imul(Y,_e)|0,x=x+Math.imul(Y,xe)|0,y=y+Math.imul($,Ee)|0,h=h+Math.imul($,Se)|0,h=h+Math.imul(V,Ee)|0,x=x+Math.imul(V,Se)|0,y=y+Math.imul(q,Ie)|0,h=h+Math.imul(q,Me)|0,h=h+Math.imul(K,Ie)|0,x=x+Math.imul(K,Me)|0,y=y+Math.imul(E,Ae)|0,h=h+Math.imul(E,Re)|0,h=h+Math.imul(N,Ae)|0,x=x+Math.imul(N,Re)|0,y=y+Math.imul(g,Te)|0,h=h+Math.imul(g,De)|0,h=h+Math.imul(R,Te)|0,x=x+Math.imul(R,De)|0;var Qi=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,y=Math.imul(ue,le),h=Math.imul(ue,pe),h=h+Math.imul(de,le)|0,x=Math.imul(de,pe),y=y+Math.imul(ce,ge)|0,h=h+Math.imul(ce,be)|0,h=h+Math.imul(he,ge)|0,x=x+Math.imul(he,be)|0,y=y+Math.imul(ae,ve)|0,h=h+Math.imul(ae,me)|0,h=h+Math.imul(fe,ve)|0,x=x+Math.imul(fe,me)|0,y=y+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,x=x+Math.imul(oe,we)|0,y=y+Math.imul(ie,_e)|0,h=h+Math.imul(ie,xe)|0,h=h+Math.imul(ne,_e)|0,x=x+Math.imul(ne,xe)|0,y=y+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(Y,Ee)|0,x=x+Math.imul(Y,Se)|0,y=y+Math.imul($,Ie)|0,h=h+Math.imul($,Me)|0,h=h+Math.imul(V,Ie)|0,x=x+Math.imul(V,Me)|0,y=y+Math.imul(q,Ae)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(K,Ae)|0,x=x+Math.imul(K,Re)|0,y=y+Math.imul(E,Te)|0,h=h+Math.imul(E,De)|0,h=h+Math.imul(N,Te)|0,x=x+Math.imul(N,De)|0,y=y+Math.imul(g,Pe)|0,h=h+Math.imul(g,Ne)|0,h=h+Math.imul(R,Pe)|0,x=x+Math.imul(R,Ne)|0;var en=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(en>>>26)|0,en&=67108863,y=Math.imul(ue,ge),h=Math.imul(ue,be),h=h+Math.imul(de,ge)|0,x=Math.imul(de,be),y=y+Math.imul(ce,ve)|0,h=h+Math.imul(ce,me)|0,h=h+Math.imul(he,ve)|0,x=x+Math.imul(he,me)|0,y=y+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(fe,ye)|0,x=x+Math.imul(fe,we)|0,y=y+Math.imul(se,_e)|0,h=h+Math.imul(se,xe)|0,h=h+Math.imul(oe,_e)|0,x=x+Math.imul(oe,xe)|0,y=y+Math.imul(ie,Ee)|0,h=h+Math.imul(ie,Se)|0,h=h+Math.imul(ne,Ee)|0,x=x+Math.imul(ne,Se)|0,y=y+Math.imul(G,Ie)|0,h=h+Math.imul(G,Me)|0,h=h+Math.imul(Y,Ie)|0,x=x+Math.imul(Y,Me)|0,y=y+Math.imul($,Ae)|0,h=h+Math.imul($,Re)|0,h=h+Math.imul(V,Ae)|0,x=x+Math.imul(V,Re)|0,y=y+Math.imul(q,Te)|0,h=h+Math.imul(q,De)|0,h=h+Math.imul(K,Te)|0,x=x+Math.imul(K,De)|0,y=y+Math.imul(E,Pe)|0,h=h+Math.imul(E,Ne)|0,h=h+Math.imul(N,Pe)|0,x=x+Math.imul(N,Ne)|0;var tn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(tn>>>26)|0,tn&=67108863,y=Math.imul(ue,ve),h=Math.imul(ue,me),h=h+Math.imul(de,ve)|0,x=Math.imul(de,me),y=y+Math.imul(ce,ye)|0,h=h+Math.imul(ce,we)|0,h=h+Math.imul(he,ye)|0,x=x+Math.imul(he,we)|0,y=y+Math.imul(ae,_e)|0,h=h+Math.imul(ae,xe)|0,h=h+Math.imul(fe,_e)|0,x=x+Math.imul(fe,xe)|0,y=y+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,x=x+Math.imul(oe,Se)|0,y=y+Math.imul(ie,Ie)|0,h=h+Math.imul(ie,Me)|0,h=h+Math.imul(ne,Ie)|0,x=x+Math.imul(ne,Me)|0,y=y+Math.imul(G,Ae)|0,h=h+Math.imul(G,Re)|0,h=h+Math.imul(Y,Ae)|0,x=x+Math.imul(Y,Re)|0,y=y+Math.imul($,Te)|0,h=h+Math.imul($,De)|0,h=h+Math.imul(V,Te)|0,x=x+Math.imul(V,De)|0,y=y+Math.imul(q,Pe)|0,h=h+Math.imul(q,Ne)|0,h=h+Math.imul(K,Pe)|0,x=x+Math.imul(K,Ne)|0;var rn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(rn>>>26)|0,rn&=67108863,y=Math.imul(ue,ye),h=Math.imul(ue,we),h=h+Math.imul(de,ye)|0,x=Math.imul(de,we),y=y+Math.imul(ce,_e)|0,h=h+Math.imul(ce,xe)|0,h=h+Math.imul(he,_e)|0,x=x+Math.imul(he,xe)|0,y=y+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(fe,Ee)|0,x=x+Math.imul(fe,Se)|0,y=y+Math.imul(se,Ie)|0,h=h+Math.imul(se,Me)|0,h=h+Math.imul(oe,Ie)|0,x=x+Math.imul(oe,Me)|0,y=y+Math.imul(ie,Ae)|0,h=h+Math.imul(ie,Re)|0,h=h+Math.imul(ne,Ae)|0,x=x+Math.imul(ne,Re)|0,y=y+Math.imul(G,Te)|0,h=h+Math.imul(G,De)|0,h=h+Math.imul(Y,Te)|0,x=x+Math.imul(Y,De)|0,y=y+Math.imul($,Pe)|0,h=h+Math.imul($,Ne)|0,h=h+Math.imul(V,Pe)|0,x=x+Math.imul(V,Ne)|0;var nn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nn>>>26)|0,nn&=67108863,y=Math.imul(ue,_e),h=Math.imul(ue,xe),h=h+Math.imul(de,_e)|0,x=Math.imul(de,xe),y=y+Math.imul(ce,Ee)|0,h=h+Math.imul(ce,Se)|0,h=h+Math.imul(he,Ee)|0,x=x+Math.imul(he,Se)|0,y=y+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Me)|0,h=h+Math.imul(fe,Ie)|0,x=x+Math.imul(fe,Me)|0,y=y+Math.imul(se,Ae)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(oe,Ae)|0,x=x+Math.imul(oe,Re)|0,y=y+Math.imul(ie,Te)|0,h=h+Math.imul(ie,De)|0,h=h+Math.imul(ne,Te)|0,x=x+Math.imul(ne,De)|0,y=y+Math.imul(G,Pe)|0,h=h+Math.imul(G,Ne)|0,h=h+Math.imul(Y,Pe)|0,x=x+Math.imul(Y,Ne)|0;var sn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(sn>>>26)|0,sn&=67108863,y=Math.imul(ue,Ee),h=Math.imul(ue,Se),h=h+Math.imul(de,Ee)|0,x=Math.imul(de,Se),y=y+Math.imul(ce,Ie)|0,h=h+Math.imul(ce,Me)|0,h=h+Math.imul(he,Ie)|0,x=x+Math.imul(he,Me)|0,y=y+Math.imul(ae,Ae)|0,h=h+Math.imul(ae,Re)|0,h=h+Math.imul(fe,Ae)|0,x=x+Math.imul(fe,Re)|0,y=y+Math.imul(se,Te)|0,h=h+Math.imul(se,De)|0,h=h+Math.imul(oe,Te)|0,x=x+Math.imul(oe,De)|0,y=y+Math.imul(ie,Pe)|0,h=h+Math.imul(ie,Ne)|0,h=h+Math.imul(ne,Pe)|0,x=x+Math.imul(ne,Ne)|0;var on=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(on>>>26)|0,on&=67108863,y=Math.imul(ue,Ie),h=Math.imul(ue,Me),h=h+Math.imul(de,Ie)|0,x=Math.imul(de,Me),y=y+Math.imul(ce,Ae)|0,h=h+Math.imul(ce,Re)|0,h=h+Math.imul(he,Ae)|0,x=x+Math.imul(he,Re)|0,y=y+Math.imul(ae,Te)|0,h=h+Math.imul(ae,De)|0,h=h+Math.imul(fe,Te)|0,x=x+Math.imul(fe,De)|0,y=y+Math.imul(se,Pe)|0,h=h+Math.imul(se,Ne)|0,h=h+Math.imul(oe,Pe)|0,x=x+Math.imul(oe,Ne)|0;var an=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(an>>>26)|0,an&=67108863,y=Math.imul(ue,Ae),h=Math.imul(ue,Re),h=h+Math.imul(de,Ae)|0,x=Math.imul(de,Re),y=y+Math.imul(ce,Te)|0,h=h+Math.imul(ce,De)|0,h=h+Math.imul(he,Te)|0,x=x+Math.imul(he,De)|0,y=y+Math.imul(ae,Pe)|0,h=h+Math.imul(ae,Ne)|0,h=h+Math.imul(fe,Pe)|0,x=x+Math.imul(fe,Ne)|0;var fn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(fn>>>26)|0,fn&=67108863,y=Math.imul(ue,Te),h=Math.imul(ue,De),h=h+Math.imul(de,Te)|0,x=Math.imul(de,De),y=y+Math.imul(ce,Pe)|0,h=h+Math.imul(ce,Ne)|0,h=h+Math.imul(he,Pe)|0,x=x+Math.imul(he,Ne)|0;var cn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(cn>>>26)|0,cn&=67108863,y=Math.imul(ue,Pe),h=Math.imul(ue,Ne),h=h+Math.imul(de,Pe)|0,x=Math.imul(de,Ne);var hn=(_+y|0)+((h&8191)<<13)|0;return _=(x+(h>>>13)|0)+(hn>>>26)|0,hn&=67108863,m[0]=nr,m[1]=Be,m[2]=ke,m[3]=jt,m[4]=Vt,m[5]=$t,m[6]=Ht,m[7]=Gt,m[8]=Qi,m[9]=en,m[10]=tn,m[11]=rn,m[12]=nn,m[13]=sn,m[14]=on,m[15]=an,m[16]=fn,m[17]=cn,m[18]=hn,_!==0&&(m[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,d=0;d>>26)|0,a+=m>>>26,m&=67108863}w.words[d]=_,p=m,m=a}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(D,l,w){var p=new P;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=O(this,l,w),p};function P(D,l){this.x=D,this.y=l}P.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},P.prototype.permute=function(l,w,p,a,d,m){for(var _=0;_>>1)d++;return 1<>>13,p[2*m+1]=d&8191,d=d>>>13;for(m=2*w;m>=26,w+=a/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,d;if(w!==0){var m=0;for(d=0;d>>26-w}m&&(this.words[d]=m,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var a;w?a=(w-w%26)/26:a=0;var d=l%26,m=Math.min((l-d)/26,this.length),_=67108863^67108863>>>d<m)for(this.length-=m,h=0;h=0&&(x!==0||h>=a);h--){var A=this.words[h]|0;this.words[h]=x<<26-d|A>>>d,x=A&_}return y&&x!==0&&(y.words[y.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(y/67108864|0),this.words[d+p]=m&67108863}for(;d>26,this.words[d+p]=m&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,d=0;d>26,this.words[d]=m&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),d=l,m=d.words[d.length-1]|0,_=this._countBits(m);p=26-_,p!==0&&(d=d.ushln(p),a.iushln(p),m=d.words[d.length-1]|0);var y=a.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=y+1,h.words=new Array(h.length);for(var x=0;x=0;g--){var R=(a.words[d.length+g]|0)*67108864+(a.words[d.length+g-1]|0);for(R=Math.min(R/m|0,67108863),a._ishlnsubmul(d,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(d,1,g),a.isZero()||(a.negative^=1);h&&(h.words[g]=R)}return h&&h.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:h||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,d,m;return this.negative!==0&&l.negative===0?(m=this.neg().divmod(l,w),w!=="mod"&&(a=m.div.neg()),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:a,mod:d}):this.negative===0&&l.negative!==0?(m=this.divmod(l.neg(),w),w!=="mod"&&(a=m.div.neg()),{div:a,mod:m.mod}):this.negative&l.negative?(m=this.neg().divmod(l.neg(),w),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:m.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),d=l.andln(1),m=p.cmp(a);return m<0||d===1&&m===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=new n(0),_=new n(1),y=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++y;for(var h=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(h),d.isub(x)),a.iushrn(1),d.iushrn(1);for(var R=0,k=1;!(p.words[0]&k)&&R<26;++R,k<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(m.isOdd()||_.isOdd())&&(m.iadd(h),_.isub(x)),m.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(m),d.isub(_)):(p.isub(w),m.isub(a),_.isub(d))}return{a:m,b:_,gcd:p.iushln(y)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,y=1;!(w.words[0]&y)&&_<26;++_,y<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(m),a.iushrn(1);for(var h=0,x=1;!(p.words[0]&x)&&h<26;++h,x<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(m),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(d)):(p.isub(w),d.isub(a))}var A;return w.cmpn(1)===0?A=a:A=d,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var m=w;w=p,p=m}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[m]=_}return d!==0&&(this.words[m]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,d=l.words[p]|0;if(a!==d){ad&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new C(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var z={k256:null,p224:null,p192:null,p25519:null};function B(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}B.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},B.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},B.prototype.split=function(l,w){l.iushrn(this.n,0,w)},B.prototype.imulK=function(l){return l.imul(this.k)};function U(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(U,B),U.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),d=0;d>>22,m=_}m>>>=22,l.words[d-10]=m,m===0&&l.length>10?l.length-=10:l.length-=9},U.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(z[l])return z[l];var w;if(l==="k256")w=new U;else if(l==="p224")w=new j;else if(l==="p192")w=new H;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return z[l]=w,w};function C(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}C.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},C.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},C.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},C.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},C.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},C.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},C.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},C.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},C.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},C.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},C.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},C.prototype.isqr=function(l){return this.imul(l,l.clone())},C.prototype.sqr=function(l){return this.mul(l,l)},C.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);t(!a.isZero());var m=new n(1).toRed(this),_=m.redNeg(),y=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,y).cmp(_)!==0;)h.redIAdd(_);for(var x=this.pow(h,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=d;g.cmp(m)!==0;){for(var k=g,E=0;k.cmp(m)!==0;E++)k=k.redSqr();t(E=0;d--){for(var x=w.words[d],A=h-1;A>=0;A--){var g=x>>A&1;if(m!==a[0]&&(m=this.sqr(m)),g===0&&_===0){y=0;continue}_<<=1,_|=g,y++,!(y!==p&&(d!==0||A!==0))&&(m=this.mul(m,a[_]),y=0,_=0)}h=26}return m},C.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},C.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(D){C.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,C),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof su>"u"||su,vg)});var ou=Z(wg=>{"use strict";var hf=wg;function Y8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}hf.toArray=Y8;function mg(r){return r.length===1?"0"+r:r}hf.zero2=mg;function yg(r){for(var e="",t=0;t{"use strict";var dr=_g,X8=Jr(),Z8=Pi(),uf=ou();dr.assert=Z8;dr.toArray=uf.toArray;dr.zero2=uf.zero2;dr.toHex=uf.toHex;dr.encode=uf.encode;function Q8(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-u:f=u,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}dr.getNAF=Q8;function e4(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var u;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?u=-o:u=o):u=0,t[0].push(u);var c;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?c=-f:c=f):c=0,t[1].push(c),2*i===u+1&&(i=1-i),2*n===c+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}dr.getJSF=e4;function t4(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}dr.cachedProperty=t4;function r4(r){return typeof r=="string"?dr.toArray(r,"hex"):r}dr.parseBytes=r4;function i4(r){return new X8(r,"hex","le")}dr.intFromLE=i4});var hu=Z((KR,cu)=>{var au;cu.exports=function(e){return au||(au=new Fi(null)),au.generate(e)};function Fi(r){this.rand=r}cu.exports.Rand=Fi;Fi.prototype.generate=function(e){return this._rand(e)};Fi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var En=Jr(),mo=Bt(),df=mo.getNAF,n4=mo.getJSF,lf=mo.assert;function qi(r,e){this.type=r,this.p=new En(e.p,16),this.red=e.prime?En.red(e.prime):En.mont(this.p),this.zero=new En(0).toRed(this.red),this.one=new En(1).toRed(this.red),this.two=new En(2).toRed(this.red),this.n=e.n&&new En(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}xg.exports=qi;qi.prototype.point=function(){throw new Error("Not implemented")};qi.prototype.validate=function(){throw new Error("Not implemented")};qi.prototype._fixedNafMul=function(e,t){lf(e.precomputed);var i=e._getDoubles(),n=df(t,1,this._bitLength),s=(1<=f;c--)u=(u<<1)+n[c];o.push(u)}for(var b=this.jpoint(null,null,null),v=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;u--){for(var c=0;u>=0&&o[u]===0;u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var b=o[u];lf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};qi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,c=0,b,v,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){u[M]=df(i[M],o[M],this._bitLength),u[T]=df(i[T],o[T],this._bitLength),c=Math.max(u[M].length,c),c=Math.max(u[T].length,c);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],z=n4(i[M],i[T]);for(c=Math.max(z[0].length,c),u[M]=new Array(c),u[T]=new Array(c),v=0;v=0;b--){for(var L=0;b>=0;){var C=!0;for(v=0;v=0&&L++,j=j.dblp(L),b<0)break;for(v=0;v0?S=f[v][W-1>>1]:W<0&&(S=f[v][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Qt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var s4=Bt(),et=Jr(),uu=co(),ps=yo(),o4=s4.assert;function er(r){ps.call(this,"short",r),this.a=new et(r.a,16).toRed(this.red),this.b=new et(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}uu(er,ps);Eg.exports=er;er.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new et(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new et(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],o4(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new et(f.a,16),b:new et(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};er.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:et.mont(e),i=new et(2).toRed(t).redInvm(),n=i.redNeg(),s=new et(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};er.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new et(1),o=new et(0),f=new et(0),u=new et(1),c,b,v,S,I,M,T,O=0,P,z;i.cmpn(0)!==0;){var B=n.div(i);P=n.sub(B.mul(i)),z=f.sub(B.mul(s));var U=u.sub(B.mul(o));if(!v&&P.cmp(t)<0)c=T.neg(),b=s,v=P.neg(),S=z;else if(v&&++O===2)break;T=P,n=i,i=P,f=s,s=z,u=o,o=U}I=P.neg(),M=z;var j=v.sqr().add(S.sqr()),H=I.sqr().add(M.sqr());return H.cmp(j)>=0&&(I=c,M=b),v.negative&&(v=v.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:v,b:S},{a:I,b:M}]};er.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),c=s.mul(i.b),b=o.mul(n.b),v=e.sub(f).sub(u),S=c.add(b).neg();return{k1:v,k2:S}};er.prototype.pointFromX=function(e,t){e=new et(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};er.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};er.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ct.prototype.isInfinity=function(){return this.inf};ct.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ct.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ct.prototype.getX=function(){return this.x.fromRed()};ct.prototype.getY=function(){return this.y.fromRed()};ct.prototype.mul=function(e){return e=new et(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ct.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ct.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ct.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ct.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ct.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function bt(r,e,t,i){ps.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new et(0)):(this.x=new et(e,16),this.y=new et(t,16),this.z=new et(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}uu(bt,ps.BasePoint);er.prototype.jpoint=function(e,t,i){return new bt(this,e,t,i)};bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),c=o.redSub(f);if(u.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=u.redSqr(),v=b.redMul(u),S=n.redMul(b),I=c.redSqr().redIAdd(v).redISub(S).redISub(S),M=c.redMul(S.redISub(I)).redISub(o.redMul(v)),T=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(I,M,T)};bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),b=c.redMul(f),v=i.redMul(c),S=u.redSqr().redIAdd(b).redISub(v).redISub(v),I=u.redMul(v.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};bt.prototype.inspect=function(){return this.isInfinity()?"":""};bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Ag=Z(($R,Mg)=>{"use strict";var gs=Jr(),Ig=co(),pf=yo(),a4=Bt();function bs(r){pf.call(this,"mont",r),this.a=new gs(r.a,16).toRed(this.red),this.b=new gs(r.b,16).toRed(this.red),this.i4=new gs(4).toRed(this.red).redInvm(),this.two=new gs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Ig(bs,pf);Mg.exports=bs;bs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function ht(r,e,t){pf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new gs(e,16),this.z=new gs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Ig(ht,pf.BasePoint);bs.prototype.decodePoint=function(e,t){return this.point(a4.toArray(e,t),1)};bs.prototype.point=function(e,t){return new ht(this,e,t)};bs.prototype.pointFromJSON=function(e){return ht.fromJSON(this,e)};ht.prototype.precompute=function(){};ht.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};ht.fromJSON=function(e,t){return new ht(e,t[0],t[1]||e.one)};ht.prototype.inspect=function(){return this.isInfinity()?"":""};ht.prototype.isInfinity=function(){return this.z.cmpn(0)===0};ht.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};ht.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),u=s.redMul(n),c=t.z.redMul(f.redAdd(u).redSqr()),b=t.x.redMul(f.redISub(u).redSqr());return this.curve.point(c,b)};ht.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};ht.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};ht.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};ht.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Dg=Z((HR,Tg)=>{"use strict";var f4=Bt(),vi=Jr(),Rg=co(),gf=yo(),c4=f4.assert;function Yr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,gf.call(this,"edwards",r),this.a=new vi(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new vi(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new vi(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c4(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Rg(Yr,gf);Tg.exports=Yr;Yr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Yr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Yr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Yr.prototype.pointFromX=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=f.fromRed().isOdd();return(t&&!u||!t&&u)&&(f=f.redNeg()),this.point(e,f)};Yr.prototype.pointFromY=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};Yr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ge(r,e,t,i,n){gf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new vi(e,16),this.y=new vi(t,16),this.z=i?new vi(i,16):this.curve.one,this.t=n&&new vi(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Rg(Ge,gf.BasePoint);Yr.prototype.pointFromJSON=function(e){return Ge.fromJSON(this,e)};Yr.prototype.point=function(e,t,i,n){return new Ge(this,e,t,i,n)};Ge.fromJSON=function(e,t){return new Ge(e,t[0],t[1],t[2])};Ge.prototype.inspect=function(){return this.isInfinity()?"":""};Ge.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ge.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),u=n.redSub(t),c=s.redMul(f),b=o.redMul(u),v=s.redMul(u),S=f.redMul(o);return this.curve.point(c,b,S,v)};Ge.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,u,c;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(u=this.z.redSqr(),c=b.redSub(u).redISub(u),n=e.redSub(t).redISub(i).redMul(c),s=b.redMul(f.redSub(i)),o=b.redMul(c))}else f=t.redAdd(i),u=this.curve._mulC(this.z).redSqr(),c=f.redSub(u).redSub(u),n=this.curve._mulC(e.redISub(f)).redMul(c),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(c);return this.curve.point(n,s,o)};Ge.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ge.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),u=s.redAdd(n),c=i.redAdd(t),b=o.redMul(f),v=u.redMul(c),S=o.redMul(c),I=f.redMul(u);return this.curve.point(b,v,I,S)};Ge.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),u=i.redAdd(o),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(c),v,S;return this.curve.twisted?(v=t.redMul(u).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(u)):(v=t.redMul(u).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(u)),this.curve.point(b,v,S)};Ge.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ge.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ge.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ge.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ge.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ge.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ge.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ge.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ge.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ge.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ge.prototype.toP=Ge.prototype.normalize;Ge.prototype.mixedAdd=Ge.prototype.add});var du=Z(Pg=>{"use strict";var bf=Pg;bf.base=yo();bf.short=Sg();bf.mont=Ag();bf.edwards=Dg()});var Cg=Z((WR,Ng)=>{Ng.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var vf=Z(Fg=>{"use strict";var pu=Fg,Ui=lo(),lu=du(),h4=Bt(),Og=h4.assert;function Lg(r){r.type==="short"?this.curve=new lu.short(r):r.type==="edwards"?this.curve=new lu.edwards(r):this.curve=new lu.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,Og(this.g.validate(),"Invalid curve"),Og(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}pu.PresetCurve=Lg;function zi(r,e){Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,get:function(){var t=new Lg(e);return Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,value:t}),t}})}zi("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ui.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});zi("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ui.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});zi("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ui.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});zi("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ui.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});zi("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ui.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});zi("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ui.sha256,gRed:!1,g:["9"]});zi("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ui.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var gu;try{gu=Cg()}catch{gu=void 0}zi("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ui.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",gu]})});var zg=Z((YR,Ug)=>{"use strict";var u4=lo(),Sn=ou(),qg=Pi();function Bi(r){if(!(this instanceof Bi))return new Bi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Sn.toArray(r.entropy,r.entropyEnc||"hex"),t=Sn.toArray(r.nonce,r.nonceEnc||"hex"),i=Sn.toArray(r.pers,r.persEnc||"hex");qg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}Ug.exports=Bi;Bi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Bi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Sn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var d4=Jr(),l4=Bt(),bu=l4.assert;function St(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}Bg.exports=St;St.fromPublic=function(e,t,i){return t instanceof St?t:new St(e,{pub:t,pubEnc:i})};St.fromPrivate=function(e,t,i){return t instanceof St?t:new St(e,{priv:t,privEnc:i})};St.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};St.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};St.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};St.prototype._importPrivate=function(e,t){this.priv=new d4(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};St.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?bu(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&bu(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};St.prototype.derive=function(e){return e.validate()||bu(e.validate(),"public point not validated"),e.mul(this.priv).getX()};St.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};St.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)};St.prototype.inspect=function(){return""}});var Vg=Z((ZR,jg)=>{"use strict";var mf=Jr(),yu=Bt(),p4=yu.assert;function yf(r,e){if(r instanceof yf)return r;this._importDER(r,e)||(p4(r.r&&r.s,"Signature without r or s"),this.r=new mf(r.r,16),this.s=new mf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}jg.exports=yf;function g4(){this.place=0}function vu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Kg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}yf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Kg(t),i=Kg(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];mu(n,t.length),n=n.concat(t),n.push(2),mu(n,i.length);var s=n.concat(i),o=[48];return mu(o,s.length),o=o.concat(s),yu.encode(o,e)}});var Wg=Z((QR,Gg)=>{"use strict";var mi=Jr(),$g=zg(),b4=Bt(),wu=vf(),v4=hu(),Hg=b4.assert,_u=kg(),wf=Vg();function tr(r){if(!(this instanceof tr))return new tr(r);typeof r=="string"&&(Hg(Object.prototype.hasOwnProperty.call(wu,r),"Unknown curve "+r),r=wu[r]),r instanceof wu.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}Gg.exports=tr;tr.prototype.keyPair=function(e){return new _u(this,e)};tr.prototype.keyFromPrivate=function(e,t){return _u.fromPrivate(this,e,t)};tr.prototype.keyFromPublic=function(e,t){return _u.fromPublic(this,e,t)};tr.prototype.genKeyPair=function(e){e||(e={});for(var t=new $g({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new mi(2));;){var s=new mi(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};tr.prototype._truncateToN=function(e,t,i){var n;if(mi.isBN(e)||typeof e=="number")e=new mi(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new mi(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new mi(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};tr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength);for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new $g({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new mi(1)),b=0;;b++){var v=n.k?n.k(b):new mi(u.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(c)>=0)){var S=this.g.mul(v);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=v.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new wf({r:M,s:T,recoveryParam:O})}}}}}};tr.prototype.verify=function(e,t,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),t=new wf(t,"hex");var o=t.r,f=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),c=u.mul(e).umod(this.n),b=u.mul(o).umod(this.n),v;return this.curve._maxwellTrick?(v=this.g.jmulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.eqXToP(o)):(v=this.g.mulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.getX().umod(this.n).cmp(o)===0)};tr.prototype.recoverPubKey=function(r,e,t,i){Hg((3&t)===t,"The recovery param is more than two bits"),e=new wf(e,i);var n=this.n,s=new mi(r),o=e.r,f=e.s,u=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var b=e.r.invm(n),v=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(v,o,S)};tr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new wf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Zg=Z((eT,Xg)=>{"use strict";var wo=Bt(),Yg=wo.assert,Jg=wo.parseBytes,vs=wo.cachedProperty;function ut(r,e){this.eddsa=r,this._secret=Jg(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Jg(e.pub)}ut.fromPublic=function(e,t){return t instanceof ut?t:new ut(e,{pub:t})};ut.fromSecret=function(e,t){return t instanceof ut?t:new ut(e,{secret:t})};ut.prototype.secret=function(){return this._secret};vs(ut,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});vs(ut,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});vs(ut,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});vs(ut,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});vs(ut,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});vs(ut,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});ut.prototype.sign=function(e){return Yg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};ut.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};ut.prototype.getSecret=function(e){return Yg(this._secret,"KeyPair is public only"),wo.encode(this.secret(),e)};ut.prototype.getPublic=function(e){return wo.encode(this.pubBytes(),e)};Xg.exports=ut});var tb=Z((tT,eb)=>{"use strict";var m4=Jr(),_f=Bt(),Qg=_f.assert,xf=_f.cachedProperty,y4=_f.parseBytes;function In(r,e){this.eddsa=r,typeof e!="object"&&(e=y4(e)),Array.isArray(e)&&(Qg(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Qg(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof m4&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}xf(In,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});xf(In,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});xf(In,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});xf(In,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});In.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};In.prototype.toHex=function(){return _f.encode(this.toBytes(),"hex").toUpperCase()};eb.exports=In});var ob=Z((rT,sb)=>{"use strict";var w4=lo(),_4=vf(),ms=Bt(),x4=ms.assert,ib=ms.parseBytes,nb=Zg(),rb=tb();function Lt(r){if(x4(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Lt))return new Lt(r);r=_4[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=w4.sha512}sb.exports=Lt;Lt.prototype.sign=function(e,t){e=ib(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),u=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})};Lt.prototype.verify=function(e,t,i){if(e=ib(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Lt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Mn=ab;Mn.version=bg().version;Mn.utils=Bt();Mn.rand=hu();Mn.curve=du();Mn.curves=vf();Mn.ec=Wg();Mn.eddsa=ob()});var vv=Z($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isBrowserCryptoAvailable=$i.getSubtleCrypto=$i.getBrowerCrypto=void 0;function Wu(){return window?.crypto||window?.msCrypto||{}}$i.getBrowerCrypto=Wu;function bv(){let r=Wu();return r.subtle||r.webkitSubtle}$i.getSubtleCrypto=bv;function U_(){return!!Wu()&&!!bv()}$i.isBrowserCryptoAvailable=U_});var wv=Z(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.isBrowser=Hi.isNode=Hi.isReactNative=void 0;function mv(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Hi.isReactNative=mv;function yv(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Hi.isNode=yv;function z_(){return!mv()&&!yv()}Hi.isBrowser=z_});var Ju=Z(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});var _v=(zn(),qs(Un));_v.__exportStar(vv(),Lf);_v.__exportStar(wv(),Lf)});var Rv=Z((UT,Av)=>{"use strict";Av.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var dm=Z((qo,Ns)=>{var X_=200,cd="__lodash_hash_undefined__",Jf=1,jv=2,Vv=9007199254740991,Kf="[object Arguments]",rd="[object Array]",Z_="[object AsyncFunction]",$v="[object Boolean]",Hv="[object Date]",Gv="[object Error]",Wv="[object Function]",Q_="[object GeneratorFunction]",jf="[object Map]",Jv="[object Number]",ex="[object Null]",Ps="[object Object]",Nv="[object Promise]",tx="[object Proxy]",Yv="[object RegExp]",Vf="[object Set]",Xv="[object String]",rx="[object Symbol]",ix="[object Undefined]",id="[object WeakMap]",Zv="[object ArrayBuffer]",$f="[object DataView]",nx="[object Float32Array]",sx="[object Float64Array]",ox="[object Int8Array]",ax="[object Int16Array]",fx="[object Int32Array]",cx="[object Uint8Array]",hx="[object Uint8ClampedArray]",ux="[object Uint16Array]",dx="[object Uint32Array]",lx=/[\\^$.*+?()[\]{}|]/g,px=/^\[object .+?Constructor\]$/,gx=/^(?:0|[1-9]\d*)$/,Je={};Je[nx]=Je[sx]=Je[ox]=Je[ax]=Je[fx]=Je[cx]=Je[hx]=Je[ux]=Je[dx]=!0;Je[Kf]=Je[rd]=Je[Zv]=Je[$v]=Je[$f]=Je[Hv]=Je[Gv]=Je[Wv]=Je[jf]=Je[Jv]=Je[Ps]=Je[Yv]=Je[Vf]=Je[Xv]=Je[id]=!1;var Qv=typeof window=="object"&&window&&window.Object===Object&&window,bx=typeof self=="object"&&self&&self.Object===Object&&self,xi=Qv||bx||Function("return this")(),em=typeof qo=="object"&&qo&&!qo.nodeType&&qo,Cv=em&&typeof Ns=="object"&&Ns&&!Ns.nodeType&&Ns,tm=Cv&&Cv.exports===em,Qu=tm&&Qv.process,Ov=function(){try{return Qu&&Qu.binding&&Qu.binding("util")}catch{}}(),Lv=Ov&&Ov.isTypedArray;function vx(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function Gx(r,e){var t=this.__data__,i=Xf(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}Ei.prototype.clear=jx;Ei.prototype.delete=Vx;Ei.prototype.get=$x;Ei.prototype.has=Hx;Ei.prototype.set=Gx;function On(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var c=s.get(r);if(c&&s.get(e))return c==e;var b=-1,v=!0,S=t&jv?new Gf:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=Vv}function hm(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function Bo(r){return r!=null&&typeof r=="object"}var um=Lv?_x(Lv):hE;function SE(r){return xE(r)?oE(r):uE(r)}function IE(){return[]}function ME(){return!1}Ns.exports=EE});var Si=qe(un());var Pl=qe(un()),sa=qe(jn());var sr=class{};var mc=class extends sr{constructor(e){super()}},Dl=sa.FIVE_SECONDS,dn={pulse:"heartbeat_pulse"},na=class r extends mc{constructor(e){super(e),this.events=new Pl.EventEmitter,this.interval=Dl,this.interval=e?.interval||Dl}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,sa.toMiliseconds)(this.interval))}pulse(){this.events.emit(dn.pulse)}};var r2=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,i2=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n2=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function s2(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){o2(r);return}return e}function o2(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Bs(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!n2.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(r2.test(r)||i2.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,s2)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function a2(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ot(r,...e){try{return a2(r(...e))}catch(t){return Promise.reject(t)}}function f2(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function c2(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ks(r){if(f2(r))return String(r);if(c2(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ks(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Nl(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var yc="base64:";function Cl(r){if(typeof r=="string")return r;Nl();let e=Buffer.from(r).toString("base64");return yc+e}function Ol(r){return typeof r!="string"||!r.startsWith(yc)?r:(Nl(),Buffer.from(r.slice(yc.length),"base64"))}function Pt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Ll(...r){return Pt(r.join(":"))}function Ks(r){return r=Pt(r),r?r+":":""}var h2="memory",u2=()=>{let r=new Map;return{name:h2,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Ul(r={}){let e={mounts:{"":r.driver||u2()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(let b of e.mountpoints)if(c.startsWith(b))return{base:b,relativeKey:c.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,b)=>e.mountpoints.filter(v=>v.startsWith(c)||b&&c.startsWith(v)).map(v=>({relativeBase:c.length>v.length?c.slice(v.length):void 0,mountpoint:v,driver:e.mounts[v]})),n=(c,b)=>{if(e.watching){b=Pt(b);for(let v of e.watchListeners)v(c,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let c in e.mounts)e.unwatch[c]=await Fl(e.mounts[c],n,c)}},o=async()=>{if(e.watching){for(let c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},f=(c,b,v)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of c){let T=typeof M=="string",O=Pt(T?M:M.key),P=T?void 0:M.value,z=T||!M.options?b:{...b,...M.options},B=t(O);I(B).items.push({key:O,value:P,relativeKey:B.relativeKey,options:z})}return Promise.all([...S.values()].map(M=>v(M))).then(M=>M.flat())},u={hasItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.hasItem,v,b)},getItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.getItem,v,b).then(I=>Bs(I))},getItems(c,b){return f(c,b,v=>v.driver.getItems?ot(v.driver.getItems,v.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:Ll(v.base,I.key),value:Bs(I.value)}))):Promise.all(v.items.map(S=>ot(v.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Bs(I)})))))},getItemRaw(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return S.getItemRaw?ot(S.getItemRaw,v,b):ot(S.getItem,v,b).then(I=>Ol(I))},async setItem(c,b,v={}){if(b===void 0)return u.removeItem(c);c=Pt(c);let{relativeKey:S,driver:I}=t(c);I.setItem&&(await ot(I.setItem,S,ks(b),v),I.watch||n("update",c))},async setItems(c,b){await f(c,b,async v=>{if(v.driver.setItems)return ot(v.driver.setItems,v.items.map(S=>({key:S.relativeKey,value:ks(S.value),options:S.options})),b);v.driver.setItem&&await Promise.all(v.items.map(S=>ot(v.driver.setItem,S.relativeKey,ks(S.value),S.options)))})},async setItemRaw(c,b,v={}){if(b===void 0)return u.removeItem(c,v);c=Pt(c);let{relativeKey:S,driver:I}=t(c);if(I.setItemRaw)await ot(I.setItemRaw,S,b,v);else if(I.setItem)await ot(I.setItem,S,Cl(b),v);else return;I.watch||n("update",c)},async removeItem(c,b={}){typeof b=="boolean"&&(b={removeMeta:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c);S.removeItem&&(await ot(S.removeItem,v,b),(b.removeMeta||b.removeMata)&&await ot(S.removeItem,v+"$",b),S.watch||n("remove",c))},async getMeta(c,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ot(S.getMeta,v,b)),!b.nativeOnly){let M=await ot(S.getItem,v+"$",b).then(T=>Bs(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(c,b,v={}){return this.setItem(c+"$",b,v)},removeMeta(c,b={}){return this.removeItem(c+"$",b)},async getKeys(c,b={}){c=Ks(c);let v=i(c,!0),S=[],I=[];for(let M of v){let T=await ot(M.driver.getKeys,M.relativeBase,b);for(let O of T){let P=M.mountpoint+Pt(O);S.some(z=>P.startsWith(z))||I.push(P)}S=[M.mountpoint,...S.filter(O=>!O.startsWith(M.mountpoint))]}return c?I.filter(M=>M.startsWith(c)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(c,b={}){c=Ks(c),await Promise.all(i(c,!1).map(async v=>{if(v.driver.clear)return ot(v.driver.clear,v.relativeBase,b);if(v.driver.removeItem){let S=await v.driver.getKeys(v.relativeBase||"",b);return Promise.all(S.map(I=>v.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>ql(c)))},async watch(c){return await s(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,b){if(c=Ks(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((v,S)=>S.length-v.length)),e.mounts[c]=b,e.watching&&Promise.resolve(Fl(b,n,c)).then(v=>{e.unwatch[c]=v}).catch(console.error),u},async unmount(c,b=!0){c=Ks(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&(e.unwatch[c](),delete e.unwatch[c]),b&&await ql(e.mounts[c]),e.mountpoints=e.mountpoints.filter(v=>v!==c),delete e.mounts[c])},getMount(c=""){c=Pt(c)+":";let b=t(c);return{driver:b.driver,base:b.base}},getMounts(c="",b={}){return c=Pt(c),i(c,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(c,b={})=>u.getKeys(c,b),get:(c,b={})=>u.getItem(c,b),set:(c,b,v={})=>u.setItem(c,b,v),has:(c,b={})=>u.hasItem(c,b),del:(c,b={})=>u.removeItem(c,b),remove:(c,b={})=>u.removeItem(c,b)};return u}function Fl(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ql(r){typeof r.dispose=="function"&&await ot(r.dispose)}function ln(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function _c(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=ln(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var wc;function js(){return wc||(wc=_c("keyval-store","keyval")),wc}function xc(r,e=js()){return e("readonly",t=>ln(t.get(r)))}function zl(r,e,t=js()){return t("readwrite",i=>(i.put(e,r),ln(i.transaction)))}function Bl(r,e=js()){return e("readwrite",t=>(t.delete(r),ln(t.transaction)))}function kl(r=js()){return r("readwrite",e=>(e.clear(),ln(e.transaction)))}function d2(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},ln(r.transaction)}function Kl(r=js()){return r("readonly",e=>{if(e.getAllKeys)return ln(e.getAllKeys());let t=[];return d2(e,i=>t.push(i.key)).then(()=>t)})}var l2=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),p2=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Fr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return p2(r)}catch{return r}}function Wt(r){return typeof r=="string"?r:l2(r)||""}var g2="idb-keyval",b2=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=_c(r.dbName,r.storeName)),{name:g2,options:r,async hasItem(n){return!(typeof await xc(t(n),i)>"u")},async getItem(n){return await xc(t(n),i)??null},setItem(n,s){return zl(t(n),s,i)},removeItem(n){return Bl(t(n),i)},getKeys(){return Kl(i)},clear(){return kl(i)}}},v2="WALLET_CONNECT_V2_INDEXED_DB",m2="keyvaluestorage",Sc=class{constructor(){this.indexedDb=Ul({driver:b2({dbName:v2,storeName:m2})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Wt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},Ec=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},oa={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ec<"u"&&Ec.localStorage?oa.exports=Ec.localStorage:typeof window<"u"&&window.localStorage?oa.exports=window.localStorage:oa.exports=new e})();function y2(r){var e;return[r[0],Fr((e=r[1])!=null?e:"")]}var Ic=class{constructor(){this.localStorage=oa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(y2)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Fr(t)}async setItem(e,t){this.localStorage.setItem(e,Wt(t))}async removeItem(e){this.localStorage.removeItem(e)}},w2="wc_storage_version",jl=1,_2=async(r,e,t)=>{let i=w2,n=await e.getItem(i);if(n&&n>=jl){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let u=f.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){let c=await r.getItem(f);await e.setItem(f,c),o.push(f)}}await e.setItem(i,jl),t(e),x2(r,o)},x2=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},aa=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new Ic;this.storage=e;try{let t=new Sc;_2(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var ai=qe(Rc()),Hs=qe(Rc());var L2={level:"info"},Gs="custom_context",Nc=1e3*1024,Tc=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ha=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Tc(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},ua=class{constructor(e,t=Nc){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===ai.levels.values.error?console.error(e):t===ai.levels.values.warn?console.warn(e):t===ai.levels.values.debug?console.debug(e):t===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Wt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Wt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Dc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Pc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},F2=Object.defineProperty,q2=Object.defineProperties,U2=Object.getOwnPropertyDescriptors,Yl=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,B2=Object.prototype.propertyIsEnumerable,Xl=(r,e,t)=>e in r?F2(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e)=>{for(var t in e||(e={}))z2.call(e,t)&&Xl(r,t,e[t]);if(Yl)for(var t of Yl(e))B2.call(e,t)&&Xl(r,t,e[t]);return r},la=(r,e)=>q2(r,U2(e));function Ws(r){return la(da({},r),{level:r?.level||L2.level})}function k2(r,e=Gs){return r[e]||""}function K2(r,e,t=Gs){return r[t]=e,r}function yt(r,e=Gs){let t="";return typeof r.bindings>"u"?t=k2(r,e):t=r.bindings().context||"",t}function j2(r,e,t=Gs){let i=yt(r,t);return i.trim()?`${i}/${e}`:e}function lt(r,e,t=Gs){let i=j2(r,e,t),n=r.child({context:i});return K2(n,i,t)}function V2(r){var e,t;let i=new Dc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace",browser:la(da({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function $2(r){var e;let t=new Pc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Zl(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?V2(r):$2(r)}var Ql=qe(un()),pa=class extends sr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var ga=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},ba=class{constructor(e,t){this.logger=e,this.core=t}},va=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}},ma=class extends sr{constructor(e){super()}},ya=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var wa=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}};var _a=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t}};var xa=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Ea=class{constructor(e,t){this.projectId=e,this.logger=t}},Sa=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Ia=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Ma=class{constructor(e){this.client=e}};var re=qe(jn());var so=qe(T0()),op=qe(Js()),ap=qe(jn());var D0="EdDSA",P0="JWT",Zs=".",Qs="base64url",Xc="utf8",Zc="utf8",N0=":",C0="did",O0="key",Qc="base58btc",L0="z",F0="K36";function eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function vn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var nh={};Dt(nh,{identity:()=>$3});function B3(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(B);P!==z;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var k3=B3,K3=k3,q0=K3;var FI=new Uint8Array(0);var U0=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var z0=r=>new TextEncoder().encode(r),B0=r=>new TextDecoder().decode(r);var eh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},th=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K0(this,e)}},rh=class{constructor(e){this.decoders=e}or(e){return K0(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},K0=(r,e)=>new rh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ih=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,t,i),this.decoder=new th(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Yn=({name:r,prefix:e,encode:t,decode:i})=>new ih(r,e,t,i),Ti=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=q0(t,e);return Yn({prefix:r,name:e,encode:i,decode:s=>ci(n(s))})},j3=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[c++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},V3=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Yn({prefix:e,name:r,encode(n){return V3(n,i,t)},decode(n){return j3(n,i,t,r)}});var $3=Yn({prefix:"\0",name:"identity",encode:r=>B0(r),decode:r=>z0(r)});var sh={};Dt(sh,{base2:()=>H3});var H3=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oh={};Dt(oh,{base8:()=>G3});var G3=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah={};Dt(ah,{base10:()=>W3});var W3=Ti({prefix:"9",name:"base10",alphabet:"0123456789"});var fh={};Dt(fh,{base16:()=>J3,base16upper:()=>Y3});var J3=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y3=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ch={};Dt(ch,{base32:()=>Xn,base32hex:()=>e6,base32hexpad:()=>r6,base32hexpadupper:()=>i6,base32hexupper:()=>t6,base32pad:()=>Z3,base32padupper:()=>Q3,base32upper:()=>X3,base32z:()=>n6});var Xn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X3=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z3=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q3=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hh={};Dt(hh,{base36:()=>s6,base36upper:()=>o6});var s6=Ti({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o6=Ti({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uh={};Dt(uh,{base58btc:()=>Ur,base58flickr:()=>a6});var Ur=Ti({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),a6=Ti({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh={};Dt(dh,{base64:()=>f6,base64pad:()=>c6,base64url:()=>h6,base64urlpad:()=>u6});var f6=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),u6=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lh={};Dt(lh,{base256emoji:()=>b6});var j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),d6=j0.reduce((r,e,t)=>(r[t]=e,r),[]),l6=j0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function p6(r){return r.reduce((e,t)=>(e+=d6[t],e),"")}function g6(r){let e=[];for(let t of r){let i=l6[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var b6=Yn({prefix:"\u{1F680}",name:"base256emoji",encode:p6,decode:g6});var vh={};Dt(vh,{sha256:()=>L6,sha512:()=>F6});var v6=H0,V0=128,m6=127,y6=~m6,w6=Math.pow(2,31);function H0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=w6;)e[t++]=r&255|V0,r/=128;for(;r&y6;)e[t++]=r&255|V0,r>>>=7;return e[t]=r|0,H0.bytes=t-i+1,e}var _6=ph,x6=128,$0=127;function ph(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw ph.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&$0)<=x6);return ph.bytes=s-i,t}var E6=Math.pow(2,7),S6=Math.pow(2,14),I6=Math.pow(2,21),M6=Math.pow(2,28),A6=Math.pow(2,35),R6=Math.pow(2,42),T6=Math.pow(2,49),D6=Math.pow(2,56),P6=Math.pow(2,63),N6=function(r){return r[to.decode(r,e),to.decode.bytes],Zn=(r,e,t=0)=>(to.encode(r,e,t),e),Qn=r=>to.encodingLength(r);var mn=(r,e)=>{let t=e.byteLength,i=Qn(r),n=i+Qn(t),s=new Uint8Array(n+t);return Zn(r,s,0),Zn(t,s,i),s.set(e,n),new es(r,t,e,s)},G0=r=>{let e=ci(r),[t,i]=ro(e),[n,s]=ro(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new es(t,n,o,e)},W0=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&U0(r.bytes,e.bytes),es=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var bh=({name:r,code:e,encode:t})=>new gh(r,e,t),gh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?mn(this.code,t):t.then(i=>mn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var Y0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),L6=bh({name:"sha2-256",code:18,encode:Y0("SHA-256")}),F6=bh({name:"sha2-512",code:19,encode:Y0("SHA-512")});var mh={};Dt(mh,{identity:()=>z6});var X0=0,q6="identity",Z0=ci,U6=r=>mn(X0,Z0(r)),z6={code:X0,name:q6,encode:Z0,digest:U6};var iM=new TextEncoder,nM=new TextDecoder;var La=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oa,byteLength:Oa,code:Ca,version:Ca,multihash:Ca,bytes:Ca,_baseCache:Oa,asCID:Oa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==no)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=mn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&W0(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return j6(t,n,e||Ur.encoder);default:return V6(t,n,e||Xn.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return G6(/^0\.0/,W6),!!(e&&(e[ep]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||Q0(t,i,n.bytes))}else if(e!=null&&e[ep]===!0){let{version:t,multihash:i,code:n}=e,s=G0(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==no)throw new Error(`Version 0 CID must use dag-pb (code: ${no}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Q0(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,no,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=ci(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new es(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[v,S]=ro(e.subarray(t));return t+=S,v},n=i(),s=no;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),u=i(),c=t+u,b=c-o;return{version:n,codec:s,multihashCode:f,digestSize:u,multihashSize:b,size:c}}static parse(e,t){let[i,n]=K6(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},K6=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ur;return[Ur.prefix,t.decode(`${Ur.prefix}${r}`)]}case Ur.prefix:{let t=e||Ur;return[Ur.prefix,t.decode(r)]}case Xn.prefix:{let t=e||Xn;return[Xn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},j6=(r,e,t)=>{let{prefix:i}=t;if(i!==Ur.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},V6=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},no=112,$6=18,Q0=(r,e,t)=>{let i=Qn(r),n=i+Qn(e),s=new Uint8Array(n+t.byteLength);return Zn(r,s,0),Zn(e,s,i),s.set(t,n),s},ep=Symbol.for("@ipld/js-cid/CID"),Ca={writable:!1,configurable:!1,enumerable:!0},Oa={writable:!1,enumerable:!1,configurable:!1},H6="0.0.0-dev",G6=(r,e)=>{if(r.test(H6))console.warn(e);else throw new Error(e)},W6=`CID.isCID(v) is deprecated and will be removed in the next major release. Following code pattern: if (CID.isCID(value)) { @@ -20,16 +20,16 @@ if (cid) { // Make sure to use cid instead of value doSomethingWithCID(cid) } -`;var yh={...nh,...sh,...oh,...ah,...fh,...ch,...hh,...uh,...dh,...lh},dM={...vh,...mh};function rp(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var tp=rp("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),wh=rp("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=eo(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new nw:typeof navigator<"u"?dp(navigator.userAgent):hw()}function fw(r){return r!==""&&aw.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function dp(r){var e=fw(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new iw;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var Bp=Nw(),Ih;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(Ih||(Ih={}));var or;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(or||(or={}));var kp="0123456789abcdef",at=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();Ka[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(zp>Ka[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(Up)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(d=>{let h=i[d];try{if(h instanceof Uint8Array){let b="";for(let y=0;y>4],b+=kp[h[y]&15];n.push(d+"=Uint8Array(0x"+b+")")}else n.push(d+"="+JSON.stringify(h))}catch{n.push(d+"="+JSON.stringify(i[d].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case or.NUMERIC_FAULT:{o="NUMERIC_FAULT";let d=e;switch(d){case"overflow":case"underflow":case"division-by-zero":o+="-"+d;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case or.CALL_EXCEPTION:case or.INSUFFICIENT_FUNDS:case or.MISSING_NEW:case or.NONCE_EXPIRED:case or.REPLACEMENT_UNDERPRICED:case or.TRANSACTION_REPLACED:case or.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(d){f[d]=i[d]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),Bp&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bp})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Sh||(Sh=new r(Fp)),Sh}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qp){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Up=!!e,qp=!!t}static setLogLevel(e){let t=Ka[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}zp=t}static from(e){return new r(e)}};at.errors=or;at.levels=Ih;var Kp="bytes/5.7.0";var nt=new at(Kp);function Vp(r){return!!r.toHexString}function is(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return is(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function $p(r){return ar(r)&&!(r.length%2)||Ah(r)}function jp(r){return typeof r=="number"&&r==r&&r%1===0}function Ah(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!jp(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function We(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),is(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r)&&(r=r.toHexString()),ar(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":nt.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nWe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),is(i)}function Cw(r,e){r=We(r),r.length>e&&nt.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),is(t)}function ar(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var Mh="0123456789abcdef";function _t(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Mh[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r))return r.toHexString();if(ar(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":nt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Ah(r)){let t="0x";for(let i=0;i>4]+Mh[n&15]}return t}return nt.throwArgumentError("invalid hexlify value","value",r)}function ja(r){if(typeof r!="string")r=_t(r);else if(!ar(r)||r.length%2)return null;return(r.length-2)/2}function Va(r,e,t){return typeof r!="string"?r=_t(r):(!ar(r)||r.length%2)&&nt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Ti(r,e){for(typeof r!="string"?r=_t(r):ar(r)||nt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&nt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function $a(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if($p(r)){let t=We(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64))):t.length===65?(e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64)),e.v=t[64]):nt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:nt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=_t(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=Cw(We(e._vs),32);e._vs=_t(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&nt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=_t(n);e.s==null?e.s=o:e.s!==o&&nt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?nt.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&nt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!ar(e.r)?nt.throwArgumentError("signature missing or invalid r","signature",r):e.r=Ti(e.r,32),e.s==null||!ar(e.s)?nt.throwArgumentError("signature missing or invalid s","signature",r):e.s=Ti(e.s,32);let t=We(e.s);t[0]>=128&&nt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=_t(t);e._vs&&(ar(e._vs)||nt.throwArgumentError("signature invalid _vs","signature",r),e._vs=Ti(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&nt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function ns(r){return"0x"+Hp.default.keccak_256(We(r))}var Jp=qe(Ph());var Wp="bignumber/5.7.0";var Ow=Jp.default.BN,sA=new at(Wp);function Nh(r){return new Ow(r,36).toString(16)}var Yp="strings/5.7.0";var Xp=new at(Yp),oo;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(oo||(oo={}));var yn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(yn||(yn={}));function Fw(r,e,t,i,n){return Xp.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function Zp(r,e,t,i,n){if(r===yn.BAD_PREFIX||r===yn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===yn.OVERRUN?t.length-e-1:0}function qw(r,e,t,i,n){return r===yn.OVERLONG?(i.push(n),0):(i.push(65533),Zp(r,e,t,i,n))}var Uw=Object.freeze({error:Fw,ignore:Zp,replace:qw});function ao(r,e=oo.current){e!=oo.current&&(Xp.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return We(t)}var Qp=`Ethereum Signed Message: -`;function Ha(r){return typeof r=="string"&&(r=ao(r)),ns(Rh([ao(Qp),ao(String(r.length)),r]))}var e1="address/5.7.0";var fo=new at(e1);function t1(r){ar(r,20)||fo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=We(ns(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var Bw=9007199254740991;function kw(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var Ch={};for(let r=0;r<10;r++)Ch[String(r)]=String(r);for(let r=0;r<26;r++)Ch[String.fromCharCode(65+r)]=String(10+r);var r1=Math.floor(kw(Bw));function Kw(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Ch[i]).join("");for(;e.length>=r1;){let i=e.substring(0,r1);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function i1(r){let e=null;if(typeof r!="string"&&fo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=t1(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&fo.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Kw(r)&&fo.throwArgumentError("bad icap checksum","address",r),e=Nh(r.substring(4));e.length<40;)e="0"+e;e=t1("0x"+e)}else fo.throwArgumentError("invalid address","address",r);return e}var n1="properties/5.7.0";var OA=new at(n1);function ss(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Ce=qe(Ph()),$r=qe(lo());function ds(r,e,t){return t={path:e,exports:{},require:function(i,n){return u8(i,n??t.path)}},r(t,t.exports),t.exports}function u8(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Hh=k1;function k1(r,e){if(!r)throw new Error(e||"Assertion failed")}k1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var ur=ds(function(r,e){"use strict";var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var d=[];if(typeof o!="string"){for(var h=0;h>8,S=b&255;y?d.push(y,S):d.push(S)}return d}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",d=0;d(S>>1)-1?T=(S>>1)-C:T=C,I.isubn(T)):T=0,y[M]=T,I.iushrn(1)}return y}t.getNAF=i;function n(d,h){var b=[[],[]];d=d.clone(),h=h.clone();for(var y=0,S=0,I;d.cmpn(-y)>0||h.cmpn(-S)>0;){var M=d.andln(3)+y&3,T=h.andln(3)+S&3;M===3&&(M=-1),T===3&&(T=-1);var C;M&1?(I=d.andln(7)+y&7,(I===3||I===5)&&T===2?C=-M:C=M):C=0,b[0].push(C);var P;T&1?(I=h.andln(7)+S&7,(I===3||I===5)&&M===2?P=-T:P=T):P=0,b[1].push(P),2*y===C+1&&(y=1-y),2*S===P+1&&(S=1-S),d.iushrn(1),h.iushrn(1)}return b}t.getJSF=n;function s(d,h,b){var y="_"+h;d.prototype[h]=function(){return this[y]!==void 0?this[y]:this[y]=b.call(this)}}t.cachedProperty=s;function o(d){return typeof d=="string"?t.toArray(d,"hex"):d}t.parseBytes=o;function f(d){return new Ce.default(d,"hex","le")}t.intFromLE=f}),Xa=zt.getNAF,d8=zt.getJSF,Za=zt.assert;function Ci(r,e){this.type=r,this.p=new Ce.default(e.p,16),this.red=e.prime?Ce.default.red(e.prime):Ce.default.mont(this.p),this.zero=new Ce.default(0).toRed(this.red),this.one=new Ce.default(1).toRed(this.red),this.two=new Ce.default(2).toRed(this.red),this.n=e.n&&new Ce.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var _n=Ci;Ci.prototype.point=function(){throw new Error("Not implemented")};Ci.prototype.validate=function(){throw new Error("Not implemented")};Ci.prototype._fixedNafMul=function(e,t){Za(e.precomputed);var i=e._getDoubles(),n=Xa(t,1,this._bitLength),s=(1<=f;h--)d=(d<<1)+n[h];o.push(d)}for(var b=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;d--){for(var h=0;d>=0&&o[d]===0;d--)h++;if(d>=0&&h++,f=f.dblp(h),d<0)break;var b=o[d];Za(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};Ci.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,d=this._wnafT3,h=0,b,y,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){d[M]=Xa(i[M],o[M],this._bitLength),d[T]=Xa(i[T],o[T],this._bitLength),h=Math.max(d[M].length,h),h=Math.max(d[T].length,h);continue}var C=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(C[1]=t[M].add(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].add(t[T].neg())):(C[1]=t[M].toJ().mixedAdd(t[T]),C[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],U=d8(i[M],i[T]);for(h=Math.max(U[0].length,h),d[M]=new Array(h),d[T]=new Array(h),y=0;y=0;b--){for(var L=0;b>=0;){var O=!0;for(y=0;y=0&&L++,j=j.dblp(L),b<0)break;for(y=0;y0?S=f[y][W-1>>1]:W<0&&(S=f[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Xt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=h,M=b),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:y,b:S},{a:I,b:M}]};Zt.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),d=o.mul(n.a),h=s.mul(i.b),b=o.mul(n.b),y=e.sub(f).sub(d),S=h.add(b).neg();return{k1:y,k2:S}};Zt.prototype.pointFromX=function(e,t){e=new Ce.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};Zt.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};Zt.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ft.prototype.isInfinity=function(){return this.inf};ft.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ft.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ft.prototype.getX=function(){return this.x.fromRed()};ft.prototype.getY=function(){return this.y.fromRed()};ft.prototype.mul=function(e){return e=new Ce.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ft.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ft.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ft.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ft.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ft.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function gt(r,e,t,i){_n.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ce.default(0)):(this.x=new Ce.default(e,16),this.y=new Ce.default(t,16),this.z=new Ce.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Gh(gt,_n.BasePoint);Zt.prototype.jpoint=function(e,t,i){return new gt(this,e,t,i)};gt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};gt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};gt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),d=n.redSub(s),h=o.redSub(f);if(d.cmpn(0)===0)return h.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=d.redSqr(),y=b.redMul(d),S=n.redMul(b),I=h.redSqr().redIAdd(y).redISub(S).redISub(S),M=h.redMul(S.redISub(I)).redISub(o.redMul(y)),T=this.z.redMul(e.z).redMul(d);return this.curve.jpoint(I,M,T)};gt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),d=s.redSub(o);if(f.cmpn(0)===0)return d.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var h=f.redSqr(),b=h.redMul(f),y=i.redMul(h),S=d.redSqr().redIAdd(b).redISub(y).redISub(y),I=d.redMul(y.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};gt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};gt.prototype.inspect=function(){return this.isInfinity()?"":""};gt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ja=ds(function(r,e){"use strict";var t=e;t.base=_n,t.short=p8,t.mont=null,t.edwards=null}),Ya=ds(function(r,e){"use strict";var t=e,i=zt.assert;function n(f){f.type==="short"?this.curve=new Ja.short(f):f.type==="edwards"?this.curve=new Ja.edwards(f):this.curve=new Ja.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,d){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var h=new n(d);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:h}),h}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:$r.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:$r.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:$r.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:$r.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:$r.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:$r.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Ni(r){if(!(this instanceof Ni))return new Ni(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ur.toArray(r.entropy,r.entropyEnc||"hex"),t=ur.toArray(r.nonce,r.nonceEnc||"hex"),i=ur.toArray(r.pers,r.persEnc||"hex");Hh(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var K1=Ni;Ni.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Ni.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ur.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var g8=zt.assert;function Qa(r,e){if(r instanceof Qa)return r;this._importDER(r,e)||(g8(r.r&&r.s,"Signature without r or s"),this.r=new Ce.default(r.r,16),this.s=new Ce.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ef=Qa;function b8(){this.place=0}function jh(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function B1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Qa.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=B1(t),i=B1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Vh(n,t.length),n=n.concat(t),n.push(2),Vh(n,i.length);var s=n.concat(i),o=[48];return Vh(o,s.length),o=o.concat(s),zt.encode(o,e)};var v8=function(){throw new Error("unsupported")},j1=zt.assert;function Yt(r){if(!(this instanceof Yt))return new Yt(r);typeof r=="string"&&(j1(Object.prototype.hasOwnProperty.call(Ya,r),"Unknown curve "+r),r=Ya[r]),r instanceof Ya.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var m8=Yt;Yt.prototype.keyPair=function(e){return new Wh(this,e)};Yt.prototype.keyFromPrivate=function(e,t){return Wh.fromPrivate(this,e,t)};Yt.prototype.keyFromPublic=function(e,t){return Wh.fromPublic(this,e,t)};Yt.prototype.genKeyPair=function(e){e||(e={});for(var t=new K1({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v8(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Ce.default(2));;){var s=new Ce.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Yt.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Yt.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Ce.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),d=new K1({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new Ce.default(1)),b=0;;b++){var y=n.k?n.k(b):new Ce.default(d.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(h)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=y.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var C=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),C^=1),new ef({r:M,s:T,recoveryParam:C})}}}}}};Yt.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Ce.default(e,16)),i=this.keyFromPublic(i,n),t=new ef(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),d=f.mul(e).umod(this.n),h=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(d,i.getPublic(),h),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};Yt.prototype.recoverPubKey=function(r,e,t,i){j1((3&t)===t,"The recovery param is more than two bits"),e=new ef(e,i);var n=this.n,s=new Ce.default(r),o=e.r,f=e.s,d=t&1,h=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");h?o=this.curve.pointFromX(o.add(this.curve.n),d):o=this.curve.pointFromX(o,d);var b=e.r.invm(n),y=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(y,o,S)};Yt.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ef(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var y8=ds(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=zt,t.rand=function(){throw new Error("unsupported")},t.curve=Ja,t.curves=Ya,t.ec=m8,t.eddsa=null}),V1=y8.ec;var $1="signing-key/5.7.0";var Yh=new at($1),Jh=null;function Hr(){return Jh||(Jh=new V1("secp256k1")),Jh}var Xh=class{constructor(e){ss(this,"curve","secp256k1"),ss(this,"privateKey",_t(e)),ja(this.privateKey)!==32&&Yh.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Hr().keyFromPrivate(We(this.privateKey));ss(this,"publicKey","0x"+t.getPublic(!1,"hex")),ss(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),ss(this,"_isSigningKey",!0)}_addPoint(e){let t=Hr().keyFromPublic(We(this.publicKey)),i=Hr().keyFromPublic(We(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=We(e);i.length!==32&&Yh.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return $a({recoveryParam:n.recoveryParam,r:Ti("0x"+n.r.toString(16),32),s:Ti("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=Hr().keyFromPublic(We(Zh(e)));return Ti("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function H1(r,e){let t=$a(e),i={r:We(t.r),s:We(t.s)};return"0x"+Hr().recoverPubKey(We(r),i,t.recoveryParam).encode("hex",!1)}function Zh(r,e){let t=We(r);if(t.length===32){let i=new Xh(t);return e?"0x"+Hr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?_t(t):"0x"+Hr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Hr().keyFromPublic(t).getPublic(!0,"hex"):_t(t)}return Yh.throwArgumentError("invalid public or private key","key","[REDACTED]")}var G1="transactions/5.7.0";var pR=new at(G1),W1;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(W1||(W1={}));function w8(r){let e=Zh(r);return i1(Va(ns(Va(e,1)),12))}function J1(r,e){return w8(H1(We(r),e))}var Eu=qe(ig()),xb=qe(cg()),Eo=qe(Js()),ws=qe(ug()),Sf=qe(gg());var Eb=qe(fb());var cb={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var E4=":";function So(r){let[e,t]=r.split(E4);return{namespace:e,reference:t}}function Sb(r,e){return r.includes(":")?[r]:e.chains||[]}var S4=Object.defineProperty,hb=Object.getOwnPropertySymbols,I4=Object.prototype.hasOwnProperty,M4=Object.prototype.propertyIsEnumerable,ub=(r,e,t)=>e in r?S4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,db=(r,e)=>{for(var t in e||(e={}))I4.call(e,t)&&ub(r,t,e[t]);if(hb)for(var t of hb(e))M4.call(e,t)&&ub(r,t,e[t]);return r},A4="ReactNative",Ft={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var R4="js";function Io(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Tn(){return!(0,yi.getDocument)()&&!!(0,yi.getNavigator)()&&navigator.product===A4}function _s(){return!Io()&&!!(0,yi.getNavigator)()&&!!(0,yi.getDocument)()}function Mo(){return Tn()?Ft.reactNative:Io()?Ft.node:_s()?Ft.browser:Ft.unknown}function Ib(){var r;try{return Tn()&&typeof window<"u"&&typeof window?.Application<"u"?(r=window.Application)==null?void 0:r.applicationId:void 0}catch{return}}function T4(r,e){let t=ys.parse(r);return t=db(db({},t),e),r=ys.stringify(t),r}function xs(){return(0,_b.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function D4(){if(Mo()===Ft.reactNative&&typeof window<"u"&&typeof window?.Platform<"u"){let{OS:t,Version:i}=window.Platform;return[t,i].join("-")}let r=lp();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function P4(){var r;let e=Mo();return e===Ft.browser?[e,((r=(0,yi.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function Su(r,e,t){let i=D4(),n=P4();return[[r,e].join("-"),[R4,t].join("-"),i,n].join("/")}function Mb({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){let d=t.split("?"),h=Su(r,e,i),b={auth:n,ua:h,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},y=T4(d[1]||"",b);return d[0]+"?"+y}function An(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Iu(r){return Object.fromEntries(r.entries())}function Mu(r){return new Map(Object.entries(r))}function wi(r=mi.FIVE_MINUTES,e){let t=(0,mi.toMiliseconds)(r||mi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Dn(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Ab(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Rb(r){return Ab("topic",r)}function Tb(r){return Ab("id",r)}function If(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function st(r,e){return(0,mi.fromMiliseconds)((e||Date.now())+(0,mi.toMiliseconds)(r))}function Xr(r){return Date.now()>=(0,mi.toMiliseconds)(r)}function Oe(r,e){return`${r}${e?`:${e}`:""}`}function N4(r=[],e=[]){return[...new Set([...r,...e])]}async function Db({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=C4(s,r,e),f=Mo();if(f===Ft.browser){if(!((i=(0,yi.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,O4()?"_blank":"_self","noreferrer noopener")}else f===Ft.reactNative&&typeof window?.Linking<"u"&&await window.Linking.openURL(o)}catch(n){console.error(n)}}function C4(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${L4(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Pb(r,e){let t="";try{if(_s()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Au(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ru(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Ao(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function O4(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function L4(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Nb(r){return Buffer.from(r,"base64").toString("utf-8")}var F4="https://rpc.walletconnect.org/v1";async function q4(r,e,t,i,n,s){switch(t.t){case"eip191":return U4(r,e,t.s);case"eip1271":return await z4(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function U4(r,e,t){return J1(Ha(e),t).toLowerCase()===r.toLowerCase()}async function z4(r,e,t,i,n,s){let o=So(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let f="0x1626ba7e",d="0000000000000000000000000000000000000000000000000000000000000040",h="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),y=Ha(e).substring(2),S=f+y+d+h+b,I=await fetch(`${s||F4}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:B4(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:M}=await I.json();return M?M.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function B4(){return Date.now()+Math.floor(Math.random()*1e3)}var k4=Object.defineProperty,K4=Object.defineProperties,j4=Object.getOwnPropertyDescriptors,lb=Object.getOwnPropertySymbols,V4=Object.prototype.hasOwnProperty,$4=Object.prototype.propertyIsEnumerable,pb=(r,e,t)=>e in r?k4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,H4=(r,e)=>{for(var t in e||(e={}))V4.call(e,t)&&pb(r,t,e[t]);if(lb)for(var t of lb(e))$4.call(e,t)&&pb(r,t,e[t]);return r},G4=(r,e)=>K4(r,j4(e)),W4="did:pkh:",Tu=r=>r?.split(":"),J4=r=>{let e=r&&Tu(r);if(e)return r.includes(W4)?e[3]:e[1]},Mf=r=>{let e=r&&Tu(r);if(e)return e[2]+":"+e[3]},Ro=r=>{let e=r&&Tu(r);if(e)return e.pop()};async function Du(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Pu(n,n.iss),o=Ro(n.iss);return await q4(o,s,i,Mf(n.iss),t)}var Pu=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ro(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${J4(e)}`,d=`Nonce: ${r.nonce}`,h=`Issued At: ${r.iat}`,b=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(T=>` -- ${T}`).join("")}`:void 0,M=To(r.resources);if(M){let T=xo(M);n=r_(n,T)}return[t,i,"",n,"",s,o,f,d,h,b,y,S,I].filter(T=>T!=null).join(` -`)};function Y4(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function X4(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Rn(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Z4(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Q4(e,t,i)}}}function Q4(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function Cb(r){return Rn(r),`urn:recap:${Y4(r).replace(/=/g,"")}`}function xo(r){let e=X4(r.replace("urn:recap:",""));return Rn(e),e}function Ob(r,e,t){let i=Z4(r,e,t);return Cb(i)}function e_(r){return r&&r.includes("urn:recap:")}function Lb(r,e){let t=xo(r),i=xo(e),n=t_(t,i);return Cb(n)}function t_(r,e){Rn(r),Rn(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,d)=>f.localeCompare(d)).forEach(f=>{var d,h;i.att[n]=G4(H4({},i.att[n]),{[f]:((d=r.att[n])==null?void 0:d[f])||((h=e.att[n])==null?void 0:h[f])})})}),i}function r_(r="",e){Rn(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(f=>{let d=Object.keys(e.att[f]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));d.sort((y,S)=>y.action.localeCompare(S.action));let h={};d.forEach(y=>{h[y.ability]||(h[y.ability]=[]),h[y.ability].push(y.action)});let b=Object.keys(h).map(y=>(n++,`(${n}) '${y}': '${h[y].join("', '")}' for '${f}'.`));i.push(b.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Nu(r){var e;let t=xo(r);Rn(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Cu(r){let e=xo(r);Rn(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function To(r){if(!r)return;let e=r?.[r.length-1];return e_(e)?e:void 0}var Fb="base10",It="base16",Zr="base64pad",Es="base64url",Do="utf8",qb=0,lr=1,Ss=2,i_=0,gb=1,_o=12,Ou=32;function Ub(){let r=Sf.generateKeyPair();return{privateKey:Ze(r.secretKey,It),publicKey:Ze(r.publicKey,It)}}function Af(){let r=(0,Eo.randomBytes)(Ou);return Ze(r,It)}function zb(r,e){let t=Sf.sharedKey(rt(r,It),rt(e,It),!0),i=new xb.HKDF(ws.SHA256,t).expand(Ou);return Ze(i,It)}function Is(r){let e=(0,ws.hash)(rt(r,It));return Ze(e,It)}function pr(r){let e=(0,ws.hash)(rt(r,Do));return Ze(e,It)}function Bb(r){return rt(`${r}`,Fb)}function Bi(r){return Number(Ze(r,Fb))}function kb(r){let e=Bb(typeof r.type<"u"?r.type:qb);if(Bi(e)===lr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?rt(r.senderPublicKey,It):void 0,i=typeof r.iv<"u"?rt(r.iv,It):(0,Eo.randomBytes)(_o),n=new Eu.ChaCha20Poly1305(rt(r.symKey,It)).seal(i,rt(r.message,Do));return $b({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Kb(r,e){let t=Bb(Ss),i=(0,Eo.randomBytes)(_o),n=rt(r,Do);return $b({type:t,sealed:n,iv:i,encoding:e})}function jb(r){let e=new Eu.ChaCha20Poly1305(rt(r.symKey,It)),{sealed:t,iv:i}=Ms({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Ze(n,Do)}function Vb(r,e){let{sealed:t}=Ms({encoded:r,encoding:e});return Ze(t,Do)}function $b(r){let{encoding:e=Zr}=r;if(Bi(r.type)===Ss)return Ze(bn([r.type,r.sealed]),e);if(Bi(r.type)===lr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Ze(bn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Ze(bn([r.type,r.iv,r.sealed]),e)}function Ms(r){let{encoded:e,encoding:t=Zr}=r,i=rt(e,t),n=i.slice(i_,gb),s=gb;if(Bi(n)===lr){let h=s+Ou,b=h+_o,y=i.slice(s,h),S=i.slice(h,b),I=i.slice(b);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(Bi(n)===Ss){let h=i.slice(s),b=(0,Eo.randomBytes)(_o);return{type:n,sealed:h,iv:b}}let o=s+_o,f=i.slice(s,o),d=i.slice(o);return{type:n,sealed:d,iv:f}}function Hb(r,e){let t=Ms({encoded:r,encoding:e?.encoding});return Lu({type:Bi(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Ze(t.senderPublicKey,It):void 0,receiverPublicKey:e?.receiverPublicKey})}function Lu(r){let e=r?.type||qb;if(e===lr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Fu(r){return r.type===lr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function qu(r){return r.type===Ss}function n_(r){return new Eb.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function s_(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function o_(r){return Buffer.from(s_(r),"base64")}function Gb(r,e){let[t,i,n]=r.split("."),s=o_(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),d=`${t}.${i}`,h=new ws.SHA256().update(Buffer.from(d)).digest(),b=n_(e),y=Buffer.from(h).toString("hex");if(!b.verify(y,{r:o,s:f}))throw new Error("Invalid signature");return ts(r).payload}var a_="irn";function Rf(r){return r?.relay||{protocol:a_}}function As(r){let e=cb[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var f_=Object.defineProperty,c_=Object.defineProperties,h_=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertySymbols,u_=Object.prototype.hasOwnProperty,d_=Object.prototype.propertyIsEnumerable,vb=(r,e,t)=>e in r?f_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mb=(r,e)=>{for(var t in e||(e={}))u_.call(e,t)&&vb(r,t,e[t]);if(bb)for(var t of bb(e))d_.call(e,t)&&vb(r,t,e[t]);return r},l_=(r,e)=>c_(r,h_(e));function p_(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Uu(r){if(!r.includes("wc:")){let d=Nb(r);d!=null&&d.includes("wc:")&&(r=d)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=ys.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:g_(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:p_(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function g_(r){return r.startsWith("//")?r.substring(2):r}function b_(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function zu(r){return`${r.protocol}:${r.topic}@${r.version}?`+ys.stringify(mb(l_(mb({symKey:r.symKey},b_(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Po(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Rs(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function v_(r){let e=[];return Object.values(r).forEach(t=>{e.push(...Rs(t.accounts))}),e}function m_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.methods)}),t}function y_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.events)}),t}function w_(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Bu(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=w_(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=N4(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var __={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},x_={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function X(r,e){let{message:t,code:i}=x_[r];return{message:e?`${t} ${e}`:t,code:i}}function Ue(r,e){let{message:t,code:i}=__[r];return{message:e?`${t} ${e}`:t,code:i}}function Ki(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function No(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function vt(r){return typeof r>"u"}function Ye(r,e){return e&&vt(r)?!0:typeof r=="string"&&!!r.trim().length}function ku(r,e){return e&&vt(r)?!0:typeof r=="number"&&!isNaN(r)}function Wb(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return An(n,i)?(i.forEach(o=>{let{accounts:f,methods:d,events:h}=r.namespaces[o],b=Rs(f),y=t[o];(!An(Sb(o,y),b)||!An(y.methods,d)||!An(y.events,h))&&(s=!1)}),s):!1}function Ef(r){return Ye(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function E_(r){if(Ye(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&Ef(t)}}return!1}function Jb(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Ye(r,!1)){if(e(r))return!0;let t=Nb(r);return e(t)}}catch{}return!1}function Yb(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function Xb(r){return r?.topic}function Zb(r,e){let t=null;return Ye(r?.publicKey,!1)||(t=X("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function yb(r){let e=!0;return Ki(r)?r.length&&(e=r.every(t=>Ye(t,!1))):e=!1,e}function S_(r,e,t){let i=null;return Ki(e)&&e.length?e.forEach(n=>{i||Ef(n)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Ef(r)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function I_(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=S_(n,Sb(n,s),`${e} ${t}`);o&&(i=o)}),i}function M_(r,e){let t=null;return Ki(r)?r.forEach(i=>{t||E_(i)||(t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function A_(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=M_(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function R_(r,e){let t=null;return yb(r?.methods)?yb(r?.events)||(t=Ue("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Ue("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Qb(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=R_(i,`${e}, namespace`);n&&(t=n)}),t}function ev(r,e,t){let i=null;if(r&&No(r)){let n=Qb(r,e);n&&(i=n);let s=I_(r,e,t);s&&(i=s)}else i=X("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Tf(r,e){let t=null;if(r&&No(r)){let i=Qb(r,e);i&&(t=i);let n=A_(r,e);n&&(t=n)}else t=X("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ku(r){return Ye(r.protocol,!0)}function tv(r,e){let t=!1;return e&&!r?t=!0:r&&Ki(r)&&r.length&&r.forEach(i=>{t=Ku(i)}),t}function rv(r){return typeof r=="number"}function Mt(r){return typeof r<"u"&&typeof r!==null}function iv(r){return!(!r||typeof r!="object"||!r.code||!ku(r.code,!1)||!r.message||!Ye(r.message,!1))}function nv(r){return!(vt(r)||!Ye(r.method,!1))}function sv(r){return!(vt(r)||vt(r.result)&&vt(r.error)||!ku(r.id,!1)||!Ye(r.jsonrpc,!1))}function ov(r){return!(vt(r)||!Ye(r.name,!1))}function ju(r,e){return!(!Ef(e)||!v_(r).includes(e))}function av(r,e,t){return Ye(t,!1)?m_(r,e).includes(t):!1}function fv(r,e,t){return Ye(t,!1)?y_(r,e).includes(t):!1}function Vu(r,e,t){let i=null,n=T_(r),s=D_(e),o=Object.keys(n),f=Object.keys(s),d=wb(Object.keys(r)),h=wb(Object.keys(e)),b=d.filter(y=>!h.includes(y));return b.length&&(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. +`;var yh={...nh,...sh,...oh,...ah,...fh,...ch,...hh,...uh,...dh,...lh},dM={...vh,...mh};function rp(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var tp=rp("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),wh=rp("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=eo(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new nw:typeof navigator<"u"?dp(navigator.userAgent):hw()}function fw(r){return r!==""&&aw.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function dp(r){var e=fw(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new iw;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var Bp=Nw(),Ih;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(Ih||(Ih={}));var or;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(or||(or={}));var kp="0123456789abcdef",at=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();Ka[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(zp>Ka[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(Up)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(u=>{let c=i[u];try{if(c instanceof Uint8Array){let b="";for(let v=0;v>4],b+=kp[c[v]&15];n.push(u+"=Uint8Array(0x"+b+")")}else n.push(u+"="+JSON.stringify(c))}catch{n.push(u+"="+JSON.stringify(i[u].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case or.NUMERIC_FAULT:{o="NUMERIC_FAULT";let u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":o+="-"+u;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case or.CALL_EXCEPTION:case or.INSUFFICIENT_FUNDS:case or.MISSING_NEW:case or.NONCE_EXPIRED:case or.REPLACEMENT_UNDERPRICED:case or.TRANSACTION_REPLACED:case or.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(u){f[u]=i[u]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),Bp&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bp})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Sh||(Sh=new r(Fp)),Sh}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qp){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Up=!!e,qp=!!t}static setLogLevel(e){let t=Ka[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}zp=t}static from(e){return new r(e)}};at.errors=or;at.levels=Ih;var Kp="bytes/5.7.0";var nt=new at(Kp);function Vp(r){return!!r.toHexString}function is(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return is(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function $p(r){return ar(r)&&!(r.length%2)||Ah(r)}function jp(r){return typeof r=="number"&&r==r&&r%1===0}function Ah(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!jp(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function We(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),is(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r)&&(r=r.toHexString()),ar(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":nt.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nWe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),is(i)}function Cw(r,e){r=We(r),r.length>e&&nt.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),is(t)}function ar(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var Mh="0123456789abcdef";function _t(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Mh[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r))return r.toHexString();if(ar(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":nt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Ah(r)){let t="0x";for(let i=0;i>4]+Mh[n&15]}return t}return nt.throwArgumentError("invalid hexlify value","value",r)}function ja(r){if(typeof r!="string")r=_t(r);else if(!ar(r)||r.length%2)return null;return(r.length-2)/2}function Va(r,e,t){return typeof r!="string"?r=_t(r):(!ar(r)||r.length%2)&&nt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Di(r,e){for(typeof r!="string"?r=_t(r):ar(r)||nt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&nt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function $a(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if($p(r)){let t=We(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64))):t.length===65?(e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64)),e.v=t[64]):nt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:nt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=_t(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=Cw(We(e._vs),32);e._vs=_t(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&nt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=_t(n);e.s==null?e.s=o:e.s!==o&&nt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?nt.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&nt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!ar(e.r)?nt.throwArgumentError("signature missing or invalid r","signature",r):e.r=Di(e.r,32),e.s==null||!ar(e.s)?nt.throwArgumentError("signature missing or invalid s","signature",r):e.s=Di(e.s,32);let t=We(e.s);t[0]>=128&&nt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=_t(t);e._vs&&(ar(e._vs)||nt.throwArgumentError("signature invalid _vs","signature",r),e._vs=Di(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&nt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function ns(r){return"0x"+Hp.default.keccak_256(We(r))}var Jp=qe(Ph());var Wp="bignumber/5.7.0";var Ow=Jp.default.BN,sA=new at(Wp);function Nh(r){return new Ow(r,36).toString(16)}var Yp="strings/5.7.0";var Xp=new at(Yp),oo;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(oo||(oo={}));var wn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(wn||(wn={}));function Fw(r,e,t,i,n){return Xp.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function Zp(r,e,t,i,n){if(r===wn.BAD_PREFIX||r===wn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===wn.OVERRUN?t.length-e-1:0}function qw(r,e,t,i,n){return r===wn.OVERLONG?(i.push(n),0):(i.push(65533),Zp(r,e,t,i,n))}var Uw=Object.freeze({error:Fw,ignore:Zp,replace:qw});function ao(r,e=oo.current){e!=oo.current&&(Xp.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return We(t)}var Qp=`Ethereum Signed Message: +`;function Ha(r){return typeof r=="string"&&(r=ao(r)),ns(Rh([ao(Qp),ao(String(r.length)),r]))}var e1="address/5.7.0";var fo=new at(e1);function t1(r){ar(r,20)||fo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=We(ns(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var Bw=9007199254740991;function kw(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var Ch={};for(let r=0;r<10;r++)Ch[String(r)]=String(r);for(let r=0;r<26;r++)Ch[String.fromCharCode(65+r)]=String(10+r);var r1=Math.floor(kw(Bw));function Kw(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Ch[i]).join("");for(;e.length>=r1;){let i=e.substring(0,r1);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function i1(r){let e=null;if(typeof r!="string"&&fo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=t1(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&fo.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Kw(r)&&fo.throwArgumentError("bad icap checksum","address",r),e=Nh(r.substring(4));e.length<40;)e="0"+e;e=t1("0x"+e)}else fo.throwArgumentError("invalid address","address",r);return e}var n1="properties/5.7.0";var OA=new at(n1);function ss(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Ce=qe(Ph()),$r=qe(lo());function ds(r,e,t){return t={path:e,exports:{},require:function(i,n){return u8(i,n??t.path)}},r(t,t.exports),t.exports}function u8(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Hh=k1;function k1(r,e){if(!r)throw new Error(e||"Assertion failed")}k1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var ur=ds(function(r,e){"use strict";var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var u=[];if(typeof o!="string"){for(var c=0;c>8,S=b&255;v?u.push(v,S):u.push(S)}return u}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",u=0;u(S>>1)-1?T=(S>>1)-O:T=O,I.isubn(T)):T=0,v[M]=T,I.iushrn(1)}return v}t.getNAF=i;function n(u,c){var b=[[],[]];u=u.clone(),c=c.clone();for(var v=0,S=0,I;u.cmpn(-v)>0||c.cmpn(-S)>0;){var M=u.andln(3)+v&3,T=c.andln(3)+S&3;M===3&&(M=-1),T===3&&(T=-1);var O;M&1?(I=u.andln(7)+v&7,(I===3||I===5)&&T===2?O=-M:O=M):O=0,b[0].push(O);var P;T&1?(I=c.andln(7)+S&7,(I===3||I===5)&&M===2?P=-T:P=T):P=0,b[1].push(P),2*v===O+1&&(v=1-v),2*S===P+1&&(S=1-S),u.iushrn(1),c.iushrn(1)}return b}t.getJSF=n;function s(u,c,b){var v="_"+c;u.prototype[c]=function(){return this[v]!==void 0?this[v]:this[v]=b.call(this)}}t.cachedProperty=s;function o(u){return typeof u=="string"?t.toArray(u,"hex"):u}t.parseBytes=o;function f(u){return new Ce.default(u,"hex","le")}t.intFromLE=f}),Xa=zt.getNAF,d8=zt.getJSF,Za=zt.assert;function Oi(r,e){this.type=r,this.p=new Ce.default(e.p,16),this.red=e.prime?Ce.default.red(e.prime):Ce.default.mont(this.p),this.zero=new Ce.default(0).toRed(this.red),this.one=new Ce.default(1).toRed(this.red),this.two=new Ce.default(2).toRed(this.red),this.n=e.n&&new Ce.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xn=Oi;Oi.prototype.point=function(){throw new Error("Not implemented")};Oi.prototype.validate=function(){throw new Error("Not implemented")};Oi.prototype._fixedNafMul=function(e,t){Za(e.precomputed);var i=e._getDoubles(),n=Xa(t,1,this._bitLength),s=(1<=f;c--)u=(u<<1)+n[c];o.push(u)}for(var b=this.jpoint(null,null,null),v=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;u--){for(var c=0;u>=0&&o[u]===0;u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var b=o[u];Za(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};Oi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,c=0,b,v,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){u[M]=Xa(i[M],o[M],this._bitLength),u[T]=Xa(i[T],o[T],this._bitLength),c=Math.max(u[M].length,c),c=Math.max(u[T].length,c);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],z=d8(i[M],i[T]);for(c=Math.max(z[0].length,c),u[M]=new Array(c),u[T]=new Array(c),v=0;v=0;b--){for(var L=0;b>=0;){var C=!0;for(v=0;v=0&&L++,j=j.dblp(L),b<0)break;for(v=0;v0?S=f[v][W-1>>1]:W<0&&(S=f[v][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Xt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=c,M=b),v.negative&&(v=v.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:v,b:S},{a:I,b:M}]};Zt.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),c=s.mul(i.b),b=o.mul(n.b),v=e.sub(f).sub(u),S=c.add(b).neg();return{k1:v,k2:S}};Zt.prototype.pointFromX=function(e,t){e=new Ce.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};Zt.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};Zt.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ft.prototype.isInfinity=function(){return this.inf};ft.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ft.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ft.prototype.getX=function(){return this.x.fromRed()};ft.prototype.getY=function(){return this.y.fromRed()};ft.prototype.mul=function(e){return e=new Ce.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ft.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ft.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ft.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ft.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ft.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function gt(r,e,t,i){xn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ce.default(0)):(this.x=new Ce.default(e,16),this.y=new Ce.default(t,16),this.z=new Ce.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Gh(gt,xn.BasePoint);Zt.prototype.jpoint=function(e,t,i){return new gt(this,e,t,i)};gt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};gt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};gt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),c=o.redSub(f);if(u.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=u.redSqr(),v=b.redMul(u),S=n.redMul(b),I=c.redSqr().redIAdd(v).redISub(S).redISub(S),M=c.redMul(S.redISub(I)).redISub(o.redMul(v)),T=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(I,M,T)};gt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),b=c.redMul(f),v=i.redMul(c),S=u.redSqr().redIAdd(b).redISub(v).redISub(v),I=u.redMul(v.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};gt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};gt.prototype.inspect=function(){return this.isInfinity()?"":""};gt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ja=ds(function(r,e){"use strict";var t=e;t.base=xn,t.short=p8,t.mont=null,t.edwards=null}),Ya=ds(function(r,e){"use strict";var t=e,i=zt.assert;function n(f){f.type==="short"?this.curve=new Ja.short(f):f.type==="edwards"?this.curve=new Ja.edwards(f):this.curve=new Ja.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,u){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var c=new n(u);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:c}),c}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:$r.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:$r.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:$r.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:$r.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:$r.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:$r.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Ci(r){if(!(this instanceof Ci))return new Ci(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ur.toArray(r.entropy,r.entropyEnc||"hex"),t=ur.toArray(r.nonce,r.nonceEnc||"hex"),i=ur.toArray(r.pers,r.persEnc||"hex");Hh(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var K1=Ci;Ci.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Ci.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ur.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var g8=zt.assert;function Qa(r,e){if(r instanceof Qa)return r;this._importDER(r,e)||(g8(r.r&&r.s,"Signature without r or s"),this.r=new Ce.default(r.r,16),this.s=new Ce.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ef=Qa;function b8(){this.place=0}function jh(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function B1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Qa.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=B1(t),i=B1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Vh(n,t.length),n=n.concat(t),n.push(2),Vh(n,i.length);var s=n.concat(i),o=[48];return Vh(o,s.length),o=o.concat(s),zt.encode(o,e)};var v8=function(){throw new Error("unsupported")},j1=zt.assert;function Yt(r){if(!(this instanceof Yt))return new Yt(r);typeof r=="string"&&(j1(Object.prototype.hasOwnProperty.call(Ya,r),"Unknown curve "+r),r=Ya[r]),r instanceof Ya.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var m8=Yt;Yt.prototype.keyPair=function(e){return new Wh(this,e)};Yt.prototype.keyFromPrivate=function(e,t){return Wh.fromPrivate(this,e,t)};Yt.prototype.keyFromPublic=function(e,t){return Wh.fromPublic(this,e,t)};Yt.prototype.genKeyPair=function(e){e||(e={});for(var t=new K1({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v8(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Ce.default(2));;){var s=new Ce.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Yt.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Yt.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Ce.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new K1({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new Ce.default(1)),b=0;;b++){var v=n.k?n.k(b):new Ce.default(u.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(c)>=0)){var S=this.g.mul(v);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=v.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new ef({r:M,s:T,recoveryParam:O})}}}}}};Yt.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Ce.default(e,16)),i=this.keyFromPublic(i,n),t=new ef(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),u=f.mul(e).umod(this.n),c=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(u,i.getPublic(),c),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(u,i.getPublic(),c),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};Yt.prototype.recoverPubKey=function(r,e,t,i){j1((3&t)===t,"The recovery param is more than two bits"),e=new ef(e,i);var n=this.n,s=new Ce.default(r),o=e.r,f=e.s,u=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var b=e.r.invm(n),v=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(v,o,S)};Yt.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ef(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var y8=ds(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=zt,t.rand=function(){throw new Error("unsupported")},t.curve=Ja,t.curves=Ya,t.ec=m8,t.eddsa=null}),V1=y8.ec;var $1="signing-key/5.7.0";var Yh=new at($1),Jh=null;function Hr(){return Jh||(Jh=new V1("secp256k1")),Jh}var Xh=class{constructor(e){ss(this,"curve","secp256k1"),ss(this,"privateKey",_t(e)),ja(this.privateKey)!==32&&Yh.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Hr().keyFromPrivate(We(this.privateKey));ss(this,"publicKey","0x"+t.getPublic(!1,"hex")),ss(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),ss(this,"_isSigningKey",!0)}_addPoint(e){let t=Hr().keyFromPublic(We(this.publicKey)),i=Hr().keyFromPublic(We(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=We(e);i.length!==32&&Yh.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return $a({recoveryParam:n.recoveryParam,r:Di("0x"+n.r.toString(16),32),s:Di("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=Hr().keyFromPublic(We(Zh(e)));return Di("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function H1(r,e){let t=$a(e),i={r:We(t.r),s:We(t.s)};return"0x"+Hr().recoverPubKey(We(r),i,t.recoveryParam).encode("hex",!1)}function Zh(r,e){let t=We(r);if(t.length===32){let i=new Xh(t);return e?"0x"+Hr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?_t(t):"0x"+Hr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Hr().keyFromPublic(t).getPublic(!0,"hex"):_t(t)}return Yh.throwArgumentError("invalid public or private key","key","[REDACTED]")}var G1="transactions/5.7.0";var pR=new at(G1),W1;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(W1||(W1={}));function w8(r){let e=Zh(r);return i1(Va(ns(Va(e,1)),12))}function J1(r,e){return w8(H1(We(r),e))}var Eu=qe(ig()),xb=qe(cg()),Eo=qe(Js()),ws=qe(ug()),Sf=qe(gg());var Eb=qe(fb());var cb={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var E4=":";function So(r){let[e,t]=r.split(E4);return{namespace:e,reference:t}}function Sb(r,e){return r.includes(":")?[r]:e.chains||[]}var S4=Object.defineProperty,hb=Object.getOwnPropertySymbols,I4=Object.prototype.hasOwnProperty,M4=Object.prototype.propertyIsEnumerable,ub=(r,e,t)=>e in r?S4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,db=(r,e)=>{for(var t in e||(e={}))I4.call(e,t)&&ub(r,t,e[t]);if(hb)for(var t of hb(e))M4.call(e,t)&&ub(r,t,e[t]);return r},A4="ReactNative",Ft={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var R4="js";function Io(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Tn(){return!(0,wi.getDocument)()&&!!(0,wi.getNavigator)()&&navigator.product===A4}function _s(){return!Io()&&!!(0,wi.getNavigator)()&&!!(0,wi.getDocument)()}function Mo(){return Tn()?Ft.reactNative:Io()?Ft.node:_s()?Ft.browser:Ft.unknown}function Ib(){var r;try{return Tn()&&typeof window<"u"&&typeof window?.Application<"u"?(r=window.Application)==null?void 0:r.applicationId:void 0}catch{return}}function T4(r,e){let t=ys.parse(r);return t=db(db({},t),e),r=ys.stringify(t),r}function xs(){return(0,_b.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function D4(){if(Mo()===Ft.reactNative&&typeof window<"u"&&typeof window?.Platform<"u"){let{OS:t,Version:i}=window.Platform;return[t,i].join("-")}let r=lp();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function P4(){var r;let e=Mo();return e===Ft.browser?[e,((r=(0,wi.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function Su(r,e,t){let i=D4(),n=P4();return[[r,e].join("-"),[R4,t].join("-"),i,n].join("/")}function Mb({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){let u=t.split("?"),c=Su(r,e,i),b={auth:n,ua:c,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},v=T4(u[1]||"",b);return u[0]+"?"+v}function An(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Iu(r){return Object.fromEntries(r.entries())}function Mu(r){return new Map(Object.entries(r))}function _i(r=yi.FIVE_MINUTES,e){let t=(0,yi.toMiliseconds)(r||yi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Dn(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Ab(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Rb(r){return Ab("topic",r)}function Tb(r){return Ab("id",r)}function If(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function st(r,e){return(0,yi.fromMiliseconds)((e||Date.now())+(0,yi.toMiliseconds)(r))}function Xr(r){return Date.now()>=(0,yi.toMiliseconds)(r)}function Oe(r,e){return`${r}${e?`:${e}`:""}`}function N4(r=[],e=[]){return[...new Set([...r,...e])]}async function Db({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=C4(s,r,e),f=Mo();if(f===Ft.browser){if(!((i=(0,wi.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,O4()?"_blank":"_self","noreferrer noopener")}else f===Ft.reactNative&&typeof window?.Linking<"u"&&await window.Linking.openURL(o)}catch(n){console.error(n)}}function C4(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${L4(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Pb(r,e){let t="";try{if(_s()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Au(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ru(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Ao(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function O4(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function L4(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Nb(r){return Buffer.from(r,"base64").toString("utf-8")}var F4="https://rpc.walletconnect.org/v1";async function q4(r,e,t,i,n,s){switch(t.t){case"eip191":return U4(r,e,t.s);case"eip1271":return await z4(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function U4(r,e,t){return J1(Ha(e),t).toLowerCase()===r.toLowerCase()}async function z4(r,e,t,i,n,s){let o=So(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),v=Ha(e).substring(2),S=f+v+u+c+b,I=await fetch(`${s||F4}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:B4(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:M}=await I.json();return M?M.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function B4(){return Date.now()+Math.floor(Math.random()*1e3)}var k4=Object.defineProperty,K4=Object.defineProperties,j4=Object.getOwnPropertyDescriptors,lb=Object.getOwnPropertySymbols,V4=Object.prototype.hasOwnProperty,$4=Object.prototype.propertyIsEnumerable,pb=(r,e,t)=>e in r?k4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,H4=(r,e)=>{for(var t in e||(e={}))V4.call(e,t)&&pb(r,t,e[t]);if(lb)for(var t of lb(e))$4.call(e,t)&&pb(r,t,e[t]);return r},G4=(r,e)=>K4(r,j4(e)),W4="did:pkh:",Tu=r=>r?.split(":"),J4=r=>{let e=r&&Tu(r);if(e)return r.includes(W4)?e[3]:e[1]},Mf=r=>{let e=r&&Tu(r);if(e)return e[2]+":"+e[3]},Ro=r=>{let e=r&&Tu(r);if(e)return e.pop()};async function Du(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Pu(n,n.iss),o=Ro(n.iss);return await q4(o,s,i,Mf(n.iss),t)}var Pu=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ro(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${J4(e)}`,u=`Nonce: ${r.nonce}`,c=`Issued At: ${r.iat}`,b=r.exp?`Expiration Time: ${r.exp}`:void 0,v=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(T=>` +- ${T}`).join("")}`:void 0,M=To(r.resources);if(M){let T=xo(M);n=r_(n,T)}return[t,i,"",n,"",s,o,f,u,c,b,v,S,I].filter(T=>T!=null).join(` +`)};function Y4(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function X4(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Rn(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Z4(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Q4(e,t,i)}}}function Q4(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function Cb(r){return Rn(r),`urn:recap:${Y4(r).replace(/=/g,"")}`}function xo(r){let e=X4(r.replace("urn:recap:",""));return Rn(e),e}function Ob(r,e,t){let i=Z4(r,e,t);return Cb(i)}function e_(r){return r&&r.includes("urn:recap:")}function Lb(r,e){let t=xo(r),i=xo(e),n=t_(t,i);return Cb(n)}function t_(r,e){Rn(r),Rn(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,u)=>f.localeCompare(u)).forEach(f=>{var u,c;i.att[n]=G4(H4({},i.att[n]),{[f]:((u=r.att[n])==null?void 0:u[f])||((c=e.att[n])==null?void 0:c[f])})})}),i}function r_(r="",e){Rn(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(f=>{let u=Object.keys(e.att[f]).map(v=>({ability:v.split("/")[0],action:v.split("/")[1]}));u.sort((v,S)=>v.action.localeCompare(S.action));let c={};u.forEach(v=>{c[v.ability]||(c[v.ability]=[]),c[v.ability].push(v.action)});let b=Object.keys(c).map(v=>(n++,`(${n}) '${v}': '${c[v].join("', '")}' for '${f}'.`));i.push(b.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Nu(r){var e;let t=xo(r);Rn(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Cu(r){let e=xo(r);Rn(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function To(r){if(!r)return;let e=r?.[r.length-1];return e_(e)?e:void 0}var Fb="base10",It="base16",Zr="base64pad",Es="base64url",Do="utf8",qb=0,lr=1,Ss=2,i_=0,gb=1,_o=12,Ou=32;function Ub(){let r=Sf.generateKeyPair();return{privateKey:Ze(r.secretKey,It),publicKey:Ze(r.publicKey,It)}}function Af(){let r=(0,Eo.randomBytes)(Ou);return Ze(r,It)}function zb(r,e){let t=Sf.sharedKey(rt(r,It),rt(e,It),!0),i=new xb.HKDF(ws.SHA256,t).expand(Ou);return Ze(i,It)}function Is(r){let e=(0,ws.hash)(rt(r,It));return Ze(e,It)}function pr(r){let e=(0,ws.hash)(rt(r,Do));return Ze(e,It)}function Bb(r){return rt(`${r}`,Fb)}function ki(r){return Number(Ze(r,Fb))}function kb(r){let e=Bb(typeof r.type<"u"?r.type:qb);if(ki(e)===lr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?rt(r.senderPublicKey,It):void 0,i=typeof r.iv<"u"?rt(r.iv,It):(0,Eo.randomBytes)(_o),n=new Eu.ChaCha20Poly1305(rt(r.symKey,It)).seal(i,rt(r.message,Do));return $b({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Kb(r,e){let t=Bb(Ss),i=(0,Eo.randomBytes)(_o),n=rt(r,Do);return $b({type:t,sealed:n,iv:i,encoding:e})}function jb(r){let e=new Eu.ChaCha20Poly1305(rt(r.symKey,It)),{sealed:t,iv:i}=Ms({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Ze(n,Do)}function Vb(r,e){let{sealed:t}=Ms({encoded:r,encoding:e});return Ze(t,Do)}function $b(r){let{encoding:e=Zr}=r;if(ki(r.type)===Ss)return Ze(vn([r.type,r.sealed]),e);if(ki(r.type)===lr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Ze(vn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Ze(vn([r.type,r.iv,r.sealed]),e)}function Ms(r){let{encoded:e,encoding:t=Zr}=r,i=rt(e,t),n=i.slice(i_,gb),s=gb;if(ki(n)===lr){let c=s+Ou,b=c+_o,v=i.slice(s,c),S=i.slice(c,b),I=i.slice(b);return{type:n,sealed:I,iv:S,senderPublicKey:v}}if(ki(n)===Ss){let c=i.slice(s),b=(0,Eo.randomBytes)(_o);return{type:n,sealed:c,iv:b}}let o=s+_o,f=i.slice(s,o),u=i.slice(o);return{type:n,sealed:u,iv:f}}function Hb(r,e){let t=Ms({encoded:r,encoding:e?.encoding});return Lu({type:ki(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Ze(t.senderPublicKey,It):void 0,receiverPublicKey:e?.receiverPublicKey})}function Lu(r){let e=r?.type||qb;if(e===lr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Fu(r){return r.type===lr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function qu(r){return r.type===Ss}function n_(r){return new Eb.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function s_(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function o_(r){return Buffer.from(s_(r),"base64")}function Gb(r,e){let[t,i,n]=r.split("."),s=o_(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),u=`${t}.${i}`,c=new ws.SHA256().update(Buffer.from(u)).digest(),b=n_(e),v=Buffer.from(c).toString("hex");if(!b.verify(v,{r:o,s:f}))throw new Error("Invalid signature");return ts(r).payload}var a_="irn";function Rf(r){return r?.relay||{protocol:a_}}function As(r){let e=cb[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var f_=Object.defineProperty,c_=Object.defineProperties,h_=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertySymbols,u_=Object.prototype.hasOwnProperty,d_=Object.prototype.propertyIsEnumerable,vb=(r,e,t)=>e in r?f_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mb=(r,e)=>{for(var t in e||(e={}))u_.call(e,t)&&vb(r,t,e[t]);if(bb)for(var t of bb(e))d_.call(e,t)&&vb(r,t,e[t]);return r},l_=(r,e)=>c_(r,h_(e));function p_(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Uu(r){if(!r.includes("wc:")){let u=Nb(r);u!=null&&u.includes("wc:")&&(r=u)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=ys.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:g_(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:p_(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function g_(r){return r.startsWith("//")?r.substring(2):r}function b_(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function zu(r){return`${r.protocol}:${r.topic}@${r.version}?`+ys.stringify(mb(l_(mb({symKey:r.symKey},b_(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Po(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Rs(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function v_(r){let e=[];return Object.values(r).forEach(t=>{e.push(...Rs(t.accounts))}),e}function m_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.methods)}),t}function y_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.events)}),t}function w_(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Bu(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=w_(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=N4(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var __={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},x_={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function X(r,e){let{message:t,code:i}=x_[r];return{message:e?`${t} ${e}`:t,code:i}}function Ue(r,e){let{message:t,code:i}=__[r];return{message:e?`${t} ${e}`:t,code:i}}function ji(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function No(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function vt(r){return typeof r>"u"}function Ye(r,e){return e&&vt(r)?!0:typeof r=="string"&&!!r.trim().length}function ku(r,e){return e&&vt(r)?!0:typeof r=="number"&&!isNaN(r)}function Wb(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return An(n,i)?(i.forEach(o=>{let{accounts:f,methods:u,events:c}=r.namespaces[o],b=Rs(f),v=t[o];(!An(Sb(o,v),b)||!An(v.methods,u)||!An(v.events,c))&&(s=!1)}),s):!1}function Ef(r){return Ye(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function E_(r){if(Ye(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&Ef(t)}}return!1}function Jb(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Ye(r,!1)){if(e(r))return!0;let t=Nb(r);return e(t)}}catch{}return!1}function Yb(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function Xb(r){return r?.topic}function Zb(r,e){let t=null;return Ye(r?.publicKey,!1)||(t=X("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function yb(r){let e=!0;return ji(r)?r.length&&(e=r.every(t=>Ye(t,!1))):e=!1,e}function S_(r,e,t){let i=null;return ji(e)&&e.length?e.forEach(n=>{i||Ef(n)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Ef(r)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function I_(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=S_(n,Sb(n,s),`${e} ${t}`);o&&(i=o)}),i}function M_(r,e){let t=null;return ji(r)?r.forEach(i=>{t||E_(i)||(t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function A_(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=M_(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function R_(r,e){let t=null;return yb(r?.methods)?yb(r?.events)||(t=Ue("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Ue("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Qb(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=R_(i,`${e}, namespace`);n&&(t=n)}),t}function ev(r,e,t){let i=null;if(r&&No(r)){let n=Qb(r,e);n&&(i=n);let s=I_(r,e,t);s&&(i=s)}else i=X("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Tf(r,e){let t=null;if(r&&No(r)){let i=Qb(r,e);i&&(t=i);let n=A_(r,e);n&&(t=n)}else t=X("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ku(r){return Ye(r.protocol,!0)}function tv(r,e){let t=!1;return e&&!r?t=!0:r&&ji(r)&&r.length&&r.forEach(i=>{t=Ku(i)}),t}function rv(r){return typeof r=="number"}function Mt(r){return typeof r<"u"&&typeof r!==null}function iv(r){return!(!r||typeof r!="object"||!r.code||!ku(r.code,!1)||!r.message||!Ye(r.message,!1))}function nv(r){return!(vt(r)||!Ye(r.method,!1))}function sv(r){return!(vt(r)||vt(r.result)&&vt(r.error)||!ku(r.id,!1)||!Ye(r.jsonrpc,!1))}function ov(r){return!(vt(r)||!Ye(r.name,!1))}function ju(r,e){return!(!Ef(e)||!v_(r).includes(e))}function av(r,e,t){return Ye(t,!1)?m_(r,e).includes(t):!1}function fv(r,e,t){return Ye(t,!1)?y_(r,e).includes(t):!1}function Vu(r,e,t){let i=null,n=T_(r),s=D_(e),o=Object.keys(n),f=Object.keys(s),u=wb(Object.keys(r)),c=wb(Object.keys(e)),b=u.filter(v=>!c.includes(v));return b.length&&(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. Required: ${b.toString()} Received: ${Object.keys(e).toString()}`)),An(o,f)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. Required: ${o.toString()} - Approved: ${f.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=Rs(e[y].accounts);S.includes(y)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} - Required: ${y} - Approved: ${S.toString()}`))}),o.forEach(y=>{i||(An(n[y].methods,s[y].methods)?An(n[y].events,s[y].events)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function T_(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function wb(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function D_(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Rs(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function cv(r,e){return ku(r,!1)&&r<=e.max&&r>=e.min}function $u(){let r=Mo();return new Promise(e=>{switch(r){case Ft.browser:e(P_());break;case Ft.reactNative:e(N_());break;case Ft.node:e(C_());break;default:e(!0)}})}function P_(){return _s()&&navigator?.onLine}async function N_(){return Tn()&&typeof window<"u"&&window!=null&&window.NetInfo?(await window?.NetInfo.fetch())?.isConnected:!0}function C_(){return!0}function hv(r){switch(Mo()){case Ft.browser:O_(r);break;case Ft.reactNative:L_(r);break;case Ft.node:break}}function O_(r){!Tn()&&_s()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function L_(r){Tn()&&typeof window<"u"&&window!=null&&window.NetInfo&&window?.NetInfo.addEventListener(e=>r(e?.isConnected))}var xu={},ki=class{static get(e){return xu[e]}static set(e,t){xu[e]=t}static delete(e){delete xu[e]}};var Mv=qe(hn());var Rt={};Dt(Rt,{DEFAULT_ERROR:()=>Oo,IBaseJsonRpcProvider:()=>Uf,IEvents:()=>Lo,IJsonRpcConnection:()=>Yu,IJsonRpcProvider:()=>Fo,INTERNAL_ERROR:()=>Df,INVALID_PARAMS:()=>pv,INVALID_REQUEST:()=>dv,METHOD_NOT_FOUND:()=>lv,PARSE_ERROR:()=>uv,RESERVED_ERROR_CODES:()=>Hu,SERVER_ERROR:()=>Co,SERVER_ERROR_CODE_RANGE:()=>Pf,STANDARD_ERROR_MAP:()=>ji,formatErrorMessage:()=>Sv,formatJsonRpcError:()=>Pn,formatJsonRpcRequest:()=>br,formatJsonRpcResult:()=>Ts,getBigIntRpcId:()=>gr,getError:()=>Cf,getErrorByCode:()=>Of,isHttpUrl:()=>H_,isJsonRpcError:()=>At,isJsonRpcPayload:()=>Zu,isJsonRpcRequest:()=>Ds,isJsonRpcResponse:()=>Hi,isJsonRpcResult:()=>kt,isJsonRpcValidationInvalid:()=>G_,isLocalhostUrl:()=>Xu,isNodeJs:()=>Ev,isReservedErrorCode:()=>Nf,isServerErrorCode:()=>F_,isValidDefaultRoute:()=>Ff,isValidErrorCode:()=>gv,isValidLeadingWildcardRoute:()=>k_,isValidRoute:()=>B_,isValidTrailingWildcardRoute:()=>K_,isValidWildcardRoute:()=>qf,isWsUrl:()=>zf,parseConnectionError:()=>Gu,payloadId:()=>Qr,validateJsonRpcError:()=>q_});var uv="PARSE_ERROR",dv="INVALID_REQUEST",lv="METHOD_NOT_FOUND",pv="INVALID_PARAMS",Df="INTERNAL_ERROR",Co="SERVER_ERROR",Hu=[-32700,-32600,-32601,-32602,-32603],Pf=[-32e3,-32099],ji={[uv]:{code:-32700,message:"Parse error"},[dv]:{code:-32600,message:"Invalid Request"},[lv]:{code:-32601,message:"Method not found"},[pv]:{code:-32602,message:"Invalid params"},[Df]:{code:-32603,message:"Internal error"},[Co]:{code:-32e3,message:"Server error"}},Oo=Co;function F_(r){return r<=Pf[0]&&r>=Pf[1]}function Nf(r){return Hu.includes(r)}function gv(r){return typeof r=="number"}function Cf(r){return Object.keys(ji).includes(r)?ji[r]:ji[Oo]}function Of(r){let e=Object.values(ji).find(t=>t.code===r);return e||ji[Oo]}function q_(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!gv(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(Nf(r.error.code)){let e=Of(r.error.code);if(e.message!==ji[Oo].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Gu(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var Nt={};Dt(Nt,{isNodeJs:()=>Ev});var xv=qe(Ju());qt(Nt,qe(Ju()));var Ev=xv.isNode;qt(Rt,Nt);function Qr(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function gr(r=6){return BigInt(Qr(r))}function br(r,e,t){return{id:t||Qr(),jsonrpc:"2.0",method:r,params:e}}function Ts(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Pn(r,e,t){return{id:r,jsonrpc:"2.0",error:Sv(e,t)}}function Sv(r,e){return typeof r>"u"?Cf(Df):(typeof r=="string"&&(r=Object.assign(Object.assign({},Cf(Co)),{message:r})),typeof e<"u"&&(r.data=e),Nf(r.code)&&(r=Of(r.code)),r)}function B_(r){return r.includes("*")?qf(r):!/\W/g.test(r)}function Ff(r){return r==="*"}function qf(r){return Ff(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function k_(r){return!Ff(r)&&qf(r)&&!r.split("*")[0].trim()}function K_(r){return!Ff(r)&&qf(r)&&!r.split("*")[1].trim()}var Lo=class{},Yu=class extends Lo{constructor(e){super()}},Uf=class extends Lo{constructor(){super()}},Fo=class extends Uf{constructor(e){super()}};var j_="^https?:",V_="^wss?:";function $_(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Iv(r,e){let t=$_(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function H_(r){return Iv(r,j_)}function zf(r){return Iv(r,V_)}function Xu(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function Zu(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Ds(r){return Zu(r)&&"method"in r}function Hi(r){return Zu(r)&&(kt(r)||At(r))}function kt(r){return"result"in r}function At(r){return"error"in r}function G_(r){return"error"in r&&r.valid===!1}var Bf=class extends Fo{constructor(e){super(e),this.events=new Mv.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(br(e.method,e.params||[],e.id||gr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{At(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Hi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Pv=qe(hn());var W_=()=>typeof WebSocket<"u"?WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Rv(),J_=()=>typeof WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Tv=r=>r.split("?")[0],Dv=10,Y_=W_(),kf=class{constructor(e){if(this.url=e,this.events=new Pv.EventEmitter,this.registering=!1,!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Wt(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Rt.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Xu(e)},o=new Y_(e,[],s);J_()?o.onerror=f=>{let d=f;i(this.emitError(d.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?Fr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=Pn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Gu(e,Tv(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Dv&&this.events.setMaxListeners(Dv)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Tv(this.url)}`));return this.events.emit("register_error",t),t}};var Om=qe(dm()),Lm=qe(za()),Fm="wc",qm=2,Ld="core",ii=`${Fm}@2:${Ld}:`,AE={name:Ld,logger:"error"},RE={database:":memory:"},TE="crypto",lm="client_ed25519_seed",DE=re.ONE_DAY,PE="keychain",NE="0.3",CE="messages",OE="0.3",LE=re.SIX_HOURS,FE="publisher",Fd="irn",qE="error",Um="wss://relay.walletconnect.org",UE="relayer",Tt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},zE="_subscription",rr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},BE=.1;var dd="2.17.1";var $e={link_mode:"link_mode",relay:"relay"},kE="0.3",KE="WALLETCONNECT_CLIENT_ID",pm="WALLETCONNECT_LINK_MODE_APPS",ti={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var jE="subscription",VE="0.3",$E=re.FIVE_SECONDS*1e3,HE="pairing",GE="0.3";var Ko={wc_pairingDelete:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:re.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:re.ONE_DAY,prompt:!1,tag:0},res:{ttl:re.ONE_DAY,prompt:!1,tag:0}}},Ji={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},vr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},WE="history",JE="0.3",YE="expirer",Kt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},XE="0.3";var ZE="verify-api",QE="https://verify.walletconnect.com",zm="https://verify.walletconnect.org",Os=zm,e9=`${Os}/v3`,t9=[QE,zm],r9="echo",i9="https://echo.walletconnect.com";var mr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ri={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ir={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Yi={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Xi={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Ls={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},n9=.1,s9="event-client",o9=86400,a9="https://pulse.walletconnect.org/batch";function f9(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,z=new Uint8Array(B);P!==U;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,z[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");C=H,P++}for(var O=B-C;O!==B&&z[O]===0;)O++;for(var W=d.repeat(T);O>>0,B=new Uint8Array(U);M[T];){var z=t[M.charCodeAt(T)];if(z===255)return;for(var j=0,H=U-1;(z!==0||j>>0,B[H]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=U-P;L!==U&&B[L]===0;)L++;for(var O=new Uint8Array(C+(U-L)),W=C;L!==U;)O[W++]=B[L++];return O}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var c9=f9,h9=c9,Bm=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},u9=r=>new TextEncoder().encode(r),d9=r=>new TextDecoder().decode(r),ld=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},pd=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return km(this,e)}},gd=class{constructor(e){this.decoders=e}or(e){return km(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},km=(r,e)=>new gd({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),bd=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ld(e,t,i),this.decoder=new pd(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Qf=({name:r,prefix:e,encode:t,decode:i})=>new bd(r,e,t,i),$o=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=h9(t,e);return Qf({prefix:r,name:e,encode:i,decode:s=>Bm(n(s))})},l9=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[h++]=255&d>>f)}if(f>=t||255&d<<8-f)throw new SyntaxError("Unexpected end of data");return o},p9=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Qf({prefix:e,name:r,encode(n){return p9(n,i,t)},decode(n){return l9(n,i,t,r)}}),g9=Qf({prefix:"\0",name:"identity",encode:r=>d9(r),decode:r=>u9(r)}),b9=Object.freeze({__proto__:null,identity:g9}),v9=mt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),m9=Object.freeze({__proto__:null,base2:v9}),y9=mt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),w9=Object.freeze({__proto__:null,base8:y9}),_9=$o({prefix:"9",name:"base10",alphabet:"0123456789"}),x9=Object.freeze({__proto__:null,base10:_9}),E9=mt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),S9=mt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),I9=Object.freeze({__proto__:null,base16:E9,base16upper:S9}),M9=mt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),A9=mt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),R9=mt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),T9=mt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),D9=mt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),P9=mt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),N9=mt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),C9=mt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),O9=mt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),L9=Object.freeze({__proto__:null,base32:M9,base32upper:A9,base32pad:R9,base32padupper:T9,base32hex:D9,base32hexupper:P9,base32hexpad:N9,base32hexpadupper:C9,base32z:O9}),F9=$o({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),q9=$o({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),U9=Object.freeze({__proto__:null,base36:F9,base36upper:q9}),z9=$o({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),B9=$o({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),k9=Object.freeze({__proto__:null,base58btc:z9,base58flickr:B9}),K9=mt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j9=mt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V9=mt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$9=mt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),H9=Object.freeze({__proto__:null,base64:K9,base64pad:j9,base64url:V9,base64urlpad:$9}),Km=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),G9=Km.reduce((r,e,t)=>(r[t]=e,r),[]),W9=Km.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function J9(r){return r.reduce((e,t)=>(e+=G9[t],e),"")}function Y9(r){let e=[];for(let t of r){let i=W9[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var X9=Qf({prefix:"\u{1F680}",name:"base256emoji",encode:J9,decode:Y9}),Z9=Object.freeze({__proto__:null,base256emoji:X9}),Q9=jm,gm=128,e7=127,t7=~e7,r7=Math.pow(2,31);function jm(r,e,t){e=e||[],t=t||0;for(var i=t;r>=r7;)e[t++]=r&255|gm,r/=128;for(;r&t7;)e[t++]=r&255|gm,r>>>=7;return e[t]=r|0,jm.bytes=t-i+1,e}var i7=vd,n7=128,bm=127;function vd(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw vd.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&bm)<=n7);return vd.bytes=s-i,t}var s7=Math.pow(2,7),o7=Math.pow(2,14),a7=Math.pow(2,21),f7=Math.pow(2,28),c7=Math.pow(2,35),h7=Math.pow(2,42),u7=Math.pow(2,49),d7=Math.pow(2,56),l7=Math.pow(2,63),p7=function(r){return r(Vm.encode(r,e,t),e),mm=r=>Vm.encodingLength(r),md=(r,e)=>{let t=e.byteLength,i=mm(r),n=i+mm(t),s=new Uint8Array(n+t);return vm(r,s,0),vm(t,s,i),s.set(e,n),new yd(r,t,e,s)},yd=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},$m=({name:r,code:e,encode:t})=>new wd(r,e,t),wd=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?md(this.code,t):t.then(i=>md(this.code,i))}else throw Error("Unknown type, must be binary type")}},Hm=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),b7=$m({name:"sha2-256",code:18,encode:Hm("SHA-256")}),v7=$m({name:"sha2-512",code:19,encode:Hm("SHA-512")}),m7=Object.freeze({__proto__:null,sha256:b7,sha512:v7}),Gm=0,y7="identity",Wm=Bm,w7=r=>md(Gm,Wm(r)),_7={code:Gm,name:y7,encode:Wm,digest:w7},x7=Object.freeze({__proto__:null,identity:_7});new TextEncoder,new TextDecoder;var ym={...b9,...m9,...w9,...x9,...I9,...L9,...U9,...k9,...H9,...Z9};({...m7,...x7});function E7(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Jm(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var wm=Jm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),hd=Jm("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=E7(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=X("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},xd=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=TE,this.randomSessionIdentifier=Af(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=_h(n);return Ua(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=Ub();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=_h(s),f=this.randomSessionIdentifier;return await fp(f,n,DE,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let f=this.getPrivateKey(n),d=zb(f,s);return this.setSymKey(d,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||Is(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let f=Lu(o),d=Wt(s);if(qu(f))return Kb(d,o?.encoding);if(Fu(f)){let S=f.senderPublicKey,I=f.receiverPublicKey;n=await this.generateSharedKey(S,I)}let h=this.getSymKey(n),{type:b,senderPublicKey:y}=f;return kb({type:b,symKey:h,message:d,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let f=Hb(s,o);if(qu(f)){let d=Vb(s,o?.encoding);return Fr(d)}if(Fu(f)){let d=f.receiverPublicKey,h=f.senderPublicKey;n=await this.generateSharedKey(d,h)}try{let d=this.getSymKey(n),h=jb({symKey:d,encoded:s,encoding:o?.encoding});return Fr(h)}catch(d){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(d)}},this.getPayloadType=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return Bi(o.type)},this.getPayloadSenderPublicKey=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return o.senderPublicKey?Ze(o.senderPublicKey,It):void 0},this.core=e,this.logger=lt(t,this.name),this.keychain=i||new _d(this.core,this.logger)}get context(){return yt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(lm)}catch{e=Af(),await this.keychain.set(lm,e)}return I7(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Ed=class extends ba{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=CE,this.version=OE,this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=pr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=pr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=lt(e,this.name),this.core=t}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Sd=class extends va{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Ei.EventEmitter,this.name=FE,this.queue=new Map,this.publishTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.failedPublishTimeout=(0,re.toMiliseconds)(re.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let f=s?.ttl||LE,d=Rf(s),h=s?.prompt||!1,b=s?.tag||0,y=s?.id||gr().toString(),S={topic:i,message:n,opts:{ttl:f,relay:d,prompt:h,tag:b,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${b}`,M=Date.now(),T,C=1;try{for(;T===void 0;){if(Date.now()-M>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:C},`publisher.publish - attempt ${C}`),T=await await Dn(this.rpcPublish(i,n,f,d,h,b,y,s?.attestation).catch(P=>this.logger.warn(P)),this.publishTimeout,I),C++,T||await new Promise(P=>setTimeout(P,this.failedPublishTimeout))}this.relayer.events.emit(Tt.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(P){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(P),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw P;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=lt(t,this.name),this.registerEventListeners()}get context(){return yt(this.logger)}rpcPublish(e,t,i,n,s,o,f,d){var h,b,y,S;let I={method:As(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:d},id:f};return vt((h=I.params)==null?void 0:h.prompt)&&((b=I.params)==null||delete b.prompt),vt((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(un.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Tt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Tt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Id=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},M7=Object.defineProperty,A7=Object.defineProperties,R7=Object.getOwnPropertyDescriptors,_m=Object.getOwnPropertySymbols,T7=Object.prototype.hasOwnProperty,D7=Object.prototype.propertyIsEnumerable,xm=(r,e,t)=>e in r?M7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jo=(r,e)=>{for(var t in e||(e={}))T7.call(e,t)&&xm(r,t,e[t]);if(_m)for(var t of _m(e))D7.call(e,t)&&xm(r,t,e[t]);return r},ud=(r,e)=>A7(r,R7(e)),Md=class extends wa{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Id,this.events=new Ei.EventEmitter,this.name=jE,this.version=VE,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ii,this.subscribeTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=Rf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let f=new re.Watch;f.start(n);let d=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(d),f.stop(n),s(!0)),f.elapsed(n)>=$E&&(clearInterval(d),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=lt(t,this.name),this.clientId=""}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=Rf(i);await this.rpcUnsubscribe(e,t,n);let s=Ue("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===$e.relay&&await this.restartToComplete();let s={method:As(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let f=pr(e+this.clientId);if(i?.transportType===$e.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(h=>this.logger.warn(h))},(0,re.toMiliseconds)(re.ONE_SECOND)),f;let d=await Dn(this.relayer.request(s).catch(h=>this.logger.warn(h)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!d&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return d?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Tt.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Dn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Dn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:As(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,ud(jo({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,jo({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,jo({},t)),this.topicMap.set(t.topic,e),this.events.emit(ti.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(ti.deleted,ud(jo({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ti.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);Ki(t)&&this.onBatchSubscribe(t.map((i,n)=>ud(jo({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(un.pulse,async()=>{await this.checkPending()}),this.events.on(ti.created,async e=>{let t=ti.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(ti.deleted,async e=>{let t=ti.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},P7=Object.defineProperty,Em=Object.getOwnPropertySymbols,N7=Object.prototype.hasOwnProperty,C7=Object.prototype.propertyIsEnumerable,Sm=(r,e,t)=>e in r?P7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Im=(r,e)=>{for(var t in e||(e={}))N7.call(e,t)&&Sm(r,t,e[t]);if(Em)for(var t of Em(e))C7.call(e,t)&&Sm(r,t,e[t]);return r},Ad=class extends ma{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Ei.EventEmitter,this.name=UE,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,re.toMiliseconds)(re.THIRTY_SECONDS+re.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||gr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let f=await new Promise(async(d,h)=>{let b=()=>{h(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(rr.disconnect,b);let y=await o;this.provider.off(rr.disconnect,b),d(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Io())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Tt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Tt.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(rr.payload,this.onPayloadHandler),this.provider.on(rr.connect,this.onConnectHandler),this.provider.on(rr.disconnect,this.onDisconnectHandler),this.provider.on(rr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?lt(e.logger,this.name):(0,Hs.default)(Ws({level:e.logger||qE})),this.messages=new Ed(this.logger,e.core),this.subscriber=new Md(this,this.logger),this.publisher=new Sd(this,this.logger),this.relayUrl=e?.relayUrl||Um,this.projectId=e.projectId,this.bundleId=Ib(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return yt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:$e.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",d,h=b=>{b.topic===e&&(this.subscriber.off(ti.created,h),d())};return await Promise.all([new Promise(b=>{d=b,this.subscriber.on(ti.created,h)}),new Promise(async(b,y)=>{f=await this.subscriber.subscribe(e,Im({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||f,b()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await Dn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(rr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(rr.disconnect,n),await Dn(this.provider.connect(),(0,re.toMiliseconds)(re.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await $u())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=st(re.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Tt.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Io())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Bf(new kf(Mb({sdkVersion:dd,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Ds(e)){if(!e.method.endsWith(zE))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:$e.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Im({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Hi(e)&&this.events.emit(Tt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Tt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=Ts(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(rr.payload,this.onPayloadHandler),this.provider.off(rr.connect,this.onConnectHandler),this.provider.off(rr.disconnect,this.onDisconnectHandler),this.provider.off(rr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await $u();hv(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Tt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,re.toMiliseconds)(BE))))}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},O7=Object.defineProperty,Mm=Object.getOwnPropertySymbols,L7=Object.prototype.hasOwnProperty,F7=Object.prototype.propertyIsEnumerable,Am=(r,e,t)=>e in r?O7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rm=(r,e)=>{for(var t in e||(e={}))L7.call(e,t)&&Am(r,t,e[t]);if(Mm)for(var t of Mm(e))F7.call(e,t)&&Am(r,t,e[t]);return r},ni=class extends ya{constructor(e,t,i,n=ii,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=kE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!vt(o)?this.map.set(this.getKey(o),o):Yb(o)?this.map.set(o.id,o):Xb(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(d=>(0,Om.default)(f[d],o[d]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});let d=Rm(Rm({},this.getData(o)),f);this.map.set(o,d),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=lt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Rd=class{constructor(e,t){this.core=e,this.logger=t,this.name=HE,this.version=GE,this.events=new Ei.default,this.initialized=!1,this.storagePrefix=ii,this.ignoredPayloadTypes=[lr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=Af(),s=await this.core.crypto.setSymKey(n),o=st(re.FIVE_MINUTES),f={protocol:Fd},d={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},h=zu({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Ji.create,d),this.core.expirer.set(s,o),await this.pairings.set(s,d),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:h}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[mr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:f,expiryTimestamp:d,methods:h}=Uu(i.uri);n.props.properties.topic=s,n.addTrace(mr.pairing_uri_validation_success),n.addTrace(mr.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(mr.existing_pairing),b.active)throw n.setError(ri.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(mr.pairing_not_expired)}let y=d||st(re.FIVE_MINUTES),S={topic:s,relay:f,expiry:y,active:!1,methods:h};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(mr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Ji.create,S),n.addTrace(mr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(mr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ri.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(I){throw n.setError(ri.subscribe_pairing_topic_failure),I}return n.addTrace(mr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=st(re.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:d}=wi();this.events.once(Oe("pairing_ping",s),({error:h})=>{h?d(h):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Ue("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:f}=i,d=this.core.crypto.keychain.get(n);return zu({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:d,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{let o=br(n,s),f=await this.core.crypto.encode(i,o),d=Ko[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,d),o.id},this.sendResult=async(i,n,s)=>{let o=Ts(i,s),f=await this.core.crypto.encode(n,o),d=await this.core.history.get(n,i),h=Ko[d.request.method].res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=Pn(i,s),f=await this.core.crypto.encode(n,o),d=await this.core.history.get(n,i),h=Ko[d.request.method]?Ko[d.request.method].res:Ko.unregistered_method.res;await this.core.relayer.publish(n,f,h),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Ue("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>Xr(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Ji.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{kt(n)?this.events.emit(Oe("pairing_ping",s),{}):At(n)&&this.events.emit(Oe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Ji.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let f=Ue("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Ue("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Mt(i)){let{message:f}=X("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!Jb(i.uri)){let{message:f}=X("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}let o=Uu(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&(0,re.toMiliseconds)(o?.expiryTimestamp){if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!Ye(i,!1)){let{message:n}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Xr(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=X("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=lt(t,this.name),this.pairings=new ni(this.core,this.logger,this.name,this.storagePrefix)}get context(){return yt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Tt.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===$e.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{Ds(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Hi(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Kt.expired,async e=>{let{topic:t}=If(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Ji.expire,{topic:t}))})}},Td=class extends ga{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Ei.EventEmitter,this.name=WE,this.version=JE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:st(re.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(vr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=At(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(vr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(vr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:br(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(vr.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(vr.created,e=>{let t=vr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.updated,e=>{let t=vr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.deleted,e=>{let t=vr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(un.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,re.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(vr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Dd=class extends _a{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Ei.EventEmitter,this.name=YE,this.version=XE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Kt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Kt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Rb(e);if(typeof e=="number")return Tb(e);let{message:t}=X("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Kt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,re.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Kt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(un.pulse,()=>this.checkExpirations()),this.events.on(Kt.created,e=>{let t=Kt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.expired,e=>{let t=Kt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.deleted,e=>{let t=Kt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Pd=class extends xa{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=ZE,this.verifyUrlV3=e9,this.storagePrefix=ii,this.version=qm,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,re.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!_s()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:f}=n,d=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{let h=(0,Lm.getDocument)(),b=this.startAbortTimer(re.ONE_SECOND*5),y=await new Promise((S,I)=>{let M=()=>{window.removeEventListener("message",C),h.body.removeChild(T),I("attestation aborted")};this.abortController.signal.addEventListener("abort",M);let T=h.createElement("iframe");T.src=d,T.style.display="none",T.addEventListener("error",M,{signal:this.abortController.signal});let C=P=>{if(P.data&&typeof P.data=="string")try{let U=JSON.parse(P.data);if(U.type==="verify_attestation"){if(ts(U.attestation).payload.id!==o)return;clearInterval(b),h.body.removeChild(T),this.abortController.signal.removeEventListener("abort",M),window.removeEventListener("message",C),S(U.attestation===null?"":U.attestation)}}catch(U){this.logger.warn(U)}};h.body.appendChild(T),window.addEventListener("message",C,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(h){this.logger.warn(h)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ts(s).payload.id!==f)return;let h=await this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;let d=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,d)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(re.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||Os;return t9.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Os}`),s=Os),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(re.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=Gb(n,s.publicKey),f={hasExpired:(0,re.toMiliseconds)(o.exp)this.abortController.abort(),(0,re.toMiliseconds)(e))}},Nd=class extends Ea{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=r9,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,d=`${i9}/${this.projectId}/clients`;await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=lt(t,this.context)}},q7=Object.defineProperty,Tm=Object.getOwnPropertySymbols,U7=Object.prototype.hasOwnProperty,z7=Object.prototype.propertyIsEnumerable,Dm=(r,e,t)=>e in r?q7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vo=(r,e)=>{for(var t in e||(e={}))U7.call(e,t)&&Dm(r,t,e[t]);if(Tm)for(var t of Tm(e))z7.call(e,t)&&Dm(r,t,e[t]);return r},Cd=class extends Sa{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=s9,this.storagePrefix=ii,this.storageVersion=n9,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Ao())try{let n={eventId:Ru(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Su(this.core.relayer.protocol,this.core.relayer.version,dd)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:f,trace:d}}=n,h=Ru(),b=this.core.projectId||"",y=Date.now(),S=Vo({eventId:h,timestamp:y,props:{event:s,type:o,properties:{topic:f,trace:d}},bundleId:b,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let f=Array.from(this.events.values()).find(d=>d.props.properties.topic===o);if(f)return Vo(Vo({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(un.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,re.fromMiliseconds)(Date.now())-(0,re.fromMiliseconds)(n.timestamp)>o9&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Vo(Vo({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${a9}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${dd}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>xs().url,this.logger=lt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},B7=Object.defineProperty,Pm=Object.getOwnPropertySymbols,k7=Object.prototype.hasOwnProperty,K7=Object.prototype.propertyIsEnumerable,Nm=(r,e,t)=>e in r?B7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cm=(r,e)=>{for(var t in e||(e={}))k7.call(e,t)&&Nm(r,t,e[t]);if(Pm)for(var t of Pm(e))K7.call(e,t)&&Nm(r,t,e[t]);return r},Od=class r extends pa{constructor(e){var t;super(e),this.protocol=Fm,this.version=qm,this.name=Ld,this.events=new Ei.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:d})=>{if(!o||!f)return;let h={topic:o,message:f,publishedAt:Date.now(),transportType:$e.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:d})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Um,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Ws({level:typeof e?.logger=="string"&&e.logger?e.logger:AE.logger}),{logger:n,chunkLoggerController:s}=Zl({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=lt(n,this.name),this.heartbeat=new na,this.crypto=new xd(this,this.logger,e?.keychain),this.history=new Td(this,this.logger),this.expirer=new Dd(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new aa(Cm(Cm({},RE),e?.storageOptions)),this.relayer=new Ad({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Rd(this,this.logger),this.verify=new Pd(this,this.logger,this.storage),this.echoClient=new Nd(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Cd(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(KE,i),t}get context(){return yt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(pm,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(pm)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},Ym=Od;var rc=qe(hn()),Fe=qe(jn());var ey="wc",ty=2,ry="client",Gd=`${ey}@${ty}:${ry}:`,qd={name:ry,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var Xm="WALLETCONNECT_DEEPLINK_CHOICE";var j7="proposal";var V7="Proposal expired",$7="session",Fs=Fe.SEVEN_DAYS,H7="engine",dt={wc_sessionPropose:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Fe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Fe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1119}}},Ud={min:Fe.FIVE_MINUTES,max:Fe.SEVEN_DAYS},si={idle:"IDLE",active:"ACTIVE"},G7="request",W7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],J7="wc";var Y7="auth",X7="authKeys",Z7="pairingTopics",Q7="requests",ic=`${J7}@${1.5}:${Y7}:`,ec=`${ic}:PUB_KEY`,eS=Object.defineProperty,tS=Object.defineProperties,rS=Object.getOwnPropertyDescriptors,Zm=Object.getOwnPropertySymbols,iS=Object.prototype.hasOwnProperty,nS=Object.prototype.propertyIsEnumerable,Qm=(r,e,t)=>e in r?eS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tt=(r,e)=>{for(var t in e||(e={}))iS.call(e,t)&&Qm(r,t,e[t]);if(Zm)for(var t of Zm(e))nS.call(e,t)&&Qm(r,t,e[t]);return r},yr=(r,e)=>tS(r,rS(e)),zd=class extends Ma{constructor(e){super(e),this.name=H7,this.events=new rc.default,this.initialized=!1,this.requestQueue={state:si.idle,queue:[]},this.sessionRequestQueue={state:si.idle,queue:[]},this.requestQueueDelay=Fe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(dt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=yr(tt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:d}=i,h=n,b,y=!1;try{h&&(y=this.client.core.pairing.pairings.get(h).active)}catch(z){throw this.client.logger.error(`connect() -> pairing.get(${h}) failed`),z}if(!h||!y){let{topic:z,uri:j}=await this.client.core.pairing.create();h=z,b=j}if(!h){let{message:z}=X("NO_MATCHING_KEY",`connect() pairing topic: ${h}`);throw new Error(z)}let S=await this.client.core.crypto.generateKeyPair(),I=dt.wc_sessionPropose.req.ttl||Fe.FIVE_MINUTES,M=st(I),T=tt({requiredNamespaces:s,optionalNamespaces:o,relays:d??[{protocol:Fd}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:M,pairingTopic:h},f&&{sessionProperties:f}),{reject:C,resolve:P,done:U}=wi(I,V7);this.events.once(Oe("session_connect"),async({error:z,session:j})=>{if(z)C(z);else if(j){j.self.publicKey=S;let H=yr(tt({},j),{pairingTopic:T.pairingTopic,requiredNamespaces:T.requiredNamespaces,optionalNamespaces:T.optionalNamespaces,transportType:$e.relay});await this.client.session.set(j.topic,H),await this.setExpiry(j.topic,j.expiry),h&&await this.client.core.pairing.updateMetadata({topic:h,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(H),P(H)}});let B=await this.sendRequest({topic:h,method:"wc_sessionPropose",params:T,throwOnFailedPublish:!0});return await this.setProposal(B,tt({id:B},T)),{uri:b,approval:U}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[ir.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(O){throw o.setError(Yi.no_internet_connection),O}try{await this.isValidProposalId(t?.id)}catch(O){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(Yi.proposal_not_found),O}try{await this.isValidApprove(t)}catch(O){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Yi.session_approve_namespace_validation_failure),O}let{id:f,relayProtocol:d,namespaces:h,sessionProperties:b,sessionConfig:y}=t,S=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:M,requiredNamespaces:T,optionalNamespaces:C}=S,P=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});P||(P=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:ir.session_approve_started,properties:{topic:I,trace:[ir.session_approve_started,ir.session_namespaces_validation_success]}}));let U=await this.client.core.crypto.generateKeyPair(),B=M.publicKey,z=await this.client.core.crypto.generateSharedKey(U,B),j=tt(tt({relay:{protocol:d??"irn"},namespaces:h,controller:{publicKey:U,metadata:this.client.metadata},expiry:st(Fs)},b&&{sessionProperties:b}),y&&{sessionConfig:y}),H=$e.relay;P.addTrace(ir.subscribing_session_topic);try{await this.client.core.relayer.subscribe(z,{transportType:H})}catch(O){throw P.setError(Yi.subscribe_session_topic_failure),O}P.addTrace(ir.subscribe_session_topic_success);let L=yr(tt({},j),{topic:z,requiredNamespaces:T,optionalNamespaces:C,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:M.publicKey,metadata:M.metadata},controller:U,transportType:$e.relay});await this.client.session.set(z,L),P.addTrace(ir.store_session);try{P.addTrace(ir.publishing_session_settle),await this.sendRequest({topic:z,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(O=>{throw P?.setError(Yi.session_settle_publish_failure),O}),P.addTrace(ir.session_settle_publish_success),P.addTrace(ir.publishing_session_approve),await this.sendResult({id:f,topic:I,result:{relay:{protocol:d??"irn"},responderPublicKey:U},throwOnFailedPublish:!0}).catch(O=>{throw P?.setError(Yi.session_approve_publish_failure),O}),P.addTrace(ir.session_approve_publish_success)}catch(O){throw this.client.logger.error(O),this.client.session.delete(z,Ue("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(z),O}return this.client.core.eventClient.deleteEvent({eventId:P.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:M.metadata}),await this.client.proposal.delete(f,Ue("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(z,st(Fs)),{topic:z,acknowledged:()=>Promise.resolve(this.client.session.get(z))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:dt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=wi(),d=Qr(),h=gr().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Oe("session_update",d),({error:y})=>{y?f(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:d,relayRpcId:h}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:b}),f(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(d){throw this.client.logger.error("extend() -> isValidExtend() failed"),d}let{topic:i}=t,n=Qr(),{done:s,resolve:o,reject:f}=wi();return this.events.once(Oe("session_extend",n),({error:d})=>{d?f(d):o()}),await this.setExpiry(i,st(Fs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(d=>{f(d)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(M){throw this.client.logger.error("request() -> isValidRequest() failed"),M}let{chainId:i,request:n,topic:s,expiry:o=dt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let d=Qr(),h=gr().toString(),{done:b,resolve:y,reject:S}=wi(o,"Request expired. Please try again.");this.events.once(Oe("session_request",d),({error:M,result:T})=>{M?S(M):y(T)});let I=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return I?(await this.sendRequest({clientRpcId:d,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(M=>S(M)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:d}),await b()):await Promise.all([new Promise(async M=>{await this.sendRequest({clientRpcId:d,relayRpcId:h,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(T=>S(T)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:d}),M()}),new Promise(async M=>{var T;if(!((T=f.sessionConfig)!=null&&T.disableDeepLink)){let C=await Pb(this.client.core.storage,Xm);await Db({id:d,topic:s,wcDeepLink:C})}M()}),b()]).then(M=>M[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);kt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):At(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=Qr(),s=gr().toString(),{done:o,resolve:f,reject:d}=wi();this.events.once(Oe("session_ping",n),({error:h})=>{h?d(h):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=gr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Ue("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=X("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>Wb(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?$e.link_mode:$e.relay;o===$e.relay&&await this.confirmOnlineStateOrThrow();let{chains:f,statement:d="",uri:h,domain:b,nonce:y,type:S,exp:I,nbf:M,methods:T=[],expiry:C}=t,P=[...t.resources||[]],{topic:U,uri:B}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:U,uri:B}});let z=await this.client.core.crypto.generateKeyPair(),j=Is(z);if(await Promise.all([this.client.auth.authKeys.set(ec,{responseTopic:j,publicKey:z}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:U})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${U}`),T.length>0){let{namespace:m}=So(f[0]),c=Ob(m,"request",T);To(P)&&(c=Lb(c,P.pop())),P.push(c)}let H=C&&C>dt.wc_sessionAuthenticate.req.ttl?C:dt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:f,statement:d,aud:h,domain:b,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:M,resources:P},requester:{publicKey:z,metadata:this.client.metadata},expiryTimestamp:st(H)},O={eip155:{chains:f,methods:[...new Set(["personal_sign",...T])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:O,relays:[{protocol:"irn"}],pairingTopic:U,proposer:{publicKey:z,metadata:this.client.metadata},expiryTimestamp:st(dt.wc_sessionPropose.req.ttl)},{done:D,resolve:l,reject:w}=wi(H,"Request expired"),p=async({error:m,session:c})=>{if(this.events.off(Oe("session_request",u),a),m)w(m);else if(c){c.self.publicKey=z,await this.client.session.set(c.topic,c),await this.setExpiry(c.topic,c.expiry),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:c.peer.metadata});let x=this.client.session.get(c.topic);await this.deleteProposal(v),l({session:x})}},a=async m=>{var c,x,A;if(await this.deletePendingAuthRequest(u,{message:"fulfilled",code:0}),m.error){let q=Ue("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return m.error.code===q.code?void 0:(this.events.off(Oe("session_connect"),p),w(m.error.message))}await this.deleteProposal(v),this.events.off(Oe("session_connect"),p);let{cacaos:g,responder:R}=m.result,k=[],E=[];for(let q of g){await Du({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,J=To(K.resources),$=[Mf(K.iss)],V=Ro(K.iss);if(J){let ee=Nu(J),G=Cu(J);k.push(...ee),$.push(...G)}for(let ee of $)E.push(`${ee}:${V}`)}let N=await this.client.core.crypto.generateSharedKey(z,R.publicKey),F;k.length>0&&(F={topic:N,acknowledged:!0,self:{publicKey:z,metadata:this.client.metadata},peer:R,controller:R.publicKey,expiry:st(Fs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:U,namespaces:Bu([...new Set(k)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(N,{transportType:o}),await this.client.session.set(N,F),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:R.metadata}),F=this.client.session.get(N)),(c=this.client.metadata.redirect)!=null&&c.linkMode&&(x=R.metadata.redirect)!=null&&x.linkMode&&(A=R.metadata.redirect)!=null&&A.universal&&i&&(this.client.core.addLinkModeSupportedApp(R.metadata.redirect.universal),this.client.session.update(N,{transportType:$e.link_mode})),l({auths:g,session:F})},u=Qr(),v=Qr();this.events.once(Oe("session_connect"),p),this.events.once(Oe("session_request",u),a);let _;try{if(s){let m=br("wc_sessionAuthenticate",L,u);this.client.core.history.set(U,m);let c=await this.client.core.crypto.encode("",m,{type:Ss,encoding:Es});_=Po(i,U,c)}else await Promise.all([this.sendRequest({topic:U,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:u}),this.sendRequest({topic:U,method:"wc_sessionPropose",params:W,expiry:dt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:v})])}catch(m){throw this.events.off(Oe("session_connect"),p),this.events.off(Oe("session_request",u),a),m}return await this.setProposal(v,tt({id:v},W)),await this.setAuthRequest(u,{request:yr(tt({},L),{verifyContext:{}}),pairingTopic:U,transportType:o}),{uri:_??B,response:D}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Xi.authenticated_session_approve_started]}});try{this.isInitialized()}catch(C){throw s.setError(Ls.no_internet_connection),C}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Ls.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let f=o.transportType||$e.relay;f===$e.relay&&await this.confirmOnlineStateOrThrow();let d=o.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),b=Is(d),y={type:lr,receiverPublicKey:d,senderPublicKey:h},S=[],I=[];for(let C of n){if(!await Du({cacao:C,projectId:this.client.core.projectId})){s.setError(Ls.invalid_cacao);let j=Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:j,encodeOpts:y}),new Error(j.message)}s.addTrace(Xi.cacaos_verified);let{p:P}=C,U=To(P.resources),B=[Mf(P.iss)],z=Ro(P.iss);if(U){let j=Nu(U),H=Cu(U);S.push(...j),B.push(...H)}for(let j of B)I.push(`${j}:${z}`)}let M=await this.client.core.crypto.generateSharedKey(h,d);s.addTrace(Xi.create_authenticated_session_topic);let T;if(S?.length>0){T={topic:M,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:d,metadata:o.requester.metadata},controller:d,expiry:st(Fs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Bu([...new Set(S)],[...new Set(I)]),transportType:f},s.addTrace(Xi.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(M,{transportType:f})}catch(C){throw s.setError(Ls.subscribe_authenticated_session_topic_failure),C}s.addTrace(Xi.subscribe_authenticated_session_topic_success),await this.client.session.set(M,T),s.addTrace(Xi.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Xi.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(C){throw s.setError(Ls.authenticated_session_approve_publish_failure),C}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:T}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),d=Is(o),h={type:lr,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:d,error:n,encodeOpts:h,rpcOpts:dt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return Pu(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:d}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Ue("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(d.publicKey)&&await this.client.core.crypto.deleteKeyPair(d.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Xm).catch(h=>this.client.logger.warn(h)),this.getPendingSessionRequests().forEach(h=>{h.topic===n&&this.deletePendingSessionRequest(h.id,Ue("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=si.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(Yi.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Ue("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=si.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,st(dt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=$e.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||st(dt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:d,throwOnFailedPublish:h,appLink:b}=t,y=br(n,s,d),S,I=!!b;try{let C=I?Es:Zr;S=await this.client.core.crypto.encode(i,y,{encoding:C})}catch(C){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),C}let M;if(W7.includes(n)){let C=pr(JSON.stringify(y)),P=pr(S);M=await this.client.core.verify.register({id:P,decryptedId:C})}let T=dt[n].req;if(T.attestation=M,o&&(T.ttl=o),f&&(T.id=f),this.client.core.history.set(i,y),I){let C=Po(b,i,S);await window.Linking.openURL(C,this.client.name)}else{let C=dt[n].req;o&&(C.ttl=o),f&&(C.id=f),h?(C.internal=yr(tt({},C.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,C)):this.client.core.relayer.publish(i,S,C).catch(P=>this.client.logger.error(P))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:d}=t,h=Ts(i,s),b,y=d&&typeof window?.Linking<"u";try{let I=y?Es:Zr;b=await this.client.core.crypto.encode(n,h,yr(tt({},f||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Po(d,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=dt[S.request.method].res;o?(I.internal=yr(tt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,I)):this.client.core.relayer.publish(n,b,I).catch(M=>this.client.logger.error(M))}await this.client.core.history.resolve(h)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:d}=t,h=Pn(i,s),b,y=d&&typeof window?.Linking<"u";try{let I=y?Es:Zr;b=await this.client.core.crypto.encode(n,h,yr(tt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Po(d,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=f||dt[S.request.method].res;this.client.core.relayer.publish(n,b,I)}await this.client.core.history.resolve(h)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Xr(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Xr(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===si.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=si.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=si.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,d=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:d}))switch(d){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${d}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=X("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:d}=n;try{let h=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(tt({},n.params));let b=f.expiryTimestamp||st(dt.wc_sessionPropose.req.ttl),y=tt({id:d,pairingTopic:i,expiryTimestamp:b},f);await this.setProposal(d,y);let S=await this.getVerifyContext({attestationId:s,hash:pr(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),h?.setError(ri.proposal_listener_not_found)),h?.addTrace(mr.emit_session_proposal),this.client.events.emit("session_proposal",{id:d,params:y,verifyContext:S})}catch(h){await this.sendError({id:d,topic:i,error:h,rpcOpts:dt.wc_sessionPropose.autoReject}),this.client.logger.error(h)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(kt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});let d=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:d});let h=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});let b=await this.client.core.crypto.generateSharedKey(d,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});let y=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(At(i)){await this.client.proposal.delete(s,Ue("USER_DISCONNECTED"));let o=Oe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Oe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:f,expiry:d,namespaces:h,sessionProperties:b,sessionConfig:y}=i.params,S=yr(tt(tt({topic:t,relay:o,expiry:d,namespaces:h,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},b&&{sessionProperties:b}),y&&{sessionConfig:y}),{transportType:$e.relay}),I=Oe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Oe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;kt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Oe("session_approve",n),{})):At(i)&&(await this.client.session.delete(t,Ue("USER_DISCONNECTED")),this.events.emit(Oe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,f=ki.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:Ue("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(tt({topic:t},n));try{ki.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(d){throw ki.delete(o),d}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Oe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_update",n),{}):At(i)&&this.events.emit(Oe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,st(Fs)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Oe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_extend",n),{}):At(i)&&this.events.emit(Oe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Oe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{kt(i)?this.events.emit(Oe("session_ping",n),{}):At(i)&&this.events.emit(Oe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Tt.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Ue("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:f,attestation:d,encryptedId:h,transportType:b}=t,{id:y,params:S}=f;try{await this.isValidRequest(tt({topic:o},S));let I=this.client.session.get(o),M=await this.getVerifyContext({attestationId:d,hash:pr(JSON.stringify(br("wc_sessionRequest",S,y))),encryptedId:h,metadata:I.peer.metadata,transportType:b}),T={id:y,topic:o,params:S,verifyContext:M};await this.setPendingSessionRequest(T),b===$e.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(T):(this.addSessionRequestToSessionRequestQueue(T),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Oe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,f=ki.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(tt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),ki.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:f,transportType:d}=t;try{let{requester:h,authPayload:b,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:pr(JSON.stringify(s)),encryptedId:f,metadata:h.metadata,transportType:d}),I={requester:h,pairingTopic:n,id:s.id,authPayload:b,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:d}),d===$e.link_mode&&(i=h.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(h){this.client.logger.error(h);let b=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,d),I={type:lr,receiverPublicKey:b,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:h,encodeOpts:I,rpcOpts:dt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=si.idle,this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,f=Oe("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Oe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===si.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=si.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:br("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Mt(t)){let{message:d}=X("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(d)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(vt(i)||await this.isValidPairingTopic(i),!tv(f,!0)){let{message:d}=X("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(d)}!vt(n)&&No(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!vt(s)&&No(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),vt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=ev(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Mt(t))throw new Error(X("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let f=this.client.proposal.get(i),d=Tf(n,"approve()");if(d)throw new Error(d.message);let h=Vu(f.requiredNamespaces,n,"approve()");if(h)throw new Error(h.message);if(!Ye(s,!0)){let{message:b}=X("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}vt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Mt(t)){let{message:s}=X("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!iv(n)){let{message:s}=X("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Mt(t)){let{message:h}=X("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(h)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Ku(i)){let{message:h}=X("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(h)}let f=Zb(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);let d=Tf(s,"onSessionSettleRequest()");if(d)throw new Error(d.message);if(Xr(o)){let{message:h}=X("EXPIRED","onSessionSettleRequest()");throw new Error(h)}},this.isValidUpdate=async t=>{if(!Mt(t)){let{message:d}=X("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(d)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=Tf(n,"update()");if(o)throw new Error(o.message);let f=Vu(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Mt(t)){let{message:d}=X("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(d)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:f}=this.client.session.get(i);if(!ju(f,s)){let{message:d}=X("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(d)}if(!nv(n)){let{message:d}=X("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(d)}if(!av(f,s,n.method)){let{message:d}=X("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(d)}if(o&&!cv(o,Ud)){let{message:d}=X("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Ud.min} and ${Ud.max}`);throw new Error(d)}},this.isValidRespond=async t=>{var i;if(!Mt(t)){let{message:o}=X("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!sv(s)){let{message:o}=X("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Mt(t)){let{message:f}=X("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!ju(o,s)){let{message:f}=X("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!ov(n)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!fv(o,s,n.name)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Ye(n,!1))throw new Error("uri is required parameter");if(!Ye(s,!1))throw new Error("domain is required parameter");if(!Ye(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(d=>So(d).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:f}=So(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,d={verified:{verifyUrl:o.verifyUrl||Os,validation:"UNKNOWN",origin:o.url||""}};try{if(f===$e.link_mode){let b=this.getAppLinkIfEnabled(o,f);return d.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",d}let h=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});h&&(d.verified.origin=h.origin,d.verified.isScam=h.isScam,d.verified.validation=h.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.warn(h)}return this.client.logger.debug(`Verify context: ${JSON.stringify(d)}`),d},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!Ye(n,!1)){let{message:s}=X("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,d,h,b,y,S;return!t||i!==$e.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((h=(d=this.client.metadata)==null?void 0:d.redirect)==null?void 0:h.universal)!==""&&((b=t?.redirect)==null?void 0:b.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof window?.Linking<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=Au(t,"topic")||"",n=decodeURIComponent(Au(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:$e.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Ao()||Tn()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=window?.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Tt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(ec)?this.client.auth.authKeys.get(ec):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===$e.link_mode?Es:Zr});try{Ds(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:pr(i)})):Hi(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(d){this.client.logger.error(d)}}registerExpirerEvents(){this.client.core.expirer.on(Kt.expired,async e=>{let{topic:t,id:i}=If(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,X("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,X("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Ji.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Ji.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=X("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=X("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=X("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Ye(e,!1)){let{message:t}=X("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=X("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!rv(e)){let{message:t}=X("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=X("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},Bd=class extends ni{constructor(e,t){super(e,t,j7,Gd),this.core=e,this.logger=t}},kd=class extends ni{constructor(e,t){super(e,t,$7,Gd),this.core=e,this.logger=t}},Kd=class extends ni{constructor(e,t){super(e,t,G7,Gd,i=>i.id),this.core=e,this.logger=t}},jd=class extends ni{constructor(e,t){super(e,t,X7,ic,()=>ec),this.core=e,this.logger=t}},Vd=class extends ni{constructor(e,t){super(e,t,Z7,ic),this.core=e,this.logger=t}},$d=class extends ni{constructor(e,t){super(e,t,Q7,ic,i=>i.id),this.core=e,this.logger=t}},Hd=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new jd(this.core,this.logger),this.pairingTopics=new Vd(this.core,this.logger),this.requests=new $d(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},tc=class r extends Ia{constructor(e){super(e),this.protocol=ey,this.version=ty,this.name=qd.name,this.events=new rc.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||qd.name,this.metadata=e?.metadata||xs(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,Hs.default)(Ws({level:e?.logger||qd.logger}));this.core=e?.core||new Ym(e),this.logger=lt(t,this.name),this.session=new kd(this.core,this.logger),this.proposal=new Bd(this.core,this.logger),this.pendingRequest=new Kd(this.core,this.logger),this.engine=new zd(this),this.auth=new Hd(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return yt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var iy=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],wr="mvx";var Ho=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);function Wd(r){return r[Math.floor(Math.random()*r.length)]}var ny="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Jd=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;ti.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Si(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=Xd(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function sy(r){return!!r}function Zd(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function Qd({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,f=r.guardian;if(f&&f!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=Jd(t),i&&(r.guardianSignature=Jd(i)),r}function oy(r){if(r)return{...r,url:xs().url}}async function ay(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var oi=class{constructor(e,t,i,n,s,o,f,d){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.Message=s,this.Transaction=o,this.TransactionsConverter=f,this.options=d}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:oy(this.options?.metadata)}:{},t=await tc.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=Yd(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await ay(500);let i=Zd(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Si(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:Ue("USER_DISCONNECTED")});else{let t=Si(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:Ue("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return Qd({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];Qd({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Si(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Si(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?sy(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=Zd(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&Si(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=Xd(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!Ki(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var Fn=(r=>(r[r.Border=-1]="Border",r[r.Data=0]="Data",r[r.Function=1]="Function",r[r.Position=2]="Position",r[r.Timing=3]="Timing",r[r.Alignment=4]="Alignment",r))(Fn||{}),aS=Object.defineProperty,fS=(r,e,t)=>e in r?aS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nc=(r,e,t)=>(fS(r,typeof e!="symbol"?e+"":e,t),t),cS=[0,1],cy=[1,0],hy=[2,3],uy=[3,2],hS={L:cS,M:cy,Q:hy,H:uy},uS=/^[0-9]*$/,dS=/^[A-Z0-9 $%*+.\/:-]*$/,el="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",nl=1,sl=40,fy=3,lS=3,sc=40,pS=10,dy=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],ly=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],tl=class{constructor(e,t,i,n){if(this.version=e,this.ecc=t,nc(this,"size"),nc(this,"mask"),nc(this,"modules",[]),nc(this,"types",[]),esl)throw new RangeError("Version value out of range");if(n<-1||n>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let s=Array.from({length:this.size},()=>!1);for(let f=0;f0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(i);if(this.drawCodewords(o),n===-1){let f=1e9;for(let d=0;d<8;d++){this.applyMask(d),this.drawFormatBits(d);let h=this.getPenaltyScore();h=0&&e=0&&t>>9)*1335;let n=(t<<10|i)^21522;for(let s=0;s<=5;s++)this.setFunctionModule(8,s,Ii(n,s));this.setFunctionModule(8,7,Ii(n,6)),this.setFunctionModule(8,8,Ii(n,7)),this.setFunctionModule(7,8,Ii(n,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,Ii(n,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,Ii(n,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,Ii(n,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let i=0;i<12;i++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let i=0;i<18;i++){let n=Ii(t,i),s=this.size-11+i%3,o=Math.floor(i/3);this.setFunctionModule(s,o,n),this.setFunctionModule(o,s,n)}}drawFinderPattern(e,t){for(let i=-4;i<=4;i++)for(let n=-4;n<=4;n++){let s=Math.max(Math.abs(n),Math.abs(i)),o=e+n,f=t+i;o>=0&&o=0&&f{(S!==d-s||M>=f)&&y.push(I[S])});return y}drawCodewords(e){if(e.length!==Math.floor(rl(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let i=this.size-1;i>=1;i-=2){i===6&&(i=5);for(let n=0;n>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(f,d),o||(e+=this.finderPenaltyCountPatterns(d)*sc),o=this.modules[s][h],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,d)*sc}for(let s=0;s5&&e++):(this.finderPenaltyAddHistory(f,d),o||(e+=this.finderPenaltyCountPatterns(d)*sc),o=this.modules[h][s],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,d)*sc}for(let s=0;so+(f?1:0),t);let i=this.size*this.size,n=Math.ceil(Math.abs(t*20-i*10)/i)-1;return e+=n*pS,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,i=[6];for(let n=this.size-7;i.length0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(i&&e[0]>=t*4&&e[6]>=t?1:0)+(i&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,i){return e&&(this.finderPenaltyAddHistory(t,i),t=0),t+=this.size,this.finderPenaltyAddHistory(t,i),this.finderPenaltyCountPatterns(i)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Mi(r,e,t){if(e<0||e>31||r>>>e)throw new RangeError("Value out of range");for(let i=e-1;i>=0;i--)t.push(r>>>i&1)}function Ii(r,e){return(r>>>e&1)!==0}var Go=class{constructor(e,t,i){if(this.mode=e,this.numChars=t,this.bitData=i,t<0)throw new RangeError("Invalid argument");this.bitData=i.slice()}getData(){return this.bitData.slice()}},gS=[1,10,12,14],bS=[2,9,11,13],vS=[4,8,16,16];function py(r,e){return r[Math.floor((e+7)/17)+1]}function gy(r){let e=[];for(let t of r)Mi(t,8,e);return new Go(vS,r.length,e)}function mS(r){if(!by(r))throw new RangeError("String contains non-numeric characters");let e=[];for(let t=0;t=1<sl)throw new RangeError("Version number out of range");let e=(16*r+128)*r+64;if(r>=2){let t=Math.floor(r/7)+2;e-=(25*t-10)*t-55,r>=7&&(e-=36)}return e}function oc(r,e){return Math.floor(rl(r)/8)-dy[e[0]][r]*ly[e[0]][r]}function ES(r){if(r<1||r>255)throw new RangeError("Degree out of range");let e=[];for(let i=0;i0);for(let i of r){let n=i^t.shift();t.push(0),e.forEach((s,o)=>t[o]^=il(s,n))}return t}function il(r,e){if(r>>>8||e>>>8)throw new RangeError("Byte out of range");let t=0;for(let i=7;i>=0;i--)t=t<<1^(t>>>7)*285,t^=(e>>>i&1)*r;return t}function IS(r,e,t=1,i=40,n=-1,s=!0){if(!(nl<=t&&t<=i&&i<=sl)||n<-1||n>7)throw new RangeError("Invalid value");let o,f;for(o=t;;o++){let y=oc(o,e)*8,S=_S(r,o);if(S<=y){f=S;break}if(o>=i)throw new RangeError("Data too long")}for(let y of[cy,hy,uy])s&&f<=oc(o,y)*8&&(e=y);let d=[];for(let y of r){Mi(y.mode[0],4,d),Mi(y.numChars,py(y.mode,o),d);for(let S of y.getData())d.push(S)}let h=oc(o,e)*8;Mi(0,Math.min(4,h-d.length),d),Mi(0,(8-d.length%8)%8,d);for(let y=236;d.length0);return d.forEach((y,S)=>b[S>>>3]|=y<<7-(S&7)),new tl(o,e,b,n)}function MS(r,e){let{ecc:t="L",boostEcc:i=!1,minVersion:n=1,maxVersion:s=40,maskPattern:o=-1,border:f=1}=e||{},d=typeof r=="string"?wS(r):Array.isArray(r)?[gy(r)]:void 0;if(!d)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof r}`);let h=IS(d,hS[t],n,s,o,i),b=AS({version:h.version,maskPattern:h.mask,size:h.size,data:h.modules,types:h.types},f);return e?.invert&&(b.data=b.data.map(y=>y.map(S=>!S))),e?.onEncoded?.(b),b}function AS(r,e=1){if(!e)return r;let{size:t}=r,i=t+e*2;r.size=i,r.data.forEach(s=>{for(let o=0;o!1)),r.data.push(Array.from({length:i},o=>!1));let n=Fn.Border;r.types.forEach(s=>{for(let o=0;on)),r.types.push(Array.from({length:i},o=>n));return r}function my(r,e={}){let t=MS(r,e),{pixelSize:i=10,whiteColor:n="white",blackColor:s="black"}=e,o=t.size*i,f=t.size*i,d=``,h=[];for(let b=0;b`,d+=``,d+="",d}var TS=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},DS=r=>{let e=`${ny}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},PS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},NS=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},ol={},CS=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",ol[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:ol[r.topic].signal}),t},ac={},OS=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=CS(r,e);return i.appendChild(s),ac[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:ac[r.topic].signal}),i},LS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},FS=r=>{if(!r)return;document.getElementById(r)?.remove()},qS=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),US=r=>r?my(r):void 0,yy=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=US(e),o;if(s&&(o=TS(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),qS()&&n.appendChild(DS(e))),n&&t instanceof oi){let f=t.pairings,d=async b=>{try{b&&(await t.logout({topic:b}),FS(b))}catch(y){let S=Ho(y);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{ac[b].abort()}},h=async b=>{try{let{approval:y}=await t.connect({topic:b,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(b)?.after(LS()),await t.login({approval:y,token:i})}catch(y){let S=Ho(y);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let y of Object.values(ac))y?.abort();for(let y of Object.values(ol))y?.abort()}};if(f&&f.length>0){let b=PS();n.appendChild(b);let y=NS();b.appendChild(y);for(let S of f){let I=OS(S,d,h);b.appendChild(I)}}}return n};var wy=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:t,qrCodeContainer:i}){this.WalletConnectV2Provider=oi;this.initMobileProvider=async(e,t,i,n,s,o)=>{if(!this.walletConnectV2ProjectId||!e.initOptions.chainType)return;let f={onClientLogin:()=>{},onClientLogout:()=>t(e),onClientEvent:b=>{console.log("wc2 session event: ",b)}},d=Wd(this.walletConnectV2RelayAddresses),h=new oi(f,i[e.initOptions.chainType].shortId,d,this.walletConnectV2ProjectId,n,s,o);try{return await h.init(),h}catch{console.warn("Can't initialize the Dapp Provider!");return}};this.loginWithMobile=async(e,t,i,n,s,o,f,d,h,b,y,S)=>{if(!this.qrCodeContainer)throw new Error("You haven't provided the QR code container DOM element id");let I=Wd(this.walletConnectV2RelayAddresses);if(!I||!e.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!this.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!e.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let M,T={onClientLogin:async()=>{if(e.dappProvider instanceof oi){let P=e.dappProvider.getAddress(),U=e.dappProvider.getSignature();if(n.set("address",P),n.set("loginMethod","mobile"),n.set("expires",o()),await f(e),U){n.set("signature",U),n.set("loginToken",t);let B=i.getToken(P,t,U);n.set("accessToken",B),d.run("onLoginSuccess"),M?.replaceChildren()}}},onClientLogout:async()=>{e.dappProvider instanceof oi&&await s(e)},onClientEvent:P=>{console.log("wc2 session event: ",P)}},C=new oi(T,h[e.initOptions.chainType].shortId,I,this.walletConnectV2ProjectId,b,y,S);try{if(C){e.dappProvider=C,d.run("onQrPending"),await C.init();let{uri:P,approval:U}=await C.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),B=t?`${P}&token=${t}`:P;return this.qrCodeContainer&&B&&(M=await yy(this.qrCodeContainer,B,C,t),d.run("onQrLoaded")),await C.login({approval:U,token:t}),C}}catch(P){let U=Ho(P);console.warn(`Something went wrong trying to login the user: ${U}`),d.run("onLoginFailure",U)}};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=t,this.qrCodeContainer=i}};export{wy as MobileSigningProvider}; + Approved: ${f.toString()}`)),Object.keys(e).forEach(v=>{if(!v.includes(":")||i)return;let S=Rs(e[v].accounts);S.includes(v)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${v} + Required: ${v} + Approved: ${S.toString()}`))}),o.forEach(v=>{i||(An(n[v].methods,s[v].methods)?An(n[v].events,s[v].events)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${v}`)):i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${v}`))}),i}function T_(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function wb(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function D_(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Rs(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function cv(r,e){return ku(r,!1)&&r<=e.max&&r>=e.min}function $u(){let r=Mo();return new Promise(e=>{switch(r){case Ft.browser:e(P_());break;case Ft.reactNative:e(N_());break;case Ft.node:e(C_());break;default:e(!0)}})}function P_(){return _s()&&navigator?.onLine}async function N_(){return Tn()&&typeof window<"u"&&window!=null&&window.NetInfo?(await window?.NetInfo.fetch())?.isConnected:!0}function C_(){return!0}function hv(r){switch(Mo()){case Ft.browser:O_(r);break;case Ft.reactNative:L_(r);break;case Ft.node:break}}function O_(r){!Tn()&&_s()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function L_(r){Tn()&&typeof window<"u"&&window!=null&&window.NetInfo&&window?.NetInfo.addEventListener(e=>r(e?.isConnected))}var xu={},Ki=class{static get(e){return xu[e]}static set(e,t){xu[e]=t}static delete(e){delete xu[e]}};var Mv=qe(un());var Rt={};Dt(Rt,{DEFAULT_ERROR:()=>Oo,IBaseJsonRpcProvider:()=>Uf,IEvents:()=>Lo,IJsonRpcConnection:()=>Yu,IJsonRpcProvider:()=>Fo,INTERNAL_ERROR:()=>Df,INVALID_PARAMS:()=>pv,INVALID_REQUEST:()=>dv,METHOD_NOT_FOUND:()=>lv,PARSE_ERROR:()=>uv,RESERVED_ERROR_CODES:()=>Hu,SERVER_ERROR:()=>Co,SERVER_ERROR_CODE_RANGE:()=>Pf,STANDARD_ERROR_MAP:()=>Vi,formatErrorMessage:()=>Sv,formatJsonRpcError:()=>Pn,formatJsonRpcRequest:()=>br,formatJsonRpcResult:()=>Ts,getBigIntRpcId:()=>gr,getError:()=>Cf,getErrorByCode:()=>Of,isHttpUrl:()=>H_,isJsonRpcError:()=>At,isJsonRpcPayload:()=>Zu,isJsonRpcRequest:()=>Ds,isJsonRpcResponse:()=>Gi,isJsonRpcResult:()=>kt,isJsonRpcValidationInvalid:()=>G_,isLocalhostUrl:()=>Xu,isNodeJs:()=>Ev,isReservedErrorCode:()=>Nf,isServerErrorCode:()=>F_,isValidDefaultRoute:()=>Ff,isValidErrorCode:()=>gv,isValidLeadingWildcardRoute:()=>k_,isValidRoute:()=>B_,isValidTrailingWildcardRoute:()=>K_,isValidWildcardRoute:()=>qf,isWsUrl:()=>zf,parseConnectionError:()=>Gu,payloadId:()=>Qr,validateJsonRpcError:()=>q_});var uv="PARSE_ERROR",dv="INVALID_REQUEST",lv="METHOD_NOT_FOUND",pv="INVALID_PARAMS",Df="INTERNAL_ERROR",Co="SERVER_ERROR",Hu=[-32700,-32600,-32601,-32602,-32603],Pf=[-32e3,-32099],Vi={[uv]:{code:-32700,message:"Parse error"},[dv]:{code:-32600,message:"Invalid Request"},[lv]:{code:-32601,message:"Method not found"},[pv]:{code:-32602,message:"Invalid params"},[Df]:{code:-32603,message:"Internal error"},[Co]:{code:-32e3,message:"Server error"}},Oo=Co;function F_(r){return r<=Pf[0]&&r>=Pf[1]}function Nf(r){return Hu.includes(r)}function gv(r){return typeof r=="number"}function Cf(r){return Object.keys(Vi).includes(r)?Vi[r]:Vi[Oo]}function Of(r){let e=Object.values(Vi).find(t=>t.code===r);return e||Vi[Oo]}function q_(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!gv(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(Nf(r.error.code)){let e=Of(r.error.code);if(e.message!==Vi[Oo].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Gu(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var Nt={};Dt(Nt,{isNodeJs:()=>Ev});var xv=qe(Ju());qt(Nt,qe(Ju()));var Ev=xv.isNode;qt(Rt,Nt);function Qr(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function gr(r=6){return BigInt(Qr(r))}function br(r,e,t){return{id:t||Qr(),jsonrpc:"2.0",method:r,params:e}}function Ts(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Pn(r,e,t){return{id:r,jsonrpc:"2.0",error:Sv(e,t)}}function Sv(r,e){return typeof r>"u"?Cf(Df):(typeof r=="string"&&(r=Object.assign(Object.assign({},Cf(Co)),{message:r})),typeof e<"u"&&(r.data=e),Nf(r.code)&&(r=Of(r.code)),r)}function B_(r){return r.includes("*")?qf(r):!/\W/g.test(r)}function Ff(r){return r==="*"}function qf(r){return Ff(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function k_(r){return!Ff(r)&&qf(r)&&!r.split("*")[0].trim()}function K_(r){return!Ff(r)&&qf(r)&&!r.split("*")[1].trim()}var Lo=class{},Yu=class extends Lo{constructor(e){super()}},Uf=class extends Lo{constructor(){super()}},Fo=class extends Uf{constructor(e){super()}};var j_="^https?:",V_="^wss?:";function $_(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Iv(r,e){let t=$_(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function H_(r){return Iv(r,j_)}function zf(r){return Iv(r,V_)}function Xu(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function Zu(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Ds(r){return Zu(r)&&"method"in r}function Gi(r){return Zu(r)&&(kt(r)||At(r))}function kt(r){return"result"in r}function At(r){return"error"in r}function G_(r){return"error"in r&&r.valid===!1}var Bf=class extends Fo{constructor(e){super(e),this.events=new Mv.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(br(e.method,e.params||[],e.id||gr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{At(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Gi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Pv=qe(un());var W_=()=>typeof WebSocket<"u"?WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Rv(),J_=()=>typeof WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Tv=r=>r.split("?")[0],Dv=10,Y_=W_(),kf=class{constructor(e){if(this.url=e,this.events=new Pv.EventEmitter,this.registering=!1,!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Wt(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Rt.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Xu(e)},o=new Y_(e,[],s);J_()?o.onerror=f=>{let u=f;i(this.emitError(u.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?Fr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=Pn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Gu(e,Tv(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Dv&&this.events.setMaxListeners(Dv)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Tv(this.url)}`));return this.events.emit("register_error",t),t}};var Om=qe(dm()),Lm=qe(za()),Fm="wc",qm=2,Ld="core",ii=`${Fm}@2:${Ld}:`,AE={name:Ld,logger:"error"},RE={database:":memory:"},TE="crypto",lm="client_ed25519_seed",DE=re.ONE_DAY,PE="keychain",NE="0.3",CE="messages",OE="0.3",LE=re.SIX_HOURS,FE="publisher",Fd="irn",qE="error",Um="wss://relay.walletconnect.org",UE="relayer",Tt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},zE="_subscription",rr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},BE=.1;var dd="2.17.2";var $e={link_mode:"link_mode",relay:"relay"},kE="0.3",KE="WALLETCONNECT_CLIENT_ID",pm="WALLETCONNECT_LINK_MODE_APPS",ti={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var jE="subscription",VE="0.3",$E=re.FIVE_SECONDS*1e3,HE="pairing",GE="0.3";var Ko={wc_pairingDelete:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:re.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:re.ONE_DAY,prompt:!1,tag:0},res:{ttl:re.ONE_DAY,prompt:!1,tag:0}}},Yi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},vr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},WE="history",JE="0.3",YE="expirer",Kt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},XE="0.3";var ZE="verify-api",QE="https://verify.walletconnect.com",zm="https://verify.walletconnect.org",Os=zm,e9=`${Os}/v3`,t9=[QE,zm],r9="echo",i9="https://echo.walletconnect.com";var mr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ri={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ir={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Xi={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Zi={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Ls={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},n9=.1,s9="event-client",o9=86400,a9="https://pulse.walletconnect.org/batch";function f9(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(B);P!==z;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var c9=f9,h9=c9,Bm=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},u9=r=>new TextEncoder().encode(r),d9=r=>new TextDecoder().decode(r),ld=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},pd=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return km(this,e)}},gd=class{constructor(e){this.decoders=e}or(e){return km(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},km=(r,e)=>new gd({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),bd=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ld(e,t,i),this.decoder=new pd(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Qf=({name:r,prefix:e,encode:t,decode:i})=>new bd(r,e,t,i),$o=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=h9(t,e);return Qf({prefix:r,name:e,encode:i,decode:s=>Bm(n(s))})},l9=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[c++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},p9=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Qf({prefix:e,name:r,encode(n){return p9(n,i,t)},decode(n){return l9(n,i,t,r)}}),g9=Qf({prefix:"\0",name:"identity",encode:r=>d9(r),decode:r=>u9(r)}),b9=Object.freeze({__proto__:null,identity:g9}),v9=mt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),m9=Object.freeze({__proto__:null,base2:v9}),y9=mt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),w9=Object.freeze({__proto__:null,base8:y9}),_9=$o({prefix:"9",name:"base10",alphabet:"0123456789"}),x9=Object.freeze({__proto__:null,base10:_9}),E9=mt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),S9=mt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),I9=Object.freeze({__proto__:null,base16:E9,base16upper:S9}),M9=mt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),A9=mt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),R9=mt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),T9=mt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),D9=mt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),P9=mt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),N9=mt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),C9=mt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),O9=mt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),L9=Object.freeze({__proto__:null,base32:M9,base32upper:A9,base32pad:R9,base32padupper:T9,base32hex:D9,base32hexupper:P9,base32hexpad:N9,base32hexpadupper:C9,base32z:O9}),F9=$o({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),q9=$o({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),U9=Object.freeze({__proto__:null,base36:F9,base36upper:q9}),z9=$o({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),B9=$o({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),k9=Object.freeze({__proto__:null,base58btc:z9,base58flickr:B9}),K9=mt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j9=mt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V9=mt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$9=mt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),H9=Object.freeze({__proto__:null,base64:K9,base64pad:j9,base64url:V9,base64urlpad:$9}),Km=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),G9=Km.reduce((r,e,t)=>(r[t]=e,r),[]),W9=Km.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function J9(r){return r.reduce((e,t)=>(e+=G9[t],e),"")}function Y9(r){let e=[];for(let t of r){let i=W9[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var X9=Qf({prefix:"\u{1F680}",name:"base256emoji",encode:J9,decode:Y9}),Z9=Object.freeze({__proto__:null,base256emoji:X9}),Q9=jm,gm=128,e7=127,t7=~e7,r7=Math.pow(2,31);function jm(r,e,t){e=e||[],t=t||0;for(var i=t;r>=r7;)e[t++]=r&255|gm,r/=128;for(;r&t7;)e[t++]=r&255|gm,r>>>=7;return e[t]=r|0,jm.bytes=t-i+1,e}var i7=vd,n7=128,bm=127;function vd(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw vd.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&bm)<=n7);return vd.bytes=s-i,t}var s7=Math.pow(2,7),o7=Math.pow(2,14),a7=Math.pow(2,21),f7=Math.pow(2,28),c7=Math.pow(2,35),h7=Math.pow(2,42),u7=Math.pow(2,49),d7=Math.pow(2,56),l7=Math.pow(2,63),p7=function(r){return r(Vm.encode(r,e,t),e),mm=r=>Vm.encodingLength(r),md=(r,e)=>{let t=e.byteLength,i=mm(r),n=i+mm(t),s=new Uint8Array(n+t);return vm(r,s,0),vm(t,s,i),s.set(e,n),new yd(r,t,e,s)},yd=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},$m=({name:r,code:e,encode:t})=>new wd(r,e,t),wd=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?md(this.code,t):t.then(i=>md(this.code,i))}else throw Error("Unknown type, must be binary type")}},Hm=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),b7=$m({name:"sha2-256",code:18,encode:Hm("SHA-256")}),v7=$m({name:"sha2-512",code:19,encode:Hm("SHA-512")}),m7=Object.freeze({__proto__:null,sha256:b7,sha512:v7}),Gm=0,y7="identity",Wm=Bm,w7=r=>md(Gm,Wm(r)),_7={code:Gm,name:y7,encode:Wm,digest:w7},x7=Object.freeze({__proto__:null,identity:_7});new TextEncoder,new TextDecoder;var ym={...b9,...m9,...w9,...x9,...I9,...L9,...U9,...k9,...H9,...Z9};({...m7,...x7});function E7(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Jm(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var wm=Jm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),hd=Jm("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=E7(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=X("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},xd=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=TE,this.randomSessionIdentifier=Af(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=_h(n);return Ua(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=Ub();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=_h(s),f=this.randomSessionIdentifier;return await fp(f,n,DE,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let f=this.getPrivateKey(n),u=zb(f,s);return this.setSymKey(u,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||Is(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let f=Lu(o),u=Wt(s);if(qu(f))return Kb(u,o?.encoding);if(Fu(f)){let S=f.senderPublicKey,I=f.receiverPublicKey;n=await this.generateSharedKey(S,I)}let c=this.getSymKey(n),{type:b,senderPublicKey:v}=f;return kb({type:b,symKey:c,message:u,senderPublicKey:v,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let f=Hb(s,o);if(qu(f)){let u=Vb(s,o?.encoding);return Fr(u)}if(Fu(f)){let u=f.receiverPublicKey,c=f.senderPublicKey;n=await this.generateSharedKey(u,c)}try{let u=this.getSymKey(n),c=jb({symKey:u,encoded:s,encoding:o?.encoding});return Fr(c)}catch(u){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}},this.getPayloadType=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return ki(o.type)},this.getPayloadSenderPublicKey=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return o.senderPublicKey?Ze(o.senderPublicKey,It):void 0},this.core=e,this.logger=lt(t,this.name),this.keychain=i||new _d(this.core,this.logger)}get context(){return yt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(lm)}catch{e=Af(),await this.keychain.set(lm,e)}return I7(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Ed=class extends ba{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=CE,this.version=OE,this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=pr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=pr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=lt(e,this.name),this.core=t}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Sd=class extends va{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Si.EventEmitter,this.name=FE,this.queue=new Map,this.publishTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.failedPublishTimeout=(0,re.toMiliseconds)(re.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let f=s?.ttl||LE,u=Rf(s),c=s?.prompt||!1,b=s?.tag||0,v=s?.id||gr().toString(),S={topic:i,message:n,opts:{ttl:f,relay:u,prompt:c,tag:b,id:v,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${v} tag:${b}`,M=Date.now(),T,O=1;try{for(;T===void 0;){if(Date.now()-M>this.publishTimeout)throw new Error(I);this.logger.trace({id:v,attempts:O},`publisher.publish - attempt ${O}`),T=await await Dn(this.rpcPublish(i,n,f,u,c,b,v,s?.attestation).catch(P=>this.logger.warn(P)),this.publishTimeout,I),O++,T||await new Promise(P=>setTimeout(P,this.failedPublishTimeout))}this.relayer.events.emit(Tt.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:v,topic:i,message:n,opts:s}})}catch(P){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(P),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw P;this.queue.set(v,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=lt(t,this.name),this.registerEventListeners()}get context(){return yt(this.logger)}rpcPublish(e,t,i,n,s,o,f,u){var c,b,v,S;let I={method:As(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:u},id:f};return vt((c=I.params)==null?void 0:c.prompt)&&((b=I.params)==null||delete b.prompt),vt((v=I.params)==null?void 0:v.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(dn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Tt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Tt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Id=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},M7=Object.defineProperty,A7=Object.defineProperties,R7=Object.getOwnPropertyDescriptors,_m=Object.getOwnPropertySymbols,T7=Object.prototype.hasOwnProperty,D7=Object.prototype.propertyIsEnumerable,xm=(r,e,t)=>e in r?M7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jo=(r,e)=>{for(var t in e||(e={}))T7.call(e,t)&&xm(r,t,e[t]);if(_m)for(var t of _m(e))D7.call(e,t)&&xm(r,t,e[t]);return r},ud=(r,e)=>A7(r,R7(e)),Md=class extends wa{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Id,this.events=new Si.EventEmitter,this.name=jE,this.version=VE,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ii,this.subscribeTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=Rf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let f=new re.Watch;f.start(n);let u=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(u),f.stop(n),s(!0)),f.elapsed(n)>=$E&&(clearInterval(u),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=lt(t,this.name),this.clientId=""}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=Rf(i);await this.rpcUnsubscribe(e,t,n);let s=Ue("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===$e.relay&&await this.restartToComplete();let s={method:As(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let f=pr(e+this.clientId);if(i?.transportType===$e.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(c=>this.logger.warn(c))},(0,re.toMiliseconds)(re.ONE_SECOND)),f;let u=await Dn(this.relayer.request(s).catch(c=>this.logger.warn(c)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!u&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return u?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Tt.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Dn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Dn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:As(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,ud(jo({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,jo({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,jo({},t)),this.topicMap.set(t.topic,e),this.events.emit(ti.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(ti.deleted,ud(jo({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ti.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);ji(t)&&this.onBatchSubscribe(t.map((i,n)=>ud(jo({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(dn.pulse,async()=>{await this.checkPending()}),this.events.on(ti.created,async e=>{let t=ti.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(ti.deleted,async e=>{let t=ti.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},P7=Object.defineProperty,Em=Object.getOwnPropertySymbols,N7=Object.prototype.hasOwnProperty,C7=Object.prototype.propertyIsEnumerable,Sm=(r,e,t)=>e in r?P7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Im=(r,e)=>{for(var t in e||(e={}))N7.call(e,t)&&Sm(r,t,e[t]);if(Em)for(var t of Em(e))C7.call(e,t)&&Sm(r,t,e[t]);return r},Ad=class extends ma{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Si.EventEmitter,this.name=UE,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,re.toMiliseconds)(re.THIRTY_SECONDS+re.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||gr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let f=await new Promise(async(u,c)=>{let b=()=>{c(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(rr.disconnect,b);let v=await o;this.provider.off(rr.disconnect,b),u(v)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Io())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Tt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Tt.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(rr.payload,this.onPayloadHandler),this.provider.on(rr.connect,this.onConnectHandler),this.provider.on(rr.disconnect,this.onDisconnectHandler),this.provider.on(rr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?lt(e.logger,this.name):(0,Hs.default)(Ws({level:e.logger||qE})),this.messages=new Ed(this.logger,e.core),this.subscriber=new Md(this,this.logger),this.publisher=new Sd(this,this.logger),this.relayUrl=e?.relayUrl||Um,this.projectId=e.projectId,this.bundleId=Ib(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return yt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:$e.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",u,c=b=>{b.topic===e&&(this.subscriber.off(ti.created,c),u())};return await Promise.all([new Promise(b=>{u=b,this.subscriber.on(ti.created,c)}),new Promise(async(b,v)=>{f=await this.subscriber.subscribe(e,Im({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&v(S)})||f,b()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Dn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(rr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(rr.disconnect,n),await Dn(this.provider.connect(),(0,re.toMiliseconds)(re.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await $u())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=st(re.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Tt.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Io())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Bf(new kf(Mb({sdkVersion:dd,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Ds(e)){if(!e.method.endsWith(zE))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:$e.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Im({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Gi(e)&&this.events.emit(Tt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Tt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=Ts(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(rr.payload,this.onPayloadHandler),this.provider.off(rr.connect,this.onConnectHandler),this.provider.off(rr.disconnect,this.onDisconnectHandler),this.provider.off(rr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await $u();hv(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Tt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,re.toMiliseconds)(BE))))}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},O7=Object.defineProperty,Mm=Object.getOwnPropertySymbols,L7=Object.prototype.hasOwnProperty,F7=Object.prototype.propertyIsEnumerable,Am=(r,e,t)=>e in r?O7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rm=(r,e)=>{for(var t in e||(e={}))L7.call(e,t)&&Am(r,t,e[t]);if(Mm)for(var t of Mm(e))F7.call(e,t)&&Am(r,t,e[t]);return r},ni=class extends ya{constructor(e,t,i,n=ii,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=kE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!vt(o)?this.map.set(this.getKey(o),o):Yb(o)?this.map.set(o.id,o):Xb(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(u=>(0,Om.default)(f[u],o[u]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});let u=Rm(Rm({},this.getData(o)),f);this.map.set(o,u),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=lt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Rd=class{constructor(e,t){this.core=e,this.logger=t,this.name=HE,this.version=GE,this.events=new Si.default,this.initialized=!1,this.storagePrefix=ii,this.ignoredPayloadTypes=[lr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=Af(),s=await this.core.crypto.setSymKey(n),o=st(re.FIVE_MINUTES),f={protocol:Fd},u={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},c=zu({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Yi.create,u),this.core.expirer.set(s,o),await this.pairings.set(s,u),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:c}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[mr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:f,expiryTimestamp:u,methods:c}=Uu(i.uri);n.props.properties.topic=s,n.addTrace(mr.pairing_uri_validation_success),n.addTrace(mr.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(mr.existing_pairing),b.active)throw n.setError(ri.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(mr.pairing_not_expired)}let v=u||st(re.FIVE_MINUTES),S={topic:s,relay:f,expiry:v,active:!1,methods:c};this.core.expirer.set(s,v),await this.pairings.set(s,S),n.addTrace(mr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Yi.create,S),n.addTrace(mr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(mr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ri.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(I){throw n.setError(ri.subscribe_pairing_topic_failure),I}return n.addTrace(mr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=st(re.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:u}=_i();this.events.once(Oe("pairing_ping",s),({error:c})=>{c?u(c):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Ue("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:f}=i,u=this.core.crypto.keychain.get(n);return zu({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:u,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{let o=br(n,s),f=await this.core.crypto.encode(i,o),u=Ko[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,u),o.id},this.sendResult=async(i,n,s)=>{let o=Ts(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),c=Ko[u.request.method].res;await this.core.relayer.publish(n,f,c),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=Pn(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),c=Ko[u.request.method]?Ko[u.request.method].res:Ko.unregistered_method.res;await this.core.relayer.publish(n,f,c),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Ue("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>Xr(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Yi.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{kt(n)?this.events.emit(Oe("pairing_ping",s),{}):At(n)&&this.events.emit(Oe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Yi.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let f=Ue("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Ue("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Mt(i)){let{message:f}=X("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!Jb(i.uri)){let{message:f}=X("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}let o=Uu(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&(0,re.toMiliseconds)(o?.expiryTimestamp){if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!Ye(i,!1)){let{message:n}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Xr(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=X("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=lt(t,this.name),this.pairings=new ni(this.core,this.logger,this.name,this.storagePrefix)}get context(){return yt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Tt.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===$e.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{Ds(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Gi(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Kt.expired,async e=>{let{topic:t}=If(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Yi.expire,{topic:t}))})}},Td=class extends ga{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Si.EventEmitter,this.name=WE,this.version=JE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:st(re.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(vr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=At(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(vr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(vr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:br(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(vr.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(vr.created,e=>{let t=vr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.updated,e=>{let t=vr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.deleted,e=>{let t=vr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(dn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,re.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(vr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Dd=class extends _a{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Si.EventEmitter,this.name=YE,this.version=XE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Kt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Kt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Rb(e);if(typeof e=="number")return Tb(e);let{message:t}=X("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Kt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,re.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Kt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(dn.pulse,()=>this.checkExpirations()),this.events.on(Kt.created,e=>{let t=Kt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.expired,e=>{let t=Kt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.deleted,e=>{let t=Kt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Pd=class extends xa{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=ZE,this.verifyUrlV3=e9,this.storagePrefix=ii,this.version=qm,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,re.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!_s()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:f}=n,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{let c=(0,Lm.getDocument)(),b=this.startAbortTimer(re.ONE_SECOND*5),v=await new Promise((S,I)=>{let M=()=>{window.removeEventListener("message",O),c.body.removeChild(T),I("attestation aborted")};this.abortController.signal.addEventListener("abort",M);let T=c.createElement("iframe");T.src=u,T.style.display="none",T.addEventListener("error",M,{signal:this.abortController.signal});let O=P=>{if(P.data&&typeof P.data=="string")try{let z=JSON.parse(P.data);if(z.type==="verify_attestation"){if(ts(z.attestation).payload.id!==o)return;clearInterval(b),c.body.removeChild(T),this.abortController.signal.removeEventListener("abort",M),window.removeEventListener("message",O),S(z.attestation===null?"":z.attestation)}}catch(z){this.logger.warn(z)}};c.body.appendChild(T),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",v),v}catch(c){this.logger.warn(c)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ts(s).payload.id!==f)return;let c=await this.isValidJwtAttestation(s);if(c){if(!c.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return c}}if(!o)return;let u=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,u)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(re.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||Os;return t9.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Os}`),s=Os),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(re.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=Gb(n,s.publicKey),f={hasExpired:(0,re.toMiliseconds)(o.exp)this.abortController.abort(),(0,re.toMiliseconds)(e))}},Nd=class extends Ea{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=r9,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,u=`${i9}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=lt(t,this.context)}},q7=Object.defineProperty,Tm=Object.getOwnPropertySymbols,U7=Object.prototype.hasOwnProperty,z7=Object.prototype.propertyIsEnumerable,Dm=(r,e,t)=>e in r?q7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vo=(r,e)=>{for(var t in e||(e={}))U7.call(e,t)&&Dm(r,t,e[t]);if(Tm)for(var t of Tm(e))z7.call(e,t)&&Dm(r,t,e[t]);return r},Cd=class extends Sa{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=s9,this.storagePrefix=ii,this.storageVersion=n9,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Ao())try{let n={eventId:Ru(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Su(this.core.relayer.protocol,this.core.relayer.version,dd)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:f,trace:u}}=n,c=Ru(),b=this.core.projectId||"",v=Date.now(),S=Vo({eventId:c,timestamp:v,props:{event:s,type:o,properties:{topic:f,trace:u}},bundleId:b,domain:this.getAppDomain()},this.setMethods(c));return this.telemetryEnabled&&(this.events.set(c,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let f=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(f)return Vo(Vo({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(dn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,re.fromMiliseconds)(Date.now())-(0,re.fromMiliseconds)(n.timestamp)>o9&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Vo(Vo({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${a9}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${dd}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>xs().url,this.logger=lt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},B7=Object.defineProperty,Pm=Object.getOwnPropertySymbols,k7=Object.prototype.hasOwnProperty,K7=Object.prototype.propertyIsEnumerable,Nm=(r,e,t)=>e in r?B7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cm=(r,e)=>{for(var t in e||(e={}))k7.call(e,t)&&Nm(r,t,e[t]);if(Pm)for(var t of Pm(e))K7.call(e,t)&&Nm(r,t,e[t]);return r},Od=class r extends pa{constructor(e){var t;super(e),this.protocol=Fm,this.version=qm,this.name=Ld,this.events=new Si.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:u})=>{if(!o||!f)return;let c={topic:o,message:f,publishedAt:Date.now(),transportType:$e.link_mode};this.relayer.onLinkMessageEvent(c,{sessionExists:u})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Um,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Ws({level:typeof e?.logger=="string"&&e.logger?e.logger:AE.logger}),{logger:n,chunkLoggerController:s}=Zl({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=lt(n,this.name),this.heartbeat=new na,this.crypto=new xd(this,this.logger,e?.keychain),this.history=new Td(this,this.logger),this.expirer=new Dd(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new aa(Cm(Cm({},RE),e?.storageOptions)),this.relayer=new Ad({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Rd(this,this.logger),this.verify=new Pd(this,this.logger,this.storage),this.echoClient=new Nd(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Cd(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(KE,i),t}get context(){return yt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(pm,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(pm)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},Ym=Od;var rc=qe(un()),Fe=qe(jn());var ey="wc",ty=2,ry="client",Gd=`${ey}@${ty}:${ry}:`,qd={name:ry,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var Xm="WALLETCONNECT_DEEPLINK_CHOICE";var j7="proposal";var V7="Proposal expired",$7="session",Fs=Fe.SEVEN_DAYS,H7="engine",dt={wc_sessionPropose:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Fe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Fe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1119}}},Ud={min:Fe.FIVE_MINUTES,max:Fe.SEVEN_DAYS},si={idle:"IDLE",active:"ACTIVE"},G7="request",W7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],J7="wc";var Y7="auth",X7="authKeys",Z7="pairingTopics",Q7="requests",ic=`${J7}@${1.5}:${Y7}:`,ec=`${ic}:PUB_KEY`,eS=Object.defineProperty,tS=Object.defineProperties,rS=Object.getOwnPropertyDescriptors,Zm=Object.getOwnPropertySymbols,iS=Object.prototype.hasOwnProperty,nS=Object.prototype.propertyIsEnumerable,Qm=(r,e,t)=>e in r?eS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tt=(r,e)=>{for(var t in e||(e={}))iS.call(e,t)&&Qm(r,t,e[t]);if(Zm)for(var t of Zm(e))nS.call(e,t)&&Qm(r,t,e[t]);return r},yr=(r,e)=>tS(r,rS(e)),zd=class extends Ma{constructor(e){super(e),this.name=H7,this.events=new rc.default,this.initialized=!1,this.requestQueue={state:si.idle,queue:[]},this.sessionRequestQueue={state:si.idle,queue:[]},this.requestQueueDelay=Fe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(dt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=yr(tt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:u}=i,c=n,b,v=!1;try{c&&(v=this.client.core.pairing.pairings.get(c).active)}catch(U){throw this.client.logger.error(`connect() -> pairing.get(${c}) failed`),U}if(!c||!v){let{topic:U,uri:j}=await this.client.core.pairing.create();c=U,b=j}if(!c){let{message:U}=X("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(U)}let S=await this.client.core.crypto.generateKeyPair(),I=dt.wc_sessionPropose.req.ttl||Fe.FIVE_MINUTES,M=st(I),T=tt({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:Fd}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:M,pairingTopic:c},f&&{sessionProperties:f}),{reject:O,resolve:P,done:z}=_i(I,V7);this.events.once(Oe("session_connect"),async({error:U,session:j})=>{if(U)O(U);else if(j){j.self.publicKey=S;let H=yr(tt({},j),{pairingTopic:T.pairingTopic,requiredNamespaces:T.requiredNamespaces,optionalNamespaces:T.optionalNamespaces,transportType:$e.relay});await this.client.session.set(j.topic,H),await this.setExpiry(j.topic,j.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(H),P(H)}});let B=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:T,throwOnFailedPublish:!0});return await this.setProposal(B,tt({id:B},T)),{uri:b,approval:z}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[ir.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(C){throw o.setError(Xi.no_internet_connection),C}try{await this.isValidProposalId(t?.id)}catch(C){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(Xi.proposal_not_found),C}try{await this.isValidApprove(t)}catch(C){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Xi.session_approve_namespace_validation_failure),C}let{id:f,relayProtocol:u,namespaces:c,sessionProperties:b,sessionConfig:v}=t,S=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:M,requiredNamespaces:T,optionalNamespaces:O}=S,P=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});P||(P=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:ir.session_approve_started,properties:{topic:I,trace:[ir.session_approve_started,ir.session_namespaces_validation_success]}}));let z=await this.client.core.crypto.generateKeyPair(),B=M.publicKey,U=await this.client.core.crypto.generateSharedKey(z,B),j=tt(tt({relay:{protocol:u??"irn"},namespaces:c,controller:{publicKey:z,metadata:this.client.metadata},expiry:st(Fs)},b&&{sessionProperties:b}),v&&{sessionConfig:v}),H=$e.relay;P.addTrace(ir.subscribing_session_topic);try{await this.client.core.relayer.subscribe(U,{transportType:H})}catch(C){throw P.setError(Xi.subscribe_session_topic_failure),C}P.addTrace(ir.subscribe_session_topic_success);let L=yr(tt({},j),{topic:U,requiredNamespaces:T,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:M.publicKey,metadata:M.metadata},controller:z,transportType:$e.relay});await this.client.session.set(U,L),P.addTrace(ir.store_session);try{P.addTrace(ir.publishing_session_settle),await this.sendRequest({topic:U,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(C=>{throw P?.setError(Xi.session_settle_publish_failure),C}),P.addTrace(ir.session_settle_publish_success),P.addTrace(ir.publishing_session_approve),await this.sendResult({id:f,topic:I,result:{relay:{protocol:u??"irn"},responderPublicKey:z},throwOnFailedPublish:!0}).catch(C=>{throw P?.setError(Xi.session_approve_publish_failure),C}),P.addTrace(ir.session_approve_publish_success)}catch(C){throw this.client.logger.error(C),this.client.session.delete(U,Ue("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(U),C}return this.client.core.eventClient.deleteEvent({eventId:P.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:M.metadata}),await this.client.proposal.delete(f,Ue("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(U,st(Fs)),{topic:U,acknowledged:()=>Promise.resolve(this.client.session.get(U))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:dt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(v){throw this.client.logger.error("update() -> isValidUpdate() failed"),v}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=_i(),u=Qr(),c=gr().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Oe("session_update",u),({error:v})=>{v?f(v):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:c}).catch(v=>{this.client.logger.error(v),this.client.session.update(i,{namespaces:b}),f(v)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}let{topic:i}=t,n=Qr(),{done:s,resolve:o,reject:f}=_i();return this.events.once(Oe("session_extend",n),({error:u})=>{u?f(u):o()}),await this.setExpiry(i,st(Fs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(u=>{f(u)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(M){throw this.client.logger.error("request() -> isValidRequest() failed"),M}let{chainId:i,request:n,topic:s,expiry:o=dt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let u=Qr(),c=gr().toString(),{done:b,resolve:v,reject:S}=_i(o,"Request expired. Please try again.");this.events.once(Oe("session_request",u),({error:M,result:T})=>{M?S(M):v(T)});let I=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return I?(await this.sendRequest({clientRpcId:u,relayRpcId:c,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(M=>S(M)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),await b()):await Promise.all([new Promise(async M=>{await this.sendRequest({clientRpcId:u,relayRpcId:c,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(T=>S(T)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),M()}),new Promise(async M=>{var T;if(!((T=f.sessionConfig)!=null&&T.disableDeepLink)){let O=await Pb(this.client.core.storage,Xm);await Db({id:u,topic:s,wcDeepLink:O})}M()}),b()]).then(M=>M[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);kt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):At(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=Qr(),s=gr().toString(),{done:o,resolve:f,reject:u}=_i();this.events.once(Oe("session_ping",n),({error:c})=>{c?u(c):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=gr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Ue("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=X("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>Wb(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?$e.link_mode:$e.relay;o===$e.relay&&await this.confirmOnlineStateOrThrow();let{chains:f,statement:u="",uri:c,domain:b,nonce:v,type:S,exp:I,nbf:M,methods:T=[],expiry:O}=t,P=[...t.resources||[]],{topic:z,uri:B}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:z,uri:B}});let U=await this.client.core.crypto.generateKeyPair(),j=Is(U);if(await Promise.all([this.client.auth.authKeys.set(ec,{responseTopic:j,publicKey:U}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:z})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${z}`),T.length>0){let{namespace:y}=So(f[0]),h=Ob(y,"request",T);To(P)&&(h=Lb(h,P.pop())),P.push(h)}let H=O&&O>dt.wc_sessionAuthenticate.req.ttl?O:dt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:f,statement:u,aud:c,domain:b,version:"1",nonce:v,iat:new Date().toISOString(),exp:I,nbf:M,resources:P},requester:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:st(H)},C={eip155:{chains:f,methods:[...new Set(["personal_sign",...T])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:z,proposer:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:st(dt.wc_sessionPropose.req.ttl)},{done:D,resolve:l,reject:w}=_i(H,"Request expired"),p=async({error:y,session:h})=>{if(this.events.off(Oe("session_request",d),a),y)w(y);else if(h){h.self.publicKey=U,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:h.peer.metadata});let x=this.client.session.get(h.topic);await this.deleteProposal(m),l({session:x})}},a=async y=>{var h,x,A;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),y.error){let q=Ue("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return y.error.code===q.code?void 0:(this.events.off(Oe("session_connect"),p),w(y.error.message))}await this.deleteProposal(m),this.events.off(Oe("session_connect"),p);let{cacaos:g,responder:R}=y.result,k=[],E=[];for(let q of g){await Du({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,J=To(K.resources),$=[Mf(K.iss)],V=Ro(K.iss);if(J){let ee=Nu(J),G=Cu(J);k.push(...ee),$.push(...G)}for(let ee of $)E.push(`${ee}:${V}`)}let N=await this.client.core.crypto.generateSharedKey(U,R.publicKey),F;k.length>0&&(F={topic:N,acknowledged:!0,self:{publicKey:U,metadata:this.client.metadata},peer:R,controller:R.publicKey,expiry:st(Fs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:z,namespaces:Bu([...new Set(k)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(N,{transportType:o}),await this.client.session.set(N,F),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:R.metadata}),F=this.client.session.get(N)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(x=R.metadata.redirect)!=null&&x.linkMode&&(A=R.metadata.redirect)!=null&&A.universal&&i&&(this.client.core.addLinkModeSupportedApp(R.metadata.redirect.universal),this.client.session.update(N,{transportType:$e.link_mode})),l({auths:g,session:F})},d=Qr(),m=Qr();this.events.once(Oe("session_connect"),p),this.events.once(Oe("session_request",d),a);let _;try{if(s){let y=br("wc_sessionAuthenticate",L,d);this.client.core.history.set(z,y);let h=await this.client.core.crypto.encode("",y,{type:Ss,encoding:Es});_=Po(i,z,h)}else await Promise.all([this.sendRequest({topic:z,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:z,method:"wc_sessionPropose",params:W,expiry:dt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:m})])}catch(y){throw this.events.off(Oe("session_connect"),p),this.events.off(Oe("session_request",d),a),y}return await this.setProposal(m,tt({id:m},W)),await this.setAuthRequest(d,{request:yr(tt({},L),{verifyContext:{}}),pairingTopic:z,transportType:o}),{uri:_??B,response:D}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Zi.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(Ls.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Ls.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let f=o.transportType||$e.relay;f===$e.relay&&await this.confirmOnlineStateOrThrow();let u=o.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),b=Is(u),v={type:lr,receiverPublicKey:u,senderPublicKey:c},S=[],I=[];for(let O of n){if(!await Du({cacao:O,projectId:this.client.core.projectId})){s.setError(Ls.invalid_cacao);let j=Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:j,encodeOpts:v}),new Error(j.message)}s.addTrace(Zi.cacaos_verified);let{p:P}=O,z=To(P.resources),B=[Mf(P.iss)],U=Ro(P.iss);if(z){let j=Nu(z),H=Cu(z);S.push(...j),B.push(...H)}for(let j of B)I.push(`${j}:${U}`)}let M=await this.client.core.crypto.generateSharedKey(c,u);s.addTrace(Zi.create_authenticated_session_topic);let T;if(S?.length>0){T={topic:M,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:st(Fs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Bu([...new Set(S)],[...new Set(I)]),transportType:f},s.addTrace(Zi.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(M,{transportType:f})}catch(O){throw s.setError(Ls.subscribe_authenticated_session_topic_failure),O}s.addTrace(Zi.subscribe_authenticated_session_topic_success),await this.client.session.set(M,T),s.addTrace(Zi.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Zi.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:v,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(O){throw s.setError(Ls.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:T}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),u=Is(o),c={type:lr,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:u,error:n,encodeOpts:c,rpcOpts:dt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return Pu(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:u}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Ue("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Xm).catch(c=>this.client.logger.warn(c)),this.getPendingSessionRequests().forEach(c=>{c.topic===n&&this.deletePendingSessionRequest(c.id,Ue("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=si.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(Xi.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Ue("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=si.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,st(dt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=$e.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||st(dt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:u,throwOnFailedPublish:c,appLink:b}=t,v=br(n,s,u),S,I=!!b;try{let O=I?Es:Zr;S=await this.client.core.crypto.encode(i,v,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let M;if(W7.includes(n)){let O=pr(JSON.stringify(v)),P=pr(S);M=await this.client.core.verify.register({id:P,decryptedId:O})}let T=dt[n].req;if(T.attestation=M,o&&(T.ttl=o),f&&(T.id=f),this.client.core.history.set(i,v),I){let O=Po(b,i,S);await window.Linking.openURL(O,this.client.name)}else{let O=dt[n].req;o&&(O.ttl=o),f&&(O.id=f),c?(O.internal=yr(tt({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(P=>this.client.logger.error(P))}return v.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:u}=t,c=Ts(i,s),b,v=u&&typeof window?.Linking<"u";try{let I=v?Es:Zr;b=await this.client.core.crypto.encode(n,c,yr(tt({},f||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(v){let I=Po(u,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=dt[S.request.method].res;o?(I.internal=yr(tt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,I)):this.client.core.relayer.publish(n,b,I).catch(M=>this.client.logger.error(M))}await this.client.core.history.resolve(c)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:u}=t,c=Pn(i,s),b,v=u&&typeof window?.Linking<"u";try{let I=v?Es:Zr;b=await this.client.core.crypto.encode(n,c,yr(tt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(v){let I=Po(u,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=f||dt[S.request.method].res;this.client.core.relayer.publish(n,b,I)}await this.client.core.history.resolve(c)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Xr(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Xr(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===si.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=si.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=si.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,u=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=X("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:u}=n;try{let c=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(tt({},n.params));let b=f.expiryTimestamp||st(dt.wc_sessionPropose.req.ttl),v=tt({id:u,pairingTopic:i,expiryTimestamp:b},f);await this.setProposal(u,v);let S=await this.getVerifyContext({attestationId:s,hash:pr(JSON.stringify(n)),encryptedId:o,metadata:v.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),c?.setError(ri.proposal_listener_not_found)),c?.addTrace(mr.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:v,verifyContext:S})}catch(c){await this.sendError({id:u,topic:i,error:c,rpcOpts:dt.wc_sessionPropose.autoReject}),this.client.logger.error(c)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(kt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});let u=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});let c=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:c});let b=await this.client.core.crypto.generateSharedKey(u,c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});let v=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:v}),await this.client.core.pairing.activate({topic:t})}else if(At(i)){await this.client.proposal.delete(s,Ue("USER_DISCONNECTED"));let o=Oe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Oe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:f,expiry:u,namespaces:c,sessionProperties:b,sessionConfig:v}=i.params,S=yr(tt(tt({topic:t,relay:o,expiry:u,namespaces:c,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},b&&{sessionProperties:b}),v&&{sessionConfig:v}),{transportType:$e.relay}),I=Oe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Oe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;kt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Oe("session_approve",n),{})):At(i)&&(await this.client.session.delete(t,Ue("USER_DISCONNECTED")),this.events.emit(Oe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,f=Ki.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:Ue("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(tt({topic:t},n));try{Ki.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(u){throw Ki.delete(o),u}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Oe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_update",n),{}):At(i)&&this.events.emit(Oe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,st(Fs)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Oe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_extend",n),{}):At(i)&&this.events.emit(Oe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Oe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{kt(i)?this.events.emit(Oe("session_ping",n),{}):At(i)&&this.events.emit(Oe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Tt.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Ue("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:f,attestation:u,encryptedId:c,transportType:b}=t,{id:v,params:S}=f;try{await this.isValidRequest(tt({topic:o},S));let I=this.client.session.get(o),M=await this.getVerifyContext({attestationId:u,hash:pr(JSON.stringify(br("wc_sessionRequest",S,v))),encryptedId:c,metadata:I.peer.metadata,transportType:b}),T={id:v,topic:o,params:S,verifyContext:M};await this.setPendingSessionRequest(T),b===$e.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(T):(this.addSessionRequestToSessionRequestQueue(T),this.processSessionRequestQueue())}catch(I){await this.sendError({id:v,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Oe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,f=Ki.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(tt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),Ki.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:f,transportType:u}=t;try{let{requester:c,authPayload:b,expiryTimestamp:v}=s.params,S=await this.getVerifyContext({attestationId:o,hash:pr(JSON.stringify(s)),encryptedId:f,metadata:c.metadata,transportType:u}),I={requester:c,pairingTopic:n,id:s.id,authPayload:b,verifyContext:S,expiryTimestamp:v};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:u}),u===$e.link_mode&&(i=c.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(c.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(c){this.client.logger.error(c);let b=s.params.requester.publicKey,v=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,u),I={type:lr,receiverPublicKey:b,senderPublicKey:v};await this.sendError({id:s.id,topic:n,error:c,encodeOpts:I,rpcOpts:dt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=si.idle,this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,f=Oe("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Oe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===si.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=si.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:br("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Mt(t)){let{message:u}=X("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(u)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(vt(i)||await this.isValidPairingTopic(i),!tv(f,!0)){let{message:u}=X("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(u)}!vt(n)&&No(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!vt(s)&&No(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),vt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=ev(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Mt(t))throw new Error(X("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let f=this.client.proposal.get(i),u=Tf(n,"approve()");if(u)throw new Error(u.message);let c=Vu(f.requiredNamespaces,n,"approve()");if(c)throw new Error(c.message);if(!Ye(s,!0)){let{message:b}=X("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}vt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Mt(t)){let{message:s}=X("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!iv(n)){let{message:s}=X("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Mt(t)){let{message:c}=X("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(c)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Ku(i)){let{message:c}=X("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}let f=Zb(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);let u=Tf(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Xr(o)){let{message:c}=X("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async t=>{if(!Mt(t)){let{message:u}=X("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(u)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=Tf(n,"update()");if(o)throw new Error(o.message);let f=Vu(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Mt(t)){let{message:u}=X("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(u)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:f}=this.client.session.get(i);if(!ju(f,s)){let{message:u}=X("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!nv(n)){let{message:u}=X("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(u)}if(!av(f,s,n.method)){let{message:u}=X("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(u)}if(o&&!cv(o,Ud)){let{message:u}=X("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Ud.min} and ${Ud.max}`);throw new Error(u)}},this.isValidRespond=async t=>{var i;if(!Mt(t)){let{message:o}=X("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!sv(s)){let{message:o}=X("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Mt(t)){let{message:f}=X("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!ju(o,s)){let{message:f}=X("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!ov(n)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!fv(o,s,n.name)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Ye(n,!1))throw new Error("uri is required parameter");if(!Ye(s,!1))throw new Error("domain is required parameter");if(!Ye(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(u=>So(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:f}=So(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,u={verified:{verifyUrl:o.verifyUrl||Os,validation:"UNKNOWN",origin:o.url||""}};try{if(f===$e.link_mode){let b=this.getAppLinkIfEnabled(o,f);return u.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",u}let c=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});c&&(u.verified.origin=c.origin,u.verified.isScam=c.isScam,u.verified.validation=c.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(c){this.client.logger.warn(c)}return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`),u},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!Ye(n,!1)){let{message:s}=X("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,u,c,b,v,S;return!t||i!==$e.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((c=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:c.universal)!==""&&((b=t?.redirect)==null?void 0:b.universal)!==void 0&&((v=t?.redirect)==null?void 0:v.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof window?.Linking<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=Au(t,"topic")||"",n=decodeURIComponent(Au(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:$e.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Ao()||Tn()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=window?.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Tt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(ec)?this.client.auth.authKeys.get(ec):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===$e.link_mode?Es:Zr});try{Ds(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:pr(i)})):Gi(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(u){this.client.logger.error(u)}}registerExpirerEvents(){this.client.core.expirer.on(Kt.expired,async e=>{let{topic:t,id:i}=If(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,X("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,X("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Yi.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Yi.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=X("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=X("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=X("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Ye(e,!1)){let{message:t}=X("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=X("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!rv(e)){let{message:t}=X("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=X("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},Bd=class extends ni{constructor(e,t){super(e,t,j7,Gd),this.core=e,this.logger=t}},kd=class extends ni{constructor(e,t){super(e,t,$7,Gd),this.core=e,this.logger=t}},Kd=class extends ni{constructor(e,t){super(e,t,G7,Gd,i=>i.id),this.core=e,this.logger=t}},jd=class extends ni{constructor(e,t){super(e,t,X7,ic,()=>ec),this.core=e,this.logger=t}},Vd=class extends ni{constructor(e,t){super(e,t,Z7,ic),this.core=e,this.logger=t}},$d=class extends ni{constructor(e,t){super(e,t,Q7,ic,i=>i.id),this.core=e,this.logger=t}},Hd=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new jd(this.core,this.logger),this.pairingTopics=new Vd(this.core,this.logger),this.requests=new $d(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},tc=class r extends Ia{constructor(e){super(e),this.protocol=ey,this.version=ty,this.name=qd.name,this.events=new rc.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||qd.name,this.metadata=e?.metadata||xs(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,Hs.default)(Ws({level:e?.logger||qd.logger}));this.core=e?.core||new Ym(e),this.logger=lt(t,this.name),this.session=new kd(this.core,this.logger),this.proposal=new Bd(this.core,this.logger),this.pendingRequest=new Kd(this.core,this.logger),this.engine=new zd(this),this.auth=new Hd(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return yt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var iy=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],wr="mvx";var Ho=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);function Wd(r){return r[Math.floor(Math.random()*r.length)]}var ny="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Jd=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;ti.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Ii(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=Xd(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function sy(r){return!!r}function Zd(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function Qd({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,f=r.guardian;if(f&&f!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=Jd(t),i&&(r.guardianSignature=Jd(i)),r}function oy(r){if(r)return{...r,url:xs().url}}async function ay(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var oi=class{constructor(e,t,i,n,s,o,f,u){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.Message=s,this.Transaction=o,this.TransactionsConverter=f,this.options=u}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:oy(this.options?.metadata)}:{},t=await tc.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=Yd(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await ay(500);let i=Zd(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Ii(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:Ue("USER_DISCONNECTED")});else{let t=Ii(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:Ue("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return Qd({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];Qd({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Ii(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?sy(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=Zd(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&Ii(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=Xd(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!ji(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var Fn=(r=>(r[r.Border=-1]="Border",r[r.Data=0]="Data",r[r.Function=1]="Function",r[r.Position=2]="Position",r[r.Timing=3]="Timing",r[r.Alignment=4]="Alignment",r))(Fn||{}),aS=Object.defineProperty,fS=(r,e,t)=>e in r?aS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nc=(r,e,t)=>(fS(r,typeof e!="symbol"?e+"":e,t),t),cS=[0,1],cy=[1,0],hy=[2,3],uy=[3,2],hS={L:cS,M:cy,Q:hy,H:uy},uS=/^[0-9]*$/,dS=/^[A-Z0-9 $%*+.\/:-]*$/,el="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",nl=1,sl=40,fy=3,lS=3,sc=40,pS=10,dy=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],ly=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],tl=class{constructor(e,t,i,n){if(this.version=e,this.ecc=t,nc(this,"size"),nc(this,"mask"),nc(this,"modules",[]),nc(this,"types",[]),esl)throw new RangeError("Version value out of range");if(n<-1||n>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let s=Array.from({length:this.size},()=>!1);for(let f=0;f0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(i);if(this.drawCodewords(o),n===-1){let f=1e9;for(let u=0;u<8;u++){this.applyMask(u),this.drawFormatBits(u);let c=this.getPenaltyScore();c=0&&e=0&&t>>9)*1335;let n=(t<<10|i)^21522;for(let s=0;s<=5;s++)this.setFunctionModule(8,s,Mi(n,s));this.setFunctionModule(8,7,Mi(n,6)),this.setFunctionModule(8,8,Mi(n,7)),this.setFunctionModule(7,8,Mi(n,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,Mi(n,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,Mi(n,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,Mi(n,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let i=0;i<12;i++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let i=0;i<18;i++){let n=Mi(t,i),s=this.size-11+i%3,o=Math.floor(i/3);this.setFunctionModule(s,o,n),this.setFunctionModule(o,s,n)}}drawFinderPattern(e,t){for(let i=-4;i<=4;i++)for(let n=-4;n<=4;n++){let s=Math.max(Math.abs(n),Math.abs(i)),o=e+n,f=t+i;o>=0&&o=0&&f{(S!==u-s||M>=f)&&v.push(I[S])});return v}drawCodewords(e){if(e.length!==Math.floor(rl(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let i=this.size-1;i>=1;i-=2){i===6&&(i=5);for(let n=0;n>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(f,u),o||(e+=this.finderPenaltyCountPatterns(u)*sc),o=this.modules[s][c],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,u)*sc}for(let s=0;s5&&e++):(this.finderPenaltyAddHistory(f,u),o||(e+=this.finderPenaltyCountPatterns(u)*sc),o=this.modules[c][s],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,u)*sc}for(let s=0;so+(f?1:0),t);let i=this.size*this.size,n=Math.ceil(Math.abs(t*20-i*10)/i)-1;return e+=n*pS,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,i=[6];for(let n=this.size-7;i.length0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(i&&e[0]>=t*4&&e[6]>=t?1:0)+(i&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,i){return e&&(this.finderPenaltyAddHistory(t,i),t=0),t+=this.size,this.finderPenaltyAddHistory(t,i),this.finderPenaltyCountPatterns(i)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Ai(r,e,t){if(e<0||e>31||r>>>e)throw new RangeError("Value out of range");for(let i=e-1;i>=0;i--)t.push(r>>>i&1)}function Mi(r,e){return(r>>>e&1)!==0}var Go=class{constructor(e,t,i){if(this.mode=e,this.numChars=t,this.bitData=i,t<0)throw new RangeError("Invalid argument");this.bitData=i.slice()}getData(){return this.bitData.slice()}},gS=[1,10,12,14],bS=[2,9,11,13],vS=[4,8,16,16];function py(r,e){return r[Math.floor((e+7)/17)+1]}function gy(r){let e=[];for(let t of r)Ai(t,8,e);return new Go(vS,r.length,e)}function mS(r){if(!by(r))throw new RangeError("String contains non-numeric characters");let e=[];for(let t=0;t=1<sl)throw new RangeError("Version number out of range");let e=(16*r+128)*r+64;if(r>=2){let t=Math.floor(r/7)+2;e-=(25*t-10)*t-55,r>=7&&(e-=36)}return e}function oc(r,e){return Math.floor(rl(r)/8)-dy[e[0]][r]*ly[e[0]][r]}function ES(r){if(r<1||r>255)throw new RangeError("Degree out of range");let e=[];for(let i=0;i0);for(let i of r){let n=i^t.shift();t.push(0),e.forEach((s,o)=>t[o]^=il(s,n))}return t}function il(r,e){if(r>>>8||e>>>8)throw new RangeError("Byte out of range");let t=0;for(let i=7;i>=0;i--)t=t<<1^(t>>>7)*285,t^=(e>>>i&1)*r;return t}function IS(r,e,t=1,i=40,n=-1,s=!0){if(!(nl<=t&&t<=i&&i<=sl)||n<-1||n>7)throw new RangeError("Invalid value");let o,f;for(o=t;;o++){let v=oc(o,e)*8,S=_S(r,o);if(S<=v){f=S;break}if(o>=i)throw new RangeError("Data too long")}for(let v of[cy,hy,uy])s&&f<=oc(o,v)*8&&(e=v);let u=[];for(let v of r){Ai(v.mode[0],4,u),Ai(v.numChars,py(v.mode,o),u);for(let S of v.getData())u.push(S)}let c=oc(o,e)*8;Ai(0,Math.min(4,c-u.length),u),Ai(0,(8-u.length%8)%8,u);for(let v=236;u.length0);return u.forEach((v,S)=>b[S>>>3]|=v<<7-(S&7)),new tl(o,e,b,n)}function MS(r,e){let{ecc:t="L",boostEcc:i=!1,minVersion:n=1,maxVersion:s=40,maskPattern:o=-1,border:f=1}=e||{},u=typeof r=="string"?wS(r):Array.isArray(r)?[gy(r)]:void 0;if(!u)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof r}`);let c=IS(u,hS[t],n,s,o,i),b=AS({version:c.version,maskPattern:c.mask,size:c.size,data:c.modules,types:c.types},f);return e?.invert&&(b.data=b.data.map(v=>v.map(S=>!S))),e?.onEncoded?.(b),b}function AS(r,e=1){if(!e)return r;let{size:t}=r,i=t+e*2;r.size=i,r.data.forEach(s=>{for(let o=0;o!1)),r.data.push(Array.from({length:i},o=>!1));let n=Fn.Border;r.types.forEach(s=>{for(let o=0;on)),r.types.push(Array.from({length:i},o=>n));return r}function my(r,e={}){let t=MS(r,e),{pixelSize:i=10,whiteColor:n="white",blackColor:s="black"}=e,o=t.size*i,f=t.size*i,u=``,c=[];for(let b=0;b`,u+=``,u+="",u}var TS=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},DS=r=>{let e=`${ny}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},PS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},NS=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},ol={},CS=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",ol[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:ol[r.topic].signal}),t},ac={},OS=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=CS(r,e);return i.appendChild(s),ac[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:ac[r.topic].signal}),i},LS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},FS=r=>{if(!r)return;document.getElementById(r)?.remove()},qS=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),US=r=>r?my(r):void 0,yy=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=US(e),o;if(s&&(o=TS(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),qS()&&n.appendChild(DS(e))),n&&t instanceof oi){let f=t.pairings,u=async b=>{try{b&&(await t.logout({topic:b}),FS(b))}catch(v){let S=Ho(v);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{ac[b].abort()}},c=async b=>{try{let{approval:v}=await t.connect({topic:b,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(b)?.after(LS()),await t.login({approval:v,token:i})}catch(v){let S=Ho(v);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let v of Object.values(ac))v?.abort();for(let v of Object.values(ol))v?.abort()}};if(f&&f.length>0){let b=PS();n.appendChild(b);let v=NS();b.appendChild(v);for(let S of f){let I=OS(S,u,c);b.appendChild(I)}}}return n};var wy=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:t,qrCodeContainer:i},n){this.WalletConnectV2Provider=oi;this.initMobileProvider=async e=>{if(!this.walletConnectV2ProjectId||!e.initOptions.chainType)return;let t={onClientLogin:()=>{},onClientLogout:()=>this.logout(e),onClientEvent:s=>{console.log("wc2 session event: ",s)}},i=Wd(this.walletConnectV2RelayAddresses),n=new oi(t,this.networkConfig[e.initOptions.chainType].shortId,i,this.walletConnectV2ProjectId,this.Message,this.Transaction,this.TransactionsConverter);try{return await n.init(),n}catch{console.warn("Can't initialize the Dapp Provider!");return}};this.loginWithMobile=async(e,t,i)=>{if(!this.qrCodeContainer)throw new Error("You haven't provided the QR code container DOM element id");let n=Wd(this.walletConnectV2RelayAddresses);if(!n||!e.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!this.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!e.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let s,o={onClientLogin:async()=>{if(e.dappProvider instanceof oi){let u=e.dappProvider.getAddress(),c=e.dappProvider.getSignature();if(this.ls.set("address",u),this.ls.set("loginMethod","mobile"),this.ls.set("expires",this.getNewLoginExpiresTimestamp()),await this.accountSync(e),c){this.ls.set("signature",c),this.ls.set("loginToken",t);let b=i.getToken(u,t,c);this.ls.set("accessToken",b),this.EventsStore.run("onLoginSuccess"),s?.replaceChildren()}}},onClientLogout:async()=>{e.dappProvider instanceof oi&&await this.logout(e)},onClientEvent:u=>{console.log("wc2 session event: ",u)}},f=new oi(o,this.networkConfig[e.initOptions.chainType].shortId,n,this.walletConnectV2ProjectId,this.Message,this.Transaction,this.TransactionsConverter);try{if(f){e.dappProvider=f,this.EventsStore.run("onQrPending"),await f.init();let{uri:u,approval:c}=await f.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),b=t?`${u}&token=${t}`:u;return this.qrCodeContainer&&b&&(s=await yy(this.qrCodeContainer,b,f,t),this.EventsStore.run("onQrLoaded")),await f.login({approval:c,token:t}),f}}catch(u){let c=Ho(u);console.warn(`Something went wrong trying to login the user: ${c}`),this.EventsStore.run("onLoginFailure",c)}};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=t,this.qrCodeContainer=i,this.networkConfig=n.networkConfig,this.Message=n.Message,this.Transaction=n.Transaction,this.TransactionsConverter=n.TransactionsConverter,this.ls=n.ls,this.logout=n.logout,this.getNewLoginExpiresTimestamp=n.getNewLoginExpiresTimestamp,this.accountSync=n.accountSync,this.EventsStore=n.EventsStore}};export{wy as MobileSigningProvider}; /*! Bundled license information: tslib/tslib.es6.js: diff --git a/package-lock.json b/package-lock.json index 7edb8f5..9a0a9d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1439,9 +1439,9 @@ } }, "node_modules/@humanwhocodes/retry": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.0.tgz", - "integrity": "sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.1.tgz", + "integrity": "sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==", "dev": true, "engines": { "node": ">=18.18" @@ -1468,20 +1468,12 @@ "node": ">=12" } }, - "node_modules/@noble/secp256k1": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-2.1.0.tgz", - "integrity": "sha512-XLEQQNdablO0XZOIniFQimiXsZDNwaYgL96dZwC54Q30imSbAOFf3NKtepc+cXyuZf5Q1HCgbqgZ2UFFuHVcEw==", - "dev": true, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@parcel/watcher": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.4.1.tgz", - "integrity": "sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.0.tgz", + "integrity": "sha512-i0GV1yJnm2n3Yq1qw6QrUrd/LI9bE8WEBOTtOkpCXHHdyN3TAGgqAK/DAT05z4fq2x04cARXt2pDmjWjL92iTQ==", "dev": true, + "hasInstallScript": true, "dependencies": { "detect-libc": "^1.0.3", "is-glob": "^4.0.3", @@ -1496,24 +1488,25 @@ "url": "https://opencollective.com/parcel" }, "optionalDependencies": { - "@parcel/watcher-android-arm64": "2.4.1", - "@parcel/watcher-darwin-arm64": "2.4.1", - "@parcel/watcher-darwin-x64": "2.4.1", - "@parcel/watcher-freebsd-x64": "2.4.1", - "@parcel/watcher-linux-arm-glibc": "2.4.1", - "@parcel/watcher-linux-arm64-glibc": "2.4.1", - "@parcel/watcher-linux-arm64-musl": "2.4.1", - "@parcel/watcher-linux-x64-glibc": "2.4.1", - "@parcel/watcher-linux-x64-musl": "2.4.1", - "@parcel/watcher-win32-arm64": "2.4.1", - "@parcel/watcher-win32-ia32": "2.4.1", - "@parcel/watcher-win32-x64": "2.4.1" + "@parcel/watcher-android-arm64": "2.5.0", + "@parcel/watcher-darwin-arm64": "2.5.0", + "@parcel/watcher-darwin-x64": "2.5.0", + "@parcel/watcher-freebsd-x64": "2.5.0", + "@parcel/watcher-linux-arm-glibc": "2.5.0", + "@parcel/watcher-linux-arm-musl": "2.5.0", + "@parcel/watcher-linux-arm64-glibc": "2.5.0", + "@parcel/watcher-linux-arm64-musl": "2.5.0", + "@parcel/watcher-linux-x64-glibc": "2.5.0", + "@parcel/watcher-linux-x64-musl": "2.5.0", + "@parcel/watcher-win32-arm64": "2.5.0", + "@parcel/watcher-win32-ia32": "2.5.0", + "@parcel/watcher-win32-x64": "2.5.0" } }, "node_modules/@parcel/watcher-android-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.4.1.tgz", - "integrity": "sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.0.tgz", + "integrity": "sha512-qlX4eS28bUcQCdribHkg/herLe+0A9RyYC+mm2PXpncit8z5b3nSqGVzMNR3CmtAOgRutiZ02eIJJgP/b1iEFQ==", "cpu": [ "arm64" ], @@ -1531,9 +1524,9 @@ } }, "node_modules/@parcel/watcher-darwin-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.4.1.tgz", - "integrity": "sha512-ln41eihm5YXIY043vBrrHfn94SIBlqOWmoROhsMVTSXGh0QahKGy77tfEywQ7v3NywyxBBkGIfrWRHm0hsKtzA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.0.tgz", + "integrity": "sha512-hyZ3TANnzGfLpRA2s/4U1kbw2ZI4qGxaRJbBH2DCSREFfubMswheh8TeiC1sGZ3z2jUf3s37P0BBlrD3sjVTUw==", "cpu": [ "arm64" ], @@ -1551,9 +1544,9 @@ } }, "node_modules/@parcel/watcher-darwin-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.4.1.tgz", - "integrity": "sha512-yrw81BRLjjtHyDu7J61oPuSoeYWR3lDElcPGJyOvIXmor6DEo7/G2u1o7I38cwlcoBHQFULqF6nesIX3tsEXMg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.0.tgz", + "integrity": "sha512-9rhlwd78saKf18fT869/poydQK8YqlU26TMiNg7AIu7eBp9adqbJZqmdFOsbZ5cnLp5XvRo9wcFmNHgHdWaGYA==", "cpu": [ "x64" ], @@ -1571,9 +1564,9 @@ } }, "node_modules/@parcel/watcher-freebsd-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.4.1.tgz", - "integrity": "sha512-TJa3Pex/gX3CWIx/Co8k+ykNdDCLx+TuZj3f3h7eOjgpdKM+Mnix37RYsYU4LHhiYJz3DK5nFCCra81p6g050w==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.0.tgz", + "integrity": "sha512-syvfhZzyM8kErg3VF0xpV8dixJ+RzbUaaGaeb7uDuz0D3FK97/mZ5AJQ3XNnDsXX7KkFNtyQyFrXZzQIcN49Tw==", "cpu": [ "x64" ], @@ -1591,9 +1584,29 @@ } }, "node_modules/@parcel/watcher-linux-arm-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.4.1.tgz", - "integrity": "sha512-4rVYDlsMEYfa537BRXxJ5UF4ddNwnr2/1O4MHM5PjI9cvV2qymvhwZSFgXqbS8YoTk5i/JR0L0JDs69BUn45YA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.0.tgz", + "integrity": "sha512-0VQY1K35DQET3dVYWpOaPFecqOT9dbuCfzjxoQyif1Wc574t3kOSkKevULddcR9znz1TcklCE7Ht6NIxjvTqLA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.0.tgz", + "integrity": "sha512-6uHywSIzz8+vi2lAzFeltnYbdHsDm3iIB57d4g5oaB9vKwjb6N6dRIgZMujw4nm5r6v9/BQH0noq6DzHrqr2pA==", "cpu": [ "arm" ], @@ -1611,9 +1624,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.4.1.tgz", - "integrity": "sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.0.tgz", + "integrity": "sha512-BfNjXwZKxBy4WibDb/LDCriWSKLz+jJRL3cM/DllnHH5QUyoiUNEp3GmL80ZqxeumoADfCCP19+qiYiC8gUBjA==", "cpu": [ "arm64" ], @@ -1631,9 +1644,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.4.1.tgz", - "integrity": "sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.0.tgz", + "integrity": "sha512-S1qARKOphxfiBEkwLUbHjCY9BWPdWnW9j7f7Hb2jPplu8UZ3nes7zpPOW9bkLbHRvWM0WDTsjdOTUgW0xLBN1Q==", "cpu": [ "arm64" ], @@ -1651,9 +1664,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.4.1.tgz", - "integrity": "sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.0.tgz", + "integrity": "sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw==", "cpu": [ "x64" ], @@ -1671,9 +1684,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.4.1.tgz", - "integrity": "sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.0.tgz", + "integrity": "sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA==", "cpu": [ "x64" ], @@ -1691,9 +1704,9 @@ } }, "node_modules/@parcel/watcher-wasm": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.4.1.tgz", - "integrity": "sha512-/ZR0RxqxU/xxDGzbzosMjh4W6NdYFMqq2nvo2b8SLi7rsl/4jkL8S5stIikorNkdR50oVDvqb/3JT05WM+CRRA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.5.0.tgz", + "integrity": "sha512-Z4ouuR8Pfggk1EYYbTaIoxc+Yv4o7cGQnH0Xy8+pQ+HbiW+ZnwhcD2LPf/prfq1nIWpAxjOkQ8uSMFWMtBLiVQ==", "bundleDependencies": [ "napi-wasm" ], @@ -1718,9 +1731,9 @@ "license": "MIT" }, "node_modules/@parcel/watcher-win32-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.4.1.tgz", - "integrity": "sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.0.tgz", + "integrity": "sha512-twtft1d+JRNkM5YbmexfcH/N4znDtjgysFaV9zvZmmJezQsKpkfLYJ+JFV3uygugK6AtIM2oADPkB2AdhBrNig==", "cpu": [ "arm64" ], @@ -1738,9 +1751,9 @@ } }, "node_modules/@parcel/watcher-win32-ia32": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.4.1.tgz", - "integrity": "sha512-maNRit5QQV2kgHFSYwftmPBxiuK5u4DXjbXx7q6eKjq5dsLXZ4FJiVvlcw35QXzk0KrUecJmuVFbj4uV9oYrcw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.0.tgz", + "integrity": "sha512-+rgpsNRKwo8A53elqbbHXdOMtY/tAtTzManTWShB5Kk54N8Q9mzNWV7tV+IbGueCbcj826MfWGU3mprWtuf1TA==", "cpu": [ "ia32" ], @@ -1758,9 +1771,9 @@ } }, "node_modules/@parcel/watcher-win32-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.4.1.tgz", - "integrity": "sha512-+DvS92F9ezicfswqrvIRM2njcYJbd5mb9CUgtrHCHmvn7pPPa+nMDRu1o1bYYz/l5IB2NVGNJWiH7h1E58IF2A==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.0.tgz", + "integrity": "sha512-lPrxve92zEHdgeff3aiu4gDOIt4u7sJYha6wbdEZDCDUhtjTsOMiaJzG5lMY4GkWH8p0fMmO2Ppq5G5XXG+DQw==", "cpu": [ "x64" ], @@ -1963,9 +1976,9 @@ } }, "node_modules/@walletconnect/core": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.17.1.tgz", - "integrity": "sha512-SMgJR5hEyEE/tENIuvlEb4aB9tmMXPzQ38Y61VgYBmwAFEhOHtpt8EDfnfRWqEhMyXuBXG4K70Yh8c67Yry+Xw==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.17.2.tgz", + "integrity": "sha512-O9VUsFg78CbvIaxfQuZMsHcJ4a2Z16DRz/O4S+uOAcGKhH/i/ln8hp864Tb+xRvifWSzaZ6CeAVxk657F+pscA==", "dev": true, "dependencies": { "@walletconnect/heartbeat": "1.2.2", @@ -1979,8 +1992,8 @@ "@walletconnect/relay-auth": "1.0.4", "@walletconnect/safe-json": "1.0.2", "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", "@walletconnect/window-getters": "1.0.1", "events": "3.3.0", "lodash.isequal": "4.5.0", @@ -2126,19 +2139,19 @@ } }, "node_modules/@walletconnect/sign-client": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.17.1.tgz", - "integrity": "sha512-6rLw6YNy0smslH9wrFTbNiYrGsL3DrOsS5FcuU4gIN6oh8pGYOFZ5FiSyTTroc5tngOk3/Sd7dlGY9S7O4nveg==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.17.2.tgz", + "integrity": "sha512-/wigdCIQjlBXSWY43Id0IPvZ5biq4HiiQZti8Ljvx408UYjmqcxcBitbj2UJXMYkid7704JWAB2mw32I1HgshQ==", "dev": true, "dependencies": { - "@walletconnect/core": "2.17.1", + "@walletconnect/core": "2.17.2", "@walletconnect/events": "1.0.1", "@walletconnect/heartbeat": "1.2.2", "@walletconnect/jsonrpc-utils": "1.0.8", "@walletconnect/logger": "2.1.2", "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", "events": "3.3.0" } }, @@ -2152,9 +2165,9 @@ } }, "node_modules/@walletconnect/types": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.17.1.tgz", - "integrity": "sha512-aiUeBE3EZZTsZBv5Cju3D0PWAsZCMks1g3hzQs9oNtrbuLL6pKKU0/zpKwk4vGywszxPvC3U0tBCku9LLsH/0A==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.17.2.tgz", + "integrity": "sha512-j/+0WuO00lR8ntu7b1+MKe/r59hNwYLFzW0tTmozzhfAlDL+dYwWasDBNq4AH8NbVd7vlPCQWmncH7/6FVtOfQ==", "dev": true, "dependencies": { "@walletconnect/events": "1.0.1", @@ -2166,9 +2179,9 @@ } }, "node_modules/@walletconnect/utils": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.17.1.tgz", - "integrity": "sha512-KL7pPwq7qUC+zcTmvxGqIyYanfHgBQ+PFd0TEblg88jM7EjuDLhjyyjtkhyE/2q7QgR7OanIK7pCpilhWvBsBQ==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.17.2.tgz", + "integrity": "sha512-T7eLRiuw96fgwUy2A5NZB5Eu87ukX8RCVoO9lji34RFV4o2IGU9FhTEWyd4QQKI8OuQRjSknhbJs0tU0r0faPw==", "dev": true, "dependencies": { "@ethersproject/hash": "5.7.0", @@ -2184,11 +2197,11 @@ "@walletconnect/relay-auth": "1.0.4", "@walletconnect/safe-json": "1.0.2", "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", + "@walletconnect/types": "2.17.2", "@walletconnect/window-getters": "1.0.1", "@walletconnect/window-metadata": "1.0.1", "detect-browser": "5.3.0", - "elliptic": "6.5.7", + "elliptic": "6.6.0", "query-string": "7.1.3", "uint8arrays": "3.1.0" } @@ -2610,9 +2623,9 @@ "dev": true }, "node_modules/elliptic": { - "version": "6.5.7", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", - "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.0.tgz", + "integrity": "sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==", "dev": true, "dependencies": { "bn.js": "^4.11.9", @@ -4789,20 +4802,15 @@ } }, "packages/elven.js": { - "version": "1.0.0", - "devDependencies": { - "esbuild": "0.24.0" - } + "version": "1.0.0" }, "packages/mobile-signing-provider": { "name": "@elven.js/mobile-signing-provider", "version": "1.0.0", "devDependencies": { - "@noble/secp256k1": "2.1.0", - "@walletconnect/sign-client": "2.17.1", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", - "esbuild": "0.24.0", + "@walletconnect/sign-client": "2.17.2", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", "uqr": "0.1.2" }, "peerDependencies": { diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json index 2bb6d98..5a8eaa0 100644 --- a/packages/elven.js/package.json +++ b/packages/elven.js/package.json @@ -20,8 +20,5 @@ "prettier": "prettier --write 'src/**/*.{js,ts,json}'", "check-types": "tsc --noEmit", "clean": "rimraf build node_modules" - }, - "devDependencies": { - "esbuild": "0.24.0" } } \ No newline at end of file diff --git a/packages/elven.js/src/main.ts b/packages/elven.js/src/main.ts index 919eff3..b8a027e 100644 --- a/packages/elven.js/src/main.ts +++ b/packages/elven.js/src/main.ts @@ -18,6 +18,7 @@ import { InitOptions, EventStoreEvents, MobileSigningProvider, + MobileSigningProviderDeps, } from './types'; import { logout } from './auth/logout'; import { loginWithExtension } from './auth/login-with-extension'; @@ -74,16 +75,32 @@ export class ElvenJS { this.networkProvider = new ApiNetworkProvider(this.initOptions); - // Initialize the optional mobile provider - this.mobileProvider = this.initOptions?.externalSigningProviders?.mobile - ?.provider - ? new this.initOptions.externalSigningProviders.mobile.provider( - this.initOptions.externalSigningProviders.mobile.config - ) - : undefined; - initializeEventsStore(this.initOptions); + // Initialize the optional mobile provider + const MobileProvider = + this.initOptions?.externalSigningProviders?.mobile?.provider; + if (MobileProvider) { + const deps: MobileSigningProviderDeps = { + networkConfig, + Message, + Transaction, + TransactionsConverter, + ls, + logout, + getNewLoginExpiresTimestamp, + accountSync, + EventsStore, + }; + const mobileProviderConfig = + this.initOptions?.externalSigningProviders?.mobile?.config; + if (mobileProviderConfig) { + this.mobileProvider = new MobileProvider(mobileProviderConfig, deps); + } else { + throw new Error('Mobile provider config is required!'); + } + } + // Catch the nativeAuthToken and login with it (for example within xPortal Hub) const nativeAuthTokenFromUrl = getParamFromUrl('accessToken'); if (nativeAuthTokenFromUrl) { @@ -109,14 +126,8 @@ export class ElvenJS { state.loginMethod === LoginMethodsEnum.mobile && this.mobileProvider ) { - this.dappProvider = await this.mobileProvider?.initMobileProvider( - this, - logout, - networkConfig, - Message, - Transaction, - TransactionsConverter - ); + this.dappProvider = + await this.mobileProvider?.initMobileProvider(this); } if (state.loginMethod === LoginMethodsEnum.webview) { this.dappProvider = new WebviewProvider(); @@ -207,16 +218,7 @@ export class ElvenJS { const dappProvider = await this.mobileProvider?.loginWithMobile( this, loginToken, - nativeAuthClient, - ls, - logout, - getNewLoginExpiresTimestamp, - accountSync, - EventsStore, - networkConfig, - Message, - Transaction, - TransactionsConverter + nativeAuthClient ); this.dappProvider = dappProvider; } diff --git a/packages/elven.js/src/types.ts b/packages/elven.js/src/types.ts index c184319..d3d525a 100644 --- a/packages/elven.js/src/types.ts +++ b/packages/elven.js/src/types.ts @@ -10,7 +10,7 @@ import { NativeAuthClient } from './core/native-auth-client'; import { Message } from './core/message'; import { TransactionsConverter } from './core/transaction-converter'; import { NetworkType } from './utils/constants'; -import { ls } from './utils/ls-helpers'; +import { LocalStorage } from './utils/ls-helpers'; import { EventsStore } from './events-store'; export interface MobileSigningProviderConfig { @@ -27,35 +27,34 @@ export interface WalletConnectV2Provider } export interface MobileSigningProvider { - initMobileProvider: ( - elvenJS: any, - logout: typeof import('./auth/logout').logout, - networkConfig: typeof import('./utils/constants').networkConfig, - Message: typeof import('./core/message').Message, - Transaction: typeof import('./core/transaction').Transaction, - TransactionsConverter: typeof import('./core/transaction-converter').TransactionsConverter - ) => Promise; + initMobileProvider: (elvenJS: any) => Promise; loginWithMobile: ( celvenJS: any, loginToken: string, - nativeAuthClient: NativeAuthClient, - storage: typeof ls, - logout: (elven: any) => Promise, - getNewLoginExpiresTimestamp: () => number, - accountSync: (elven: any) => Promise, - EventsStoreClass: typeof EventsStore, - networkConfig: Record, - MessageClass: typeof Message, - TransactionClass: typeof Transaction, - TransactionsConverterClass: typeof TransactionsConverter + nativeAuthClient: NativeAuthClient ) => Promise; WalletConnectV2Provider: { new (...args: any[]): WalletConnectV2Provider; }; } +export type MobileSigningProviderDeps = { + networkConfig: Record; + Message: typeof Message; + Transaction: typeof Transaction; + TransactionsConverter: typeof TransactionsConverter; + ls: LocalStorage; + logout: (instance: any) => Promise; + getNewLoginExpiresTimestamp: () => number; + accountSync: (instance: any) => Promise; + EventsStore: typeof EventsStore; +}; + export interface MobileProvider { - new (config: MobileSigningProviderConfig): MobileSigningProvider; + new ( + config: MobileSigningProviderConfig, + deps: MobileSigningProviderDeps + ): MobileSigningProvider; } export interface InitOptions { diff --git a/packages/elven.js/src/utils/ls-helpers.ts b/packages/elven.js/src/utils/ls-helpers.ts index eec4e6c..ccbdaa8 100644 --- a/packages/elven.js/src/utils/ls-helpers.ts +++ b/packages/elven.js/src/utils/ls-helpers.ts @@ -1,7 +1,13 @@ import { LOCAL_STORAGE_KEY } from './constants'; +export interface LocalStorage { + get(key?: string): any; + set(key: string, value: string | number): void; + clear(): void; +} + // Local storage helpers for the Elven.js key -export const ls = { +export const ls: LocalStorage = { get(key?: string) { const state = localStorage.getItem(LOCAL_STORAGE_KEY); if (!state) return {}; diff --git a/packages/mobile-signing-provider/package.json b/packages/mobile-signing-provider/package.json index 43deb1c..0ee0d44 100644 --- a/packages/mobile-signing-provider/package.json +++ b/packages/mobile-signing-provider/package.json @@ -22,11 +22,9 @@ "clean": "rimraf build node_modules" }, "devDependencies": { - "@noble/secp256k1": "2.1.0", - "@walletconnect/sign-client": "2.17.1", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", - "esbuild": "0.24.0", + "@walletconnect/sign-client": "2.17.2", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", "uqr": "0.1.2" }, "peerDependencies": { diff --git a/packages/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/mobile-signing-provider/src/mobile-signing-provider.ts index 0a2b589..b75afe2 100644 --- a/packages/mobile-signing-provider/src/mobile-signing-provider.ts +++ b/packages/mobile-signing-provider/src/mobile-signing-provider.ts @@ -20,37 +20,62 @@ export class MobileSigningProvider { private walletConnectV2ProjectId: string; private walletConnectV2RelayAddresses: string[]; private qrCodeContainer: string | HTMLElement; + private networkConfig: NetworkConfig; + private Message: new (...args: any[]) => unknown; + private Transaction: new (...args: any[]) => unknown; + private TransactionsConverter: new (...args: any[]) => unknown; + private ls: LocalStorage; + private logout: (context: Context) => Promise; + private getNewLoginExpiresTimestamp: () => number; + private accountSync: (context: Context) => Promise; + private EventsStore: EventsStore; + WalletConnectV2Provider = WalletConnectV2Provider; - constructor({ - walletConnectV2ProjectId, - walletConnectV2RelayAddresses, - qrCodeContainer, - }: { - walletConnectV2ProjectId: string; - walletConnectV2RelayAddresses: string[]; - qrCodeContainer: string | HTMLElement; - }) { + constructor( + { + walletConnectV2ProjectId, + walletConnectV2RelayAddresses, + qrCodeContainer, + }: { + walletConnectV2ProjectId: string; + walletConnectV2RelayAddresses: string[]; + qrCodeContainer: string | HTMLElement; + }, + deps: { + networkConfig: NetworkConfig; + Message: new (...args: any[]) => unknown; + Transaction: new (...args: any[]) => unknown; + TransactionsConverter: new (...args: any[]) => unknown; + ls: LocalStorage; + logout: (context: Context) => Promise; + getNewLoginExpiresTimestamp: () => number; + accountSync: (context: Context) => Promise; + EventsStore: EventsStore; + } + ) { this.walletConnectV2ProjectId = walletConnectV2ProjectId; this.walletConnectV2RelayAddresses = walletConnectV2RelayAddresses; this.qrCodeContainer = qrCodeContainer; + this.networkConfig = deps.networkConfig; + this.Message = deps.Message; + this.Transaction = deps.Transaction; + this.TransactionsConverter = deps.TransactionsConverter; + this.ls = deps.ls; + this.logout = deps.logout; + this.getNewLoginExpiresTimestamp = deps.getNewLoginExpiresTimestamp; + this.accountSync = deps.accountSync; + this.EventsStore = deps.EventsStore; } - initMobileProvider = async ( - context: Context, - logout: (context: Context) => Promise, - networkConfig: NetworkConfig, - Message: new (...args: any[]) => unknown, - Transaction: new (...args: any[]) => unknown, - TransactionsConverter: new (...args: any[]) => unknown - ) => { + initMobileProvider = async (context: Context) => { if (!this.walletConnectV2ProjectId || !context.initOptions.chainType) { return undefined; } const providerHandlers = { onClientLogin: () => {}, - onClientLogout: () => logout(context), + onClientLogout: () => this.logout(context), onClientEvent: (event: SessionEventTypes['event']) => { console.log('wc2 session event: ', event); }, @@ -62,12 +87,12 @@ export class MobileSigningProvider { const dappProviderInstance = new WalletConnectV2Provider( providerHandlers, - networkConfig[context.initOptions.chainType].shortId, + this.networkConfig[context.initOptions.chainType].shortId, relayAddress, this.walletConnectV2ProjectId, - Message, - Transaction, - TransactionsConverter + this.Message, + this.Transaction, + this.TransactionsConverter ); try { @@ -82,16 +107,7 @@ export class MobileSigningProvider { loginWithMobile = async ( context: Context, loginToken: string, - nativeAuthClient: NativeAuthClient, - ls: LocalStorage, - logout: (context: Context) => Promise, - getNewLoginExpiresTimestamp: () => number, - accountSync: (context: Context) => Promise, - EventsStore: EventsStore, - networkConfig: NetworkConfig, - Message: new (...args: any[]) => unknown, - Transaction: new (...args: any[]) => unknown, - TransactionsConverter: new (...args: any[]) => unknown + nativeAuthClient: NativeAuthClient ) => { if (!this.qrCodeContainer) { throw new Error( @@ -129,15 +145,15 @@ export class MobileSigningProvider { const address = context.dappProvider.getAddress(); const signature = context.dappProvider.getSignature(); - ls.set('address', address); - ls.set('loginMethod', LoginMethodsEnum.mobile); - ls.set('expires', getNewLoginExpiresTimestamp()); + this.ls.set('address', address); + this.ls.set('loginMethod', LoginMethodsEnum.mobile); + this.ls.set('expires', this.getNewLoginExpiresTimestamp()); - await accountSync(context); + await this.accountSync(context); if (signature) { - ls.set('signature', signature); - ls.set('loginToken', loginToken); + this.ls.set('signature', signature); + this.ls.set('loginToken', loginToken); const accessToken = nativeAuthClient.getToken( address, @@ -145,16 +161,16 @@ export class MobileSigningProvider { signature ); - ls.set('accessToken', accessToken); + this.ls.set('accessToken', accessToken); - EventsStore.run(EventStoreEvents.onLoginSuccess); + this.EventsStore.run(EventStoreEvents.onLoginSuccess); qrCodeElement?.replaceChildren(); } } }, onClientLogout: async () => { if (context.dappProvider instanceof WalletConnectV2Provider) { - await logout(context); + await this.logout(context); } }, onClientEvent: (event: SessionEventTypes['event']) => { @@ -164,19 +180,19 @@ export class MobileSigningProvider { const dappProvider = new WalletConnectV2Provider( providerHandlers, - networkConfig[context.initOptions.chainType].shortId, + this.networkConfig[context.initOptions.chainType].shortId, relayAddress, this.walletConnectV2ProjectId, - Message, - Transaction, - TransactionsConverter + this.Message, + this.Transaction, + this.TransactionsConverter ); try { if (dappProvider) { context.dappProvider = dappProvider; - EventsStore.run(EventStoreEvents.onQrPending); + this.EventsStore.run(EventStoreEvents.onQrPending); await dappProvider.init(); @@ -199,7 +215,7 @@ export class MobileSigningProvider { loginToken ); - EventsStore.run(EventStoreEvents.onQrLoaded); + this.EventsStore.run(EventStoreEvents.onQrLoaded); } await dappProvider.login({ @@ -212,7 +228,7 @@ export class MobileSigningProvider { } catch (e) { const err = errorParse(e); console.warn(`Something went wrong trying to login the user: ${err}`); - EventsStore.run(EventStoreEvents.onLoginFailure, err); + this.EventsStore.run(EventStoreEvents.onLoginFailure, err); } }; } From 238ea56b2cce78b4c3cd785ced416e52ada5f2b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sat, 9 Nov 2024 15:56:45 +0100 Subject: [PATCH 12/13] improve native auth integration --- TODO.md | 12 +++--- demo-app/elven.js | 2 +- packages/elven.js/src/auth/account-sync.ts | 3 +- .../elven.js/src/core/native-auth-client.ts | 38 ++----------------- .../elven.js/src/core/web-wallet-signing.ts | 2 +- packages/elven.js/src/main.ts | 4 +- 6 files changed, 17 insertions(+), 44 deletions(-) diff --git a/TODO.md b/TODO.md index 63f465c..c6a04c2 100644 --- a/TODO.md +++ b/TODO.md @@ -1,13 +1,13 @@ +- prepare a new API for token operations +- prepare a new API for smart contracts interactions - the the best would be to pass the arguments as is (always requiring ABI without typed helpers ???) + - pass ABI as link to a file or as content or both? - check and handle all the errors for the mobile provider when the provider is not initialized etc. - add tests for at least most used utilities, maybe some core tools, check tests in MVX SDKs (more tests can be added later) -- prepare a new API - - for token operations - - for smart contracts interactions - the the best would be to pass the arguments as is (always requiring ABI without typed helpers ???) - - pass ABI as link to a file or as content or both? - test guardians -- use Knip to detect unused stuff (in both packages) and do the cleanup -- test on the testnet - update README and docs and demos - how it is built now - what it can't do - why the mobile provider is so big and what can be done to make it smaller, plus why it isn't so bad because it is a separate file +- check TODOs in code +- use Knip to detect unused stuff (in both packages) and do the cleanup +- test on the testnet diff --git a/demo-app/elven.js b/demo-app/elven.js index d0cc598..b9d82ab 100644 --- a/demo-app/elven.js +++ b/demo-app/elven.js @@ -6,6 +6,6 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ie=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),A=n=>et.encode(n),R=n=>tt.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),j=n=>y(A(n)),N=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},nt=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Ae=a&63;e+=C.charAt(l),e+=C.charAt(u),e+=r+1R(N(n)),I=n=>{let e=typeof n=="string"?A(n):n;return nt(e)};function rt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function it(n,e,t){let r=n;for(let o=0;o{pe([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&pe([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function he(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=rt(r);it(t,i,o)}return t}function Le(n){let e=[];return pe([],n,e),e.join("&")}var ot=()=>typeof window<"u"&&typeof window.location<"u",$=()=>{if(ot()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},me=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var P=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Ee(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:y(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return y(this.address)}};var ke=1e9,Ue=0,K=2,Oe=2,fe=64,Ce=1;var Me="sdk-js";var We="hook/login",_e="hook/logout";var De="hook/sign",Fe="hook/2fa",Ge="hook/sign-message",B="walletProviderStatus",V="transactionsSigned";var He={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var k=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||ke),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||K),this.options=Number(e.options?.valueOf()||Ue),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var J=class extends v{constructor(){super("Async timer already running")}},X=class extends v{constructor(){super("Async timer aborted")}};var M=class extends v{constructor(){super("Expected transaction status not reached")}},q=class extends v{constructor(){super("Expected transaction events not found")}};var Y=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var Z=class extends v{constructor(){super("Cannot sign single transaction.")}},ee=class extends v{constructor(){super("Account is not connected.")}},z=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},te=class extends Error{constructor(){super("Cannot get signed message")}};var W=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new J;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new X),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var Te=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Q=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new Te(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new Y;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==fe)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${fe}.`);return t}async awaitConditionally(e,t,r){let o=new W("watcher:periodic"),i=new W("watcher:patience"),s=new W("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var b=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ce,this.signer=e.signer||Me}};var h=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?I(e.senderUsername):void 0,receiverUsername:e.receiverUsername?I(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?I(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?y(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?y(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new k({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:H(e.receiverUsername||""),sender:e.sender,senderUsername:H(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?N(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var U=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new Z;return t[0]}ensureConnected(){if(!this.account.address)throw new ee}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>h.transactionToPlainObject(r))});try{return t.map(o=>h.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:R(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new b({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var ne="elvenjs_state",$e="https://devnet-api.multiversx.com";var E="/dapp/init",re="devnet";var T={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(ne);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(ne,JSON.stringify(t))},clear(){localStorage.removeItem(ne)}};var ie=async()=>{let n=U.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var we=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},w=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:We,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:_e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Ge,callbackUrl:t?.callbackUrl,params:{message:R(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=he(e);if((t.status?.toString()||"")!=="signed")throw new te;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Fe,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(De,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=he(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,B)&&e[B]===V}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new z;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new z;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var ye=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},_=class{constructor(e){this.config=Object.assign(new ye,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(s=>s.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(j(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var oe=(n,e)=>t=>{let r=t.data;try{r=me()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!me()&&t.origin!=$()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",oe(n,e)),e({type:o,payload:i}))};var L=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",oe("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>h.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>h.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:R(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new b({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),$()):t.parent&&t.parent.postMessage(e,$())),await this.waitingForResponse(He[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",oe(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var f=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var be=async(n,e)=>{let t=f("signature"),r=f("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new w(`${n}${E}`);if(t&&e&&r){let l=new _({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var se=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var ae=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||re,this.apiUrl=e||T[this.chainType]?.apiAddress,this.apiTimeout=r||T[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=h.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new se(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:N(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>j(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var S=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(S||{}),O=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(O||{}),at=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(at||{}),ve=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(ve||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var p=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var xe=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=p(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var D=()=>new Date().setHours(new Date().getHours()+24),ce=n=>Date.now()>n;var F=async n=>{let e=d.get("address"),t=d.get("expires");if(!(t&&ce(t))&&e&&n.networkProvider){let o=new P(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=p(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Be=async(n,e,t,r="/")=>{let o=await ie(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=p(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",D()),await F(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var Se=async(n,e,t,r)=>{let o=new w(`${n}${E}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",T[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",D()),d.set("loginToken",e),o}catch(a){let l=p(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var de=async(n,e)=>{c.run("onTxSent",n);let r=await new Q(e).awaitCompleted(n.txHash),o=r.sender,i=new P(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var le=n=>{let e=n.sender,t=new P(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var qe=async(n,e,t,r)=>{if(f(B)===V&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=f("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=I(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new w(`${t}${E}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=h.plainObjectToTransaction(l);u.nonce=BigInt(r),le(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await de(m,e)}catch(m){let Re=`Getting transaction information failed! ${p(m)}`;throw c.run("onTxFailure",u,Re),new Error(Re)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var ze=n=>{let e=d.get("activeGuardian");return e&&(n.version=K,n.options=Oe,n.guardian=e),n},Qe=async(n,e)=>{let t=new w(`${e}${E}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},je=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ke=()=>{let n=!f("walletProviderStatus"),e=f("status")==="signed",t=f("message"),r=f("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ct(n){try{let e=atob(n),t=btoa(e),r=H(n),o=I(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function G(n){return ct(n)?atob(n):n}var ue=n=>Object.prototype.toString.call(n)==="[object String]";var Ve=n=>{if(!n||!ue(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(G(i)),a=G(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Je=n=>{if(!n||!ue(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=G(t),s=G(r),a=Ve(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function Xe(n,e){let t=Je(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new L)}var Ye=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&c.set("onQrPending",e.onQrPending),e?.onQrLoaded&&c.set("onQrLoaded",e.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var ge=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=p(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var Pe=class{static async init(e){let t=d.get();if(t.expires&&ce(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:re,apiUrl:$e,apiTimeout:1e4,...e},this.networkProvider=new ae(this.initOptions),Ye(this.initOptions);let r=this.initOptions?.externalSigningProviders?.mobile?.provider;if(r){let s={networkConfig:T,Message:b,Transaction:k,TransactionsConverter:h,ls:d,logout:xe,getNewLoginExpiresTimestamp:D,accountSync:F,EventsStore:c},a=this.initOptions?.externalSigningProviders?.mobile?.config;if(a)this.mobileProvider=new r(a,s);else throw new Error("Mobile provider config is required!")}let o=f("accessToken");o&&await ge(async s=>{Xe(o,this),await F(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&f("address"))&&t?.loginMethod&&(await ge(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await ie()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this)),t.loginMethod==="webview"&&(this.dappProvider=new L),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await be(T[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await be(T[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await F(this),s()}),this.initOptions?.chainType&&(await qe(this.dappProvider,this.networkProvider,T[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Ke()))}static async login(e,t){if(!Object.values(O).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await ge(async()=>{let o=new _({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize();if(e==="browser-extension"){let s=await Be(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await Se(T[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await Se(T[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await xe(this);return this.dappProvider=void 0,e}catch(e){let t=p(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=ze(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof L&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof w&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=je(t);if(o||le(t),o&&this.initOptions?.chainType){await Qe(t,T[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await de(i,this.networkProvider)}}catch(r){let o=p(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new b({data:A(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new b({data:A(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof L){let i=await this.dappProvider.signMessage(new b({data:A(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof w){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new b({data:A(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=p(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=p(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}static{this.storage=d}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,c.clear()}}};var dt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},Ze=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),Ze({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{P as Account,at as DappCoreWCV2CustomMethodsEnum,Pe as ElvenJS,S as EventStoreEvents,O as LoginMethodsEnum,k as Transaction,Q as TransactionWatcher,ve as WebWalletUrlParamsEnum,Ze as formatAmount,dt as parseAmount}; +var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Re=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),R=n=>et.encode(n),I=n=>tt.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),Ee=n=>y(R(n)),N=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},nt=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Pe=a&63;e+=C.charAt(l),e+=C.charAt(u),e+=r+1I(N(n)),S=n=>{let e=typeof n=="string"?R(n):n;return nt(e)};function rt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function it(n,e,t){let r=n;for(let o=0;o{ge([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&ge([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function pe(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=rt(r);it(t,i,o)}return t}function Le(n){let e=[];return ge([],n,e),e.join("&")}var ot=()=>typeof window<"u"&&typeof window.location<"u",H=()=>{if(ot()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},he=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var A=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Ie(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:y(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return y(this.address)}};var Oe=1e9,Ue=0,j=2,ke=2,me=64,Ce=1;var Me="sdk-js";var We="hook/login",_e="hook/logout";var De="hook/sign",Fe="hook/2fa",Ge="hook/sign-message",B="walletProviderStatus",K="transactionsSigned";var $e={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var O=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||Oe),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||j),this.options=Number(e.options?.valueOf()||Ue),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var V=class extends v{constructor(){super("Async timer already running")}},J=class extends v{constructor(){super("Async timer aborted")}};var M=class extends v{constructor(){super("Expected transaction status not reached")}},q=class extends v{constructor(){super("Expected transaction events not found")}};var X=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var Y=class extends v{constructor(){super("Cannot sign single transaction.")}},Z=class extends v{constructor(){super("Account is not connected.")}},z=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},ee=class extends Error{constructor(){super("Cannot get signed message")}};var W=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new V;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new J),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var fe=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Q=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new fe(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new X;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==me)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${me}.`);return t}async awaitConditionally(e,t,r){let o=new W("watcher:periodic"),i=new W("watcher:patience"),s=new W("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var b=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ce,this.signer=e.signer||Me}};var h=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?S(e.senderUsername):void 0,receiverUsername:e.receiverUsername?S(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?S(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?y(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?y(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new O({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:$(e.receiverUsername||""),sender:e.sender,senderUsername:$(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?N(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var U=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new Y;return t[0]}ensureConnected(){if(!this.account.address)throw new Z}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>h.transactionToPlainObject(r))});try{return t.map(o=>h.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:I(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new b({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var te="elvenjs_state",He="https://devnet-api.multiversx.com";var E="/dapp/init",ne="devnet";var T={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(te);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(te,JSON.stringify(t))},clear(){localStorage.removeItem(te)}};var re=async()=>{let n=U.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var Te=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},w=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:We,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:_e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Ge,callbackUrl:t?.callbackUrl,params:{message:I(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=pe(e);if((t.status?.toString()||"")!=="signed")throw new ee;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Fe,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(De,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=pe(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,B)&&e[B]===K}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new z;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new z;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var we=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*2}},_=class{constructor(e){this.config=Object.assign(new we,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(S(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var ie=(n,e)=>t=>{let r=t.data;try{r=he()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!he()&&t.origin!=H()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",ie(n,e)),e({type:o,payload:i}))};var L=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",ie("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>h.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>h.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:I(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new b({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),H()):t.parent&&t.parent.postMessage(e,H())),await this.waitingForResponse($e[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",ie(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var f=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var ye=async(n,e)=>{let t=f("signature"),r=f("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new w(`${n}${E}`);if(t&&e&&r){let l=new _({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var oe=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var se=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||ne,this.apiUrl=e||T[this.chainType]?.apiAddress,this.apiTimeout=r||T[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=h.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new oe(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:N(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>Ee(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var P=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(P||{}),k=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(k||{}),at=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(at||{}),be=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(be||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var p=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var ve=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=p(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var D=()=>new Date().setHours(new Date().getHours()+24),ae=n=>Date.now()>n;var F=async n=>{let e=d.get("address"),t=d.get("expires");if(!(typeof t=="number"?ae(t):!0)&&e&&n.networkProvider){let o=new A(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=p(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Be=async(n,e,t,r="/")=>{let o=await re(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=p(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",D()),await F(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var xe=async(n,e,t,r)=>{let o=new w(`${n}${E}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",T[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",D()),d.set("loginToken",e),o}catch(a){let l=p(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var ce=async(n,e)=>{c.run("onTxSent",n);let r=await new Q(e).awaitCompleted(n.txHash),o=r.sender,i=new A(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var de=n=>{let e=n.sender,t=new A(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var qe=async(n,e,t,r)=>{if(f(B)===K&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=f("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=S(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new w(`${t}${E}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=h.plainObjectToTransaction(l);u.nonce=BigInt(r),de(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await ce(m,e)}catch(m){let Ae=`Getting transaction information failed! ${p(m)}`;throw c.run("onTxFailure",u,Ae),new Error(Ae)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var ze=n=>{let e=d.get("activeGuardian");return e&&(n.version=j,n.options=ke,n.guardian=e),n},Qe=async(n,e)=>{let t=new w(`${e}${E}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},je=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ke=()=>{let n=!f("walletProviderStatus"),e=f("status")==="signed",t=f("message"),r=f("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ct(n){try{let e=atob(n),t=btoa(e),r=$(n),o=S(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function G(n){return ct(n)?atob(n):n}var le=n=>Object.prototype.toString.call(n)==="[object String]";var Ve=n=>{if(!n||!le(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(G(i)),a=G(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Je=n=>{if(!n||!le(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=G(t),s=G(r),a=Ve(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function Xe(n,e){let t=Je(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new L)}var Ye=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&c.set("onQrPending",e.onQrPending),e?.onQrLoaded&&c.set("onQrLoaded",e.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var ue=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=p(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var Se=class{static async init(e){let t=d.get();if(t.expires&&ae(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:ne,apiUrl:He,apiTimeout:1e4,...e},this.networkProvider=new se(this.initOptions),Ye(this.initOptions);let r=this.initOptions?.externalSigningProviders?.mobile?.provider;if(r){let s={networkConfig:T,Message:b,Transaction:O,TransactionsConverter:h,ls:d,logout:ve,getNewLoginExpiresTimestamp:D,accountSync:F,EventsStore:c},a=this.initOptions?.externalSigningProviders?.mobile?.config;if(a)this.mobileProvider=new r(a,s);else throw new Error("Mobile provider config is required!")}let o=f("accessToken");o&&await ue(async s=>{Xe(o,this),await F(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&f("address"))&&t?.loginMethod&&(await ue(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await re()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this)),t.loginMethod==="webview"&&(this.dappProvider=new L),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await ye(T[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await ye(T[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await F(this),s()}),this.initOptions?.chainType&&(await qe(this.dappProvider,this.networkProvider,T[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Ke()))}static async login(e,t){if(!Object.values(k).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await ue(async()=>{let o=new _({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize({timestamp:`${Math.floor(Date.now()/1e3)}`});if(e==="browser-extension"){let s=await Be(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await xe(T[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await xe(T[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await ve(this);return this.dappProvider=void 0,e}catch(e){let t=p(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=ze(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof L&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof w&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=je(t);if(o||de(t),o&&this.initOptions?.chainType){await Qe(t,T[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await ce(i,this.networkProvider)}}catch(r){let o=p(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new b({data:R(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new b({data:R(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof L){let i=await this.dappProvider.signMessage(new b({data:R(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof w){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new b({data:R(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=p(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=p(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}static{this.storage=d}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,c.clear()}}};var dt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},Ze=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),Ze({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{A as Account,at as DappCoreWCV2CustomMethodsEnum,Se as ElvenJS,P as EventStoreEvents,k as LoginMethodsEnum,O as Transaction,Q as TransactionWatcher,be as WebWalletUrlParamsEnum,Ze as formatAmount,dt as parseAmount}; /** keccak.js https://github.com/adraffy/keccak.js @license MIT */ /** https://github.com/emn178/js-sha3/blob/master/src/sha3.js @license MIT */ diff --git a/packages/elven.js/src/auth/account-sync.ts b/packages/elven.js/src/auth/account-sync.ts index 504be82..795ae1d 100644 --- a/packages/elven.js/src/auth/account-sync.ts +++ b/packages/elven.js/src/auth/account-sync.ts @@ -6,7 +6,8 @@ import { isLoginExpired } from './expires-at'; export const accountSync = async (elven: any) => { const address = ls.get('address'); const loginExpires = ls.get('expires'); - const loginExpired = loginExpires && isLoginExpired(loginExpires); + const loginExpired = + typeof loginExpires === 'number' ? isLoginExpired(loginExpires) : true; if (!loginExpired && address && elven.networkProvider) { const userAccountInstance = new Account(address); diff --git a/packages/elven.js/src/core/native-auth-client.ts b/packages/elven.js/src/core/native-auth-client.ts index fcdf9e1..bc67b69 100644 --- a/packages/elven.js/src/core/native-auth-client.ts +++ b/packages/elven.js/src/core/native-auth-client.ts @@ -1,8 +1,6 @@ // Based on Multiversx sdk-core with modifications -import { stringToHex } from './utils'; - -// TODO: review what is really needed regarding the gateway and api fallbacks +import { toBase64FromStringOrBytes } from './utils'; class NativeAuthClientConfig { origin: string = @@ -10,9 +8,8 @@ class NativeAuthClientConfig { ? window.location.hostname : ''; apiUrl: string = 'https://api.multiversx.com'; - expirySeconds: number = 60 * 60 * 24; + expirySeconds: number = 60 * 60 * 2; blockHashShard?: number; - gatewayUrl?: string; extraRequestHeaders?: { [key: string]: string }; } @@ -40,37 +37,9 @@ export class NativeAuthClient { } async getCurrentBlockHash(): Promise { - if (this.config.gatewayUrl) { - return await this.getCurrentBlockHashWithGateway(); - } return await this.getCurrentBlockHashWithApi(); } - private async getCurrentBlockHashWithGateway(): Promise { - const round = await this.getCurrentRound(); - const url = `${this.config.gatewayUrl}/blocks/by-round/${round}`; - const response = await this.get(url); - const blocks = response.data.data.blocks; - const block = blocks.filter( - (block: { shard: number }) => block.shard === this.config.blockHashShard - )[0]; - return block.hash; - } - - private async getCurrentRound(): Promise { - if (!this.config.gatewayUrl) { - throw new Error('Gateway URL not set'); - } - if (!this.config.blockHashShard) { - throw new Error('Blockhash shard not set'); - } - - const url = `${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`; - const response = await this.get(url); - const status = response.data.data.status; - return status.erd_current_round; - } - private async getCurrentBlockHashWithApi(): Promise { const url = `${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`; const response = await this.get(url); @@ -89,8 +58,9 @@ export class NativeAuthClient { const response = await this.get(url); return response.hash; } + encodeValue(str: string) { - return this.escape(stringToHex(str)); + return this.escape(toBase64FromStringOrBytes(str)); } private escape(str: string) { diff --git a/packages/elven.js/src/core/web-wallet-signing.ts b/packages/elven.js/src/core/web-wallet-signing.ts index c3ff4fb..bbdb42c 100644 --- a/packages/elven.js/src/core/web-wallet-signing.ts +++ b/packages/elven.js/src/core/web-wallet-signing.ts @@ -194,7 +194,7 @@ export class WalletProvider { async signTransaction( transaction: Transaction, options?: { callbackUrl?: string } - ): Promise { + ) { await this.signTransactions([transaction], options); } diff --git a/packages/elven.js/src/main.ts b/packages/elven.js/src/main.ts index b8a027e..d80f4f7 100644 --- a/packages/elven.js/src/main.ts +++ b/packages/elven.js/src/main.ts @@ -200,7 +200,9 @@ export class ElvenJS { origin: window.location.origin, }); - const loginToken = await nativeAuthClient.initialize(); + const loginToken = await nativeAuthClient.initialize({ + timestamp: `${Math.floor(Date.now() / 1000)}`, + }); // Login with browser extension if (loginMethod === LoginMethodsEnum.browserExtension) { From 466f5a95151e44dec4846e48cc83424aaf3f309a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Sun, 17 Nov 2024 15:40:15 +0100 Subject: [PATCH 13/13] remove the namespace --- TODO.md | 2 + configs/eslint-config/package.json | 10 +- demo-app/elven.js | 2 +- demo-app/index.html | 48 +- demo-app/mobile-signing-provider.js | 2 +- package-lock.json | 503 +++++------ package.json | 13 +- .../elven.js/src/auth/login-with-extension.ts | 2 +- .../src/auth/login-with-web-wallet.ts | 2 +- packages/elven.js/src/auth/logout.ts | 2 +- packages/elven.js/src/config.ts | 23 + packages/elven.js/src/elven.ts | 2 +- packages/elven.js/src/events-store.ts | 33 +- .../elven.js/src/initialize-events-store.ts | 2 +- .../elven.js/src/interaction/post-send-tx.ts | 2 +- .../web-wallet-sign-message-finalize.ts | 2 +- .../src/interaction/web-wallet-tx-finalize.ts | 2 +- packages/elven.js/src/main.ts | 783 +++++++++--------- packages/elven.js/src/types.ts | 2 +- .../elven.js/src/utils/with-login-events.ts | 2 +- 20 files changed, 740 insertions(+), 699 deletions(-) create mode 100644 packages/elven.js/src/config.ts diff --git a/TODO.md b/TODO.md index c6a04c2..6f8a2d7 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,4 @@ +- remove callbacks from the API - base everything on promises - prepare a new API for token operations - prepare a new API for smart contracts interactions - the the best would be to pass the arguments as is (always requiring ABI without typed helpers ???) - pass ABI as link to a file or as content or both? @@ -11,3 +12,4 @@ - check TODOs in code - use Knip to detect unused stuff (in both packages) and do the cleanup - test on the testnet +- add jsdoc comments for main functions diff --git a/configs/eslint-config/package.json b/configs/eslint-config/package.json index aec5a87..7e13800 100644 --- a/configs/eslint-config/package.json +++ b/configs/eslint-config/package.json @@ -5,10 +5,10 @@ "private": true, "main": "index.js", "devDependencies": { - "@eslint/eslintrc": "3.1.0", - "@eslint/js": "9.14.0", - "@typescript-eslint/eslint-plugin": "8.12.2", - "@typescript-eslint/parser": "8.12.2", + "@eslint/eslintrc": "3.2.0", + "@eslint/js": "9.15.0", + "@typescript-eslint/eslint-plugin": "8.14.0", + "@typescript-eslint/parser": "8.14.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-prettier": "5.2.1" }, @@ -16,4 +16,4 @@ "lint": "eslint \"**/*.{ts,tsx,js,jsx}\" --fix", "prettier": "prettier --write '**/*.{js,ts,json}'" } -} +} \ No newline at end of file diff --git a/demo-app/elven.js b/demo-app/elven.js index b9d82ab..6fb57ce 100644 --- a/demo-app/elven.js +++ b/demo-app/elven.js @@ -6,6 +6,6 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Re=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),R=n=>et.encode(n),I=n=>tt.decode(n),x=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),Ee=n=>y(R(n)),N=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let a=0;a=8&&(i-=8,r[s++]=o>>i&255)}return r},nt=n=>{let e="",t=n.length;for(let r=0;r>18&63,u=a>>12&63,m=a>>6&63,Pe=a&63;e+=C.charAt(l),e+=C.charAt(u),e+=r+1I(N(n)),S=n=>{let e=typeof n=="string"?R(n):n;return nt(e)};function rt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function it(n,e,t){let r=n;for(let o=0;o{ge([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&ge([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function pe(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=rt(r);it(t,i,o)}return t}function Le(n){let e=[];return ge([],n,e),e.join("&")}var ot=()=>typeof window<"u"&&typeof window.location<"u",H=()=>{if(ot()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},he=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var A=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Ie(e)&&(this.address=x(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:y(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return y(this.address)}};var Oe=1e9,Ue=0,j=2,ke=2,me=64,Ce=1;var Me="sdk-js";var We="hook/login",_e="hook/logout";var De="hook/sign",Fe="hook/2fa",Ge="hook/sign-message",B="walletProviderStatus",K="transactionsSigned";var $e={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var O=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||Oe),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||j),this.options=Number(e.options?.valueOf()||Ue),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var v=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var V=class extends v{constructor(){super("Async timer already running")}},J=class extends v{constructor(){super("Async timer aborted")}};var M=class extends v{constructor(){super("Expected transaction status not reached")}},q=class extends v{constructor(){super("Expected transaction events not found")}};var X=class extends v{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var Y=class extends v{constructor(){super("Cannot sign single transaction.")}},Z=class extends v{constructor(){super("Account is not connected.")}},z=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},ee=class extends Error{constructor(){super("Cannot get signed message")}};var W=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new V;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new J),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var fe=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Q=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new fe(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new X;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.every(u=>a.includes(u))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let a=this.getAllTransactionEvents(s).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new q;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new M;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==me)throw new v(`Invalid transaction hash length. The length of a hex encoded hash should be ${me}.`);return t}async awaitConditionally(e,t,r){let o=new W("watcher:periodic"),i=new W("watcher:patience"),s=new W("watcher:timeout"),a=!1,l,u=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),a=!0});!a&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),u=e(l),!(u||a)););if(u&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!u)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var b=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||Ce,this.signer=e.signer||Me}};var h=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?S(e.senderUsername):void 0,receiverUsername:e.receiverUsername?S(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?S(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?y(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?y(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new O({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:$(e.receiverUsername||""),sender:e.sender,senderUsername:$(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?N(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?x(e.signature):void 0,guardianSignature:e.guardianSignature?x(e.guardianSignature):void 0})}};var U=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new Y;return t[0]}ensureConnected(){if(!this.account.address)throw new Z}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>h.transactionToPlainObject(r))});try{return t.map(o=>h.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:I(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=x(o);return new b({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var te="elvenjs_state",He="https://devnet-api.multiversx.com";var E="/dapp/init",ne="devnet";var T={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(te);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(te,JSON.stringify(t))},clear(){localStorage.removeItem(te)}};var re=async()=>{let n=U.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var Te=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},w=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:We,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:_e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:Ge,callbackUrl:t?.callbackUrl,params:{message:I(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=pe(e);if((t.status?.toString()||"")!=="signed")throw new ee;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Fe,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(De,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=pe(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,B)&&e[B]===K}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new z;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new z;let o=[];for(let i=0;i{let a=n.prepareWalletTransaction(s);for(let l in a)Object.prototype.hasOwnProperty.call(a,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(a[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var we=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*2}},_=class{constructor(e){this.config=Object.assign(new we,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(S(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var ie=(n,e)=>t=>{let r=t.data;try{r=he()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!he()&&t.origin!=H()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",ie(n,e)),e({type:o,payload:i}))};var L=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",ie("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>h.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>h.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:I(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new b({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:x(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),H()):t.parent&&t.parent.postMessage(e,H())),await this.waitingForResponse($e[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",ie(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var f=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var ye=async(n,e)=>{let t=f("signature"),r=f("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new w(`${n}${E}`);if(t&&e&&r){let l=new _({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var oe=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var se=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||ne,this.apiUrl=e||T[this.chainType]?.apiAddress,this.apiTimeout=r||T[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),a=await s.json();if(!s.ok){let l=a?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),a}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await a.json();if(!a.ok){let u=l?.error||a.status;return clearTimeout(i),Promise.reject(u)}return clearTimeout(i),l}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=h.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new oe(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:N(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>Ee(l))},a=await this.apiPost("query",s);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var P=(g=>(g.onLoginStart="onLoginStart",g.onLoginSuccess="onLoginSuccess",g.onLoginFailure="onLoginFailure",g.onLogoutStart="onLogoutStart",g.onLogoutSuccess="onLogoutSuccess",g.onLogoutFailure="onLogoutFailure",g.onQrPending="onQrPending",g.onQrLoaded="onQrLoaded",g.onTxStart="onTxStart",g.onTxSent="onTxSent",g.onTxFinalized="onTxFinalized",g.onTxFailure="onTxFailure",g.onSignMsgStart="onSignMsgStart",g.onSignMsgFinalized="onSignMsgFinalized",g.onSignMsgFailure="onSignMsgFailure",g.onQueryStart="onQueryStart",g.onQueryFinalized="onQueryFinalized",g.onQueryFailure="onQueryFailure",g))(P||{}),k=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(k||{}),at=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(at||{}),be=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(be||{});var c=class{static set(e,t){if(!e)return;let r={...this.events,[e]:t};this.events=r}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var p=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var ve=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");c.run("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),c.run("onLogoutSuccess")),e}catch(e){let t=p(e);console.warn(`Something went wrong trying to logout the user: ${t}`),c.run("onLogoutFailure",t)}};var D=()=>new Date().setHours(new Date().getHours()+24),ae=n=>Date.now()>n;var F=async n=>{let e=d.get("address"),t=d.get("expires");if(!(typeof t=="number"?ae(t):!0)&&e&&n.networkProvider){let o=new A(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=p(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var Be=async(n,e,t,r="/")=>{let o=await re(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(u){let m=p(u);throw new Error(m)}if(!o)throw new Error("There were problems with auth provider initialization!");let a=o.getAccount();d.set("loginToken",e);let l=a?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let u=await o.getAddress();if(!u)throw new Error("Canceled!");d.set("address",u),d.set("loginMethod","browser-extension"),d.set("expires",D()),await F(n);let m=t.getToken(u,e,l);return d.set("accessToken",m),c.run("onLoginSuccess"),o}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var xe=async(n,e,t,r)=>{let o=new w(`${n}${E}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",T[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",D()),d.set("loginToken",e),o}catch(a){let l=p(a);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),c.run("onLoginFailure",l)}};var ce=async(n,e)=>{c.run("onTxSent",n);let r=await new Q(e).awaitCompleted(n.txHash),o=r.sender,i=new A(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),c.run("onTxFinalized",r)};var de=n=>{let e=n.sender,t=new A(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var qe=async(n,e,t,r)=>{if(f(B)===K&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),a=f("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=S(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&a&&(l=new w(`${t}${E}`).getTransactionsFromWalletUrl()?.[0]);if(l){let u=h.plainObjectToTransaction(l);u.nonce=BigInt(r),de(u);try{c.run("onTxStart",u);let m=await e.sendTransaction(u);await ce(m,e)}catch(m){let Ae=`Getting transaction information failed! ${p(m)}`;throw c.run("onTxFailure",u,Ae),new Error(Ae)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var ze=n=>{let e=d.get("activeGuardian");return e&&(n.version=j,n.options=ke,n.guardian=e),n},Qe=async(n,e)=>{let t=new w(`${e}${E}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},je=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ke=()=>{let n=!f("walletProviderStatus"),e=f("status")==="signed",t=f("message"),r=f("signature");n&&e&&t&&r&&(c.run("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ct(n){try{let e=atob(n),t=btoa(e),r=$(n),o=S(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function G(n){return ct(n)?atob(n):n}var le=n=>Object.prototype.toString.call(n)==="[object String]";var Ve=n=>{if(!n||!le(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(G(i)),a=G(t);return{ttl:Number(o),extraInfo:s,origin:a,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var Je=n=>{if(!n||!le(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=G(t),s=G(r),a=Ve(s);if(!a)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...a,address:i,body:s,signature:o};return a.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function Xe(n,e){let t=Je(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new L)}var Ye=n=>{n.onLoginStart&&c.set("onLoginStart",n.onLoginStart),n.onLoginSuccess&&c.set("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&c.set("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&c.set("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&c.set("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&c.set("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&c.set("onQrPending",e.onQrPending),e?.onQrLoaded&&c.set("onQrLoaded",e.onQrLoaded),n.onTxStart&&c.set("onTxStart",n.onTxStart),n.onTxSent&&c.set("onTxSent",n.onTxSent),n.onTxFinalized&&c.set("onTxFinalized",n.onTxFinalized),n.onTxFailure&&c.set("onTxFailure",n.onTxFailure),n.onSignMsgStart&&c.set("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&c.set("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&c.set("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&c.set("onQueryStart",n.onQueryStart),n.onQueryFinalized&&c.set("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&c.set("onQueryFailure",n.onQueryFailure)};var ue=async n=>{c.run("onLoginStart");try{await n(()=>{c.run("onLoginSuccess")})}catch(e){let t=p(e);console.warn(`Something went wrong trying to login the user: ${t}`),c.run("onLoginFailure",t)}};var Se=class{static async init(e){let t=d.get();if(t.expires&&ae(t.expires)){d.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:ne,apiUrl:He,apiTimeout:1e4,...e},this.networkProvider=new se(this.initOptions),Ye(this.initOptions);let r=this.initOptions?.externalSigningProviders?.mobile?.provider;if(r){let s={networkConfig:T,Message:b,Transaction:O,TransactionsConverter:h,ls:d,logout:ve,getNewLoginExpiresTimestamp:D,accountSync:F,EventsStore:c},a=this.initOptions?.externalSigningProviders?.mobile?.config;if(a)this.mobileProvider=new r(a,s);else throw new Error("Mobile provider config is required!")}let o=f("accessToken");o&&await ue(async s=>{Xe(o,this),await F(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&f("address"))&&t?.loginMethod&&(await ue(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await re()),t.loginMethod==="mobile"&&this.mobileProvider&&(this.dappProvider=await this.mobileProvider?.initMobileProvider(this)),t.loginMethod==="webview"&&(this.dappProvider=new L),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await ye(T[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await ye(T[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await F(this),s()}),this.initOptions?.chainType&&(await qe(this.dappProvider,this.networkProvider,T[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),Ke()))}static async login(e,t){if(!Object.values(k).includes(e)){let o="Wrong login method!";throw c.run("onLoginFailure",o),new Error(o)}if(!this.networkProvider){let o="Login failed: Use ElvenJs.init() first!";throw c.run("onLoginFailure",o),new Error(o)}await ue(async()=>{let o=new _({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),i=await o.initialize({timestamp:`${Math.floor(Date.now()/1e3)}`});if(e==="browser-extension"){let s=await Be(this,i,o,t?.callbackRoute);this.dappProvider=s}if(e==="mobile"&&this.mobileProvider){let s=await this.mobileProvider?.loginWithMobile(this,i,o);this.dappProvider=s}if(e==="web-wallet"&&this.initOptions?.chainType){let s=await xe(T[this.initOptions.chainType].walletAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}if(e==="x-alias"&&this.initOptions?.chainType){let s=await xe(T[this.initOptions.chainType].xAliasAddress,i,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=s}})}static async logout(){try{let e=await ve(this);return this.dappProvider=void 0,e}catch(e){let t=p(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let r="Transaction signing failed: There is no active session!";throw c.run("onTxFailure",e,r),new Error(r)}if(!this.networkProvider){let r="Transaction signing failed: There is no active network provider!";throw c.run("onTxFailure",e,r),new Error(r)}let t=ze(e);try{c.run("onTxStart",e);let r=d.get();if(e.nonce=r.nonce,this.dappProvider instanceof U&&(t=await this.dappProvider.signTransaction(e)),this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof L&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof w&&await this.dappProvider.signTransaction(e),r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"){let o=je(t);if(o||de(t),o&&this.initOptions?.chainType){await Qe(t,T[this.initOptions.chainType].walletAddress);return}let i=await this.networkProvider.sendTransaction(t);await ce(i,this.networkProvider)}}catch(r){let o=p(r);throw c.run("onTxFailure",t,`Getting transaction information failed! ${o}`),new Error(`Getting transaction information failed! ${o}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let o="Message signing failed: There is no active session!";throw c.run("onSignMsgFailure",e,o),new Error(o)}if(!this.networkProvider){let o="Message signing failed: There is no active network provider!";throw c.run("onSignMsgFailure",e,o),new Error(o)}let r="";try{if(c.run("onSignMsgStart",e),this.dappProvider instanceof U){let i=await this.dappProvider.signMessage(new b({data:R(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.mobileProvider&&this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider){let i=await this.dappProvider.signMessage(new b({data:R(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof L){let i=await this.dappProvider.signMessage(new b({data:R(e)}));typeof i!="string"&&i?.signature&&(r=y(i.signature))}if(this.dappProvider instanceof w){let i=a=>encodeURIComponent(a).replace(/[!'()*]/g,l=>`%${l.charCodeAt(0).toString(16).toUpperCase()}`),s=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new b({data:R(e)}),{callbackUrl:encodeURIComponent(`${s}${s.includes("?")?"&":"?"}message=${i(e)}`)})}let o=d.get();return o.loginMethod!=="web-wallet"&&o.loginMethod!=="x-alias"&&c.run("onSignMsgFinalized",e,r),{message:e,messageSignature:r}}catch(o){let i=p(o);throw c.run("onSignMsgFailure",e,i),new Error(`Message signing failed! ${i}`)}}static async queryContract({address:e,func:t,args:r=[],value:o=0,caller:i}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let s={address:e,func:t,args:r,value:o,caller:i};try{c.run("onQueryStart",s);let a=await this.networkProvider.queryContract(s);return c.run("onQueryFinalized",a),a}catch(a){let l=p(a);throw c.run("onQueryFinalized",s,l),new Error(`Smart contract query failed! ${l}`)}}static{this.storage=d}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,c.clear()}}};var dt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},Ze=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),m=BigInt(n)+u;return r&&(m=-m),Ze({amount:m,decimals:e,rounding:t})}}let a=`${i}.${s.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),r&&(a=`-${a}`),a};export{A as Account,at as DappCoreWCV2CustomMethodsEnum,Se as ElvenJS,P as EventStoreEvents,k as LoginMethodsEnum,O as Transaction,Q as TransactionWatcher,be as WebWalletUrlParamsEnum,Ze as formatAmount,dt as parseAmount}; +var ot=Object.defineProperty;var st=(n,e)=>{for(var t in e)ot(n,t,{get:e[t],enumerable:!0})};var D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ne=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),L=n=>at.encode(n),N=n=>ct.decode(n),A=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),Ue=n=>b(L(n)),k=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let c=0;c=8&&(i-=8,r[s++]=o>>i&255)}return r},dt=n=>{let e="",t=n.length;for(let r=0;r>18&63,g=c>>12&63,T=c>>6&63,Ie=c&63;e+=D.charAt(l),e+=D.charAt(g),e+=r+1N(k(n)),R=n=>{let e=typeof n=="string"?L(n):n;return dt(e)};function lt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function ut(n,e,t){let r=n;for(let o=0;o{he([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&he([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function Te(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=lt(r);ut(t,i,o)}return t}function ke(n){let e=[];return he([],n,e),e.join("&")}var gt=()=>typeof window<"u"&&typeof window.location<"u",Q=()=>{if(gt()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},we=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var I=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Oe(e)&&(this.address=A(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:b(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return b(this.address)}};var Me=1e9,We=0,X=2,_e=2,ye=64,De=1;var Fe="sdk-js";var Ge="hook/login",$e="hook/logout";var He="hook/sign",Be="hook/2fa",qe="hook/sign-message",j="walletProviderStatus",Y="transactionsSigned";var ze={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var C=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||Me),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||X),this.options=Number(e.options?.valueOf()||We),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var S=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var Z=class extends S{constructor(){super("Async timer already running")}},ee=class extends S{constructor(){super("Async timer aborted")}};var F=class extends S{constructor(){super("Expected transaction status not reached")}},K=class extends S{constructor(){super("Expected transaction events not found")}};var te=class extends S{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var ne=class extends S{constructor(){super("Cannot sign single transaction.")}},re=class extends S{constructor(){super("Account is not connected.")}},V=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},ie=class extends Error{constructor(){super("Cannot get signed message")}};var G=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new Z;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new ee),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var ve=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},J=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new ve(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new F;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new te;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new F;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let c=this.getAllTransactionEvents(s).map(g=>g.identifier);return t.every(g=>c.includes(g))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new K;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let c=this.getAllTransactionEvents(s).map(g=>g.identifier);return t.find(g=>c.includes(g))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new K;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new F;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==ye)throw new S(`Invalid transaction hash length. The length of a hex encoded hash should be ${ye}.`);return t}async awaitConditionally(e,t,r){let o=new G("watcher:periodic"),i=new G("watcher:patience"),s=new G("watcher:timeout"),c=!1,l,g=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),c=!0});!c&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),g=e(l),!(g||c)););if(g&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!g)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var x=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||De,this.signer=e.signer||Fe}};var h=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?R(e.senderUsername):void 0,receiverUsername:e.receiverUsername?R(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?R(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?b(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?b(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new C({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:z(e.receiverUsername||""),sender:e.sender,senderUsername:z(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?k(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?A(e.signature):void 0,guardianSignature:e.guardianSignature?A(e.guardianSignature):void 0})}};var M=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new ne;return t[0]}ensureConnected(){if(!this.account.address)throw new re}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>h.transactionToPlainObject(r))});try{return t.map(o=>h.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:N(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=A(o);return new x({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var oe="elvenjs_state",Qe="https://devnet-api.multiversx.com";var O="/dapp/init",se="devnet";var y={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(oe);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(oe,JSON.stringify(t))},clear(){localStorage.removeItem(oe)}};var ae=async()=>{let n=M.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var be=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},v=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:Ge,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:$e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:qe,callbackUrl:t?.callbackUrl,params:{message:N(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=Te(e);if((t.status?.toString()||"")!=="signed")throw new ie;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Be,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(He,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=Te(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,j)&&e[j]===Y}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new V;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new V;let o=[];for(let i=0;i{let c=n.prepareWalletTransaction(s);for(let l in c)Object.prototype.hasOwnProperty.call(c,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(c[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var xe=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*2}},$=class{constructor(e){this.config=Object.assign(new xe,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(R(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var ce=(n,e)=>t=>{let r=t.data;try{r=we()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!we()&&t.origin!=Q()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",ce(n,e)),e({type:o,payload:i}))};var U=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",ce("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>h.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>h.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:N(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new x({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:A(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),Q()):t.parent&&t.parent.postMessage(e,Q())),await this.waitingForResponse(ze[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",ce(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var w=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var Se=async(n,e)=>{let t=w("signature"),r=w("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new v(`${n}${O}`);if(t&&e&&r){let l=new $({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var de=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var le=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||se,this.apiUrl=e||y[this.chainType]?.apiAddress,this.apiTimeout=r||y[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),c=await s.json();if(!s.ok){let l=c?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),c}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let c=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await c.json();if(!c.ok){let g=l?.error||c.status;return clearTimeout(i),Promise.reject(g)}return clearTimeout(i),l}catch(c){this.handleApiError(c,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=h.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new de(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:k(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>Ue(l))},c=await this.apiPost("query",s);return{returnData:c.returnData,returnCode:c.returnCode,returnMessage:c.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var E=(m=>(m.onLoginStart="onLoginStart",m.onLoginSuccess="onLoginSuccess",m.onLoginFailure="onLoginFailure",m.onLogoutStart="onLogoutStart",m.onLogoutSuccess="onLogoutSuccess",m.onLogoutFailure="onLogoutFailure",m.onQrPending="onQrPending",m.onQrLoaded="onQrLoaded",m.onTxStart="onTxStart",m.onTxSent="onTxSent",m.onTxFinalized="onTxFinalized",m.onTxFailure="onTxFailure",m.onSignMsgStart="onSignMsgStart",m.onSignMsgFinalized="onSignMsgFinalized",m.onSignMsgFailure="onSignMsgFailure",m.onQueryStart="onQueryStart",m.onQueryFinalized="onQueryFinalized",m.onQueryFailure="onQueryFailure",m))(E||{}),W=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(W||{}),mt=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(mt||{}),Pe=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(Pe||{});var P={};st(P,{clear:()=>Ae,get:()=>ft,run:()=>u,set:()=>p});var _;function p(n,e){n&&(_={..._,[n]:e})}function ft(n){if(!(!n||!_))return _[n]}function u(n,...e){!n||!_||_[n]?.(...e)}function Ae(){_=void 0}var f=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var Re=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");u("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),u("onLogoutSuccess")),e}catch(e){let t=f(e);console.warn(`Something went wrong trying to logout the user: ${t}`),u("onLogoutFailure",t)}};var H=()=>new Date().setHours(new Date().getHours()+24),ue=n=>Date.now()>n;var B=async n=>{let e=d.get("address"),t=d.get("expires");if(!(typeof t=="number"?ue(t):!0)&&e&&n.networkProvider){let o=new I(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=f(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var je=async(n,e,t,r="/")=>{let o=await ae(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(g){let T=f(g);throw new Error(T)}if(!o)throw new Error("There were problems with auth provider initialization!");let c=o.getAccount();d.set("loginToken",e);let l=c?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let g=await o.getAddress();if(!g)throw new Error("Canceled!");d.set("address",g),d.set("loginMethod","browser-extension"),d.set("expires",H()),await B(n);let T=t.getToken(g,e,l);return d.set("accessToken",T),u("onLoginSuccess"),o}catch(g){throw new Error(`Something went wrong trying to synchronize the user account: ${g?.message}`)}};var Ee=async(n,e,t,r)=>{let o=new v(`${n}${O}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",y[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",H()),d.set("loginToken",e),o}catch(c){let l=f(c);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),u("onLoginFailure",l)}};var ge=async(n,e)=>{u("onTxSent",n);let r=await new J(e).awaitCompleted(n.txHash),o=r.sender,i=new I(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),u("onTxFinalized",r)};var pe=n=>{let e=n.sender,t=new I(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var Ke=async(n,e,t,r)=>{if(w(j)===Y&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),c=w("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=R(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&c&&(l=new v(`${t}${O}`).getTransactionsFromWalletUrl()?.[0]);if(l){let g=h.plainObjectToTransaction(l);g.nonce=BigInt(r),pe(g);try{u("onTxStart",g);let T=await e.sendTransaction(g);await ge(T,e)}catch(T){let Le=`Getting transaction information failed! ${f(T)}`;throw u("onTxFailure",g,Le),new Error(Le)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var Ve=n=>{let e=d.get("activeGuardian");return e&&(n.version=X,n.options=_e,n.guardian=e),n},Je=async(n,e)=>{let t=new v(`${e}${O}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},Xe=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ye=()=>{let n=!w("walletProviderStatus"),e=w("status")==="signed",t=w("message"),r=w("signature");n&&e&&t&&r&&(u("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ht(n){try{let e=atob(n),t=btoa(e),r=z(n),o=R(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function q(n){return ht(n)?atob(n):n}var me=n=>Object.prototype.toString.call(n)==="[object String]";var Ze=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(q(i)),c=q(t);return{ttl:Number(o),extraInfo:s,origin:c,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var et=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=q(t),s=q(r),c=Ze(s);if(!c)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...c,address:i,body:s,signature:o};return c.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function tt(n,e){let t=et(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new U)}var nt=n=>{n.onLoginStart&&p("onLoginStart",n.onLoginStart),n.onLoginSuccess&&p("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&p("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&p("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&p("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&p("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&p("onQrPending",e.onQrPending),e?.onQrLoaded&&p("onQrLoaded",e.onQrLoaded),n.onTxStart&&p("onTxStart",n.onTxStart),n.onTxSent&&p("onTxSent",n.onTxSent),n.onTxFinalized&&p("onTxFinalized",n.onTxFinalized),n.onTxFailure&&p("onTxFailure",n.onTxFailure),n.onSignMsgStart&&p("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&p("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&p("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&p("onQueryStart",n.onQueryStart),n.onQueryFinalized&&p("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&p("onQueryFailure",n.onQueryFailure)};var fe=async n=>{u("onLoginStart");try{await n(()=>{u("onLoginSuccess")})}catch(e){let t=f(e);console.warn(`Something went wrong trying to login the user: ${t}`),u("onLoginFailure",t)}};var a={initOptions:void 0,dappProvider:void 0,networkProvider:void 0,mobileProvider:void 0},rt=()=>{a.initOptions=void 0,a.dappProvider=void 0,a.networkProvider=void 0,a.mobileProvider=void 0};var Qi=async n=>{let e=d.get();if(e.expires&&ue(e.expires)){d.clear(),a.dappProvider=void 0;return}a.initOptions={chainType:se,apiUrl:Qe,apiTimeout:1e4,...n},a.networkProvider=new le(a.initOptions),nt(a.initOptions);let t=a.initOptions?.externalSigningProviders?.mobile?.provider;if(t){let i={networkConfig:y,Message:x,Transaction:C,TransactionsConverter:h,ls:d,logout:Re,getNewLoginExpiresTimestamp:H,accountSync:B,EventsStore:P},s=a.initOptions?.externalSigningProviders?.mobile?.config;if(s)a.mobileProvider=new t(s,i);else throw new Error("Mobile provider config is required!")}let r=w("accessToken");r&&await fe(async i=>{tt(r,a),await B(a),i()}),(e?.address||(e.loginMethod==="web-wallet"||e.loginMethod==="x-alias")&&w("address"))&&e?.loginMethod&&(await fe(async i=>{e.loginMethod==="browser-extension"&&(a.dappProvider=await ae()),e.loginMethod==="mobile"&&a.mobileProvider&&(a.dappProvider=await a.mobileProvider?.initMobileProvider(a)),e.loginMethod==="webview"&&(a.dappProvider=new U),e.loginMethod==="web-wallet"&&a.initOptions?.chainType&&(a.dappProvider=await Se(y[a.initOptions.chainType].walletAddress,a.initOptions.apiUrl)),e.loginMethod==="x-alias"&&a.initOptions?.chainType&&(a.dappProvider=await Se(y[a.initOptions.chainType].xAliasAddress,a.initOptions.apiUrl)),await B(a),i()}),a.initOptions?.chainType&&(await Ke(a.dappProvider,a.networkProvider,y[a.initOptions.chainType][e.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],e.nonce),Ye()))},ji=async(n,e)=>{if(!Object.values(W).includes(n)){let r="Wrong login method!";throw u("onLoginFailure",r),new Error(r)}if(!a.networkProvider){let r="Login failed: Use ElvenJs.init() first!";throw u("onLoginFailure",r),new Error(r)}await fe(async()=>{let r=new $({apiUrl:a.initOptions?.apiUrl,origin:window.location.origin}),o=await r.initialize({timestamp:`${Math.floor(Date.now()/1e3)}`});if(n==="browser-extension"){let i=await je(a,o,r,e?.callbackRoute);a.dappProvider=i}if(n==="mobile"&&a.mobileProvider){let i=await a.mobileProvider?.loginWithMobile(a,o,r);a.dappProvider=i}if(n==="web-wallet"&&a.initOptions?.chainType){let i=await Ee(y[a.initOptions.chainType].walletAddress,o,a.initOptions?.chainType,e?.callbackRoute);a.dappProvider=i}if(n==="x-alias"&&a.initOptions?.chainType){let i=await Ee(y[a.initOptions.chainType].xAliasAddress,o,a.initOptions?.chainType,e?.callbackRoute);a.dappProvider=i}})},Ki=async()=>{try{let n=await Re(a);return a.dappProvider=void 0,n}catch(n){let e=f(n);console.warn("Something went wrong when logging out: ",e)}},Vi=async n=>{if(!a.dappProvider){let t="Transaction signing failed: There is no active session!";throw u("onTxFailure",n,t),new Error(t)}if(!a.networkProvider){let t="Transaction signing failed: There is no active network provider!";throw u("onTxFailure",n,t),new Error(t)}let e=Ve(n);try{u("onTxStart",n);let t=d.get();if(n.nonce=t.nonce,a.dappProvider instanceof M&&(e=await a.dappProvider.signTransaction(n)),a.mobileProvider&&a.dappProvider instanceof a.mobileProvider.WalletConnectV2Provider&&(e=await a.dappProvider.signTransaction(n)),a.dappProvider instanceof U&&(e=await a.dappProvider.signTransaction(n)),a.dappProvider instanceof v&&await a.dappProvider.signTransaction(n),t.loginMethod!=="web-wallet"&&t.loginMethod!=="x-alias"){let r=Xe(e);if(r||pe(e),r&&a.initOptions?.chainType){await Je(e,y[a.initOptions.chainType].walletAddress);return}let o=await a.networkProvider.sendTransaction(e);await ge(o,a.networkProvider)}}catch(t){let r=f(t);throw u("onTxFailure",e,`Getting transaction information failed! ${r}`),new Error(`Getting transaction information failed! ${r}`)}return e},Ji=async(n,e)=>{if(!a.dappProvider){let r="Message signing failed: There is no active session!";throw u("onSignMsgFailure",n,r),new Error(r)}if(!a.networkProvider){let r="Message signing failed: There is no active network provider!";throw u("onSignMsgFailure",n,r),new Error(r)}let t="";try{if(u("onSignMsgStart",n),a.dappProvider instanceof M){let o=await a.dappProvider.signMessage(new x({data:L(n)}));typeof o!="string"&&o?.signature&&(t=b(o.signature))}if(a.mobileProvider&&a.dappProvider instanceof a.mobileProvider.WalletConnectV2Provider){let o=await a.dappProvider.signMessage(new x({data:L(n)}));typeof o!="string"&&o?.signature&&(t=b(o.signature))}if(a.dappProvider instanceof U){let o=await a.dappProvider.signMessage(new x({data:L(n)}));typeof o!="string"&&o?.signature&&(t=b(o.signature))}if(a.dappProvider instanceof v){let o=s=>encodeURIComponent(s).replace(/[!'()*]/g,c=>`%${c.charCodeAt(0).toString(16).toUpperCase()}`),i=e?.callbackUrl||window.location.origin;await a.dappProvider.signMessage(new x({data:L(n)}),{callbackUrl:encodeURIComponent(`${i}${i.includes("?")?"&":"?"}message=${o(n)}`)})}let r=d.get();return r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"&&u("onSignMsgFinalized",n,t),{message:n,messageSignature:t}}catch(r){let o=f(r);throw u("onSignMsgFailure",n,o),new Error(`Message signing failed! ${o}`)}},Xi=async({address:n,func:e,args:t=[],value:r=0,caller:o})=>{if(!a.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!n||!e)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let i={address:n,func:e,args:t,value:r,caller:o};try{u("onQueryStart",i);let s=await a.networkProvider.queryContract(i);return u("onQueryFinalized",s),s}catch(s){let c=f(s);throw u("onQueryFinalized",i,c),new Error(`Smart contract query failed! ${c}`)}},Yi=d,Zi=()=>{rt(),Ae()};var Tt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},it=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let g=BigInt("1"+"0".repeat(e-t)),T=BigInt(n)+g;return r&&(T=-T),it({amount:T,decimals:e,rounding:t})}}let c=`${i}.${s.padEnd(t,"0")}`;return c=c.replace(/\.?0+$/,""),r&&(c=`-${c}`),c};export{I as Account,mt as DappCoreWCV2CustomMethodsEnum,E as EventStoreEvents,W as LoginMethodsEnum,C as Transaction,J as TransactionWatcher,Pe as WebWalletUrlParamsEnum,Zi as destroy,it as formatAmount,Qi as init,ji as login,Ki as logout,Tt as parseAmount,Xi as queryContract,Vi as signAndSendTransaction,Ji as signMessage,Yi as storage}; /** keccak.js https://github.com/adraffy/keccak.js @license MIT */ /** https://github.com/emn178/js-sha3/blob/master/src/sha3.js @license MIT */ diff --git a/demo-app/index.html b/demo-app/index.html index a3422dd..17e296f 100644 --- a/demo-app/index.html +++ b/demo-app/index.html @@ -168,7 +168,13 @@

Other demos:

// Elven.js tools import { - ElvenJS, + init, + login, + logout, + storage, + signMessage, + signAndSendTransaction, + queryContract, Transaction, parseAmount, } from './elven.js'; @@ -179,7 +185,7 @@

Other demos:

// You don't have to add them if you want to use default setup // You can only add your custom callbacks const initElven = async () => { - await ElvenJS.init( + await init( { apiUrl: 'https://devnet-api.multiversx.com', chainType: 'devnet', @@ -240,7 +246,7 @@

Other demos:

document.getElementById('button-login-extension').addEventListener('click', async () => { try { clearQrCodeContainer(); - await ElvenJS.login('browser-extension'); + await login('browser-extension'); } catch (e) { console.log('Login: Something went wrong, try again!', e?.message); } @@ -249,7 +255,7 @@

Other demos:

document.getElementById('button-login-mobile').addEventListener('click', async () => { clearQrCodeContainer(); try { - await ElvenJS.login('mobile'); + await login('mobile'); } catch (e) { console.log('Login: Something went wrong, try again!', e?.message); } @@ -258,7 +264,7 @@

Other demos:

document.getElementById('button-login-web').addEventListener('click', async () => { try { clearQrCodeContainer(); - await ElvenJS.login('web-wallet', { + await login('web-wallet', { callbackRoute: '/', }); } catch (e) { @@ -269,7 +275,7 @@

Other demos:

document.getElementById('button-login-x-alias').addEventListener('click', async () => { try { clearQrCodeContainer(); - await ElvenJS.login('x-alias', { + await login('x-alias', { callbackRoute: '/', }); } catch (e) { @@ -279,7 +285,7 @@

Other demos:

document.getElementById('button-logout').addEventListener('click', async () => { try { - const isLoggedOut = await ElvenJS.logout(); + const isLoggedOut = await logout(); } catch (e) { console.error(e.message); } @@ -291,8 +297,8 @@

Other demos:

document.getElementById('button-tx').addEventListener('click', async () => { const demoMessage = 'Transaction demo from Elven.js!'; - const isGuardian = ElvenJS.storage.get('activeGuardian'); - const isXalias = ElvenJS.storage.get('loginMethod') === 'x-alias'; + const isGuardian = storage.get('activeGuardian'); + const isXalias = storage.get('loginMethod') === 'x-alias'; // Additional 50000 when there is an active guardian // See more about gas limit calculation here: https://docs.multiversx.com/developers/gas-and-fees/overview/ const gasLimit = ((isGuardian || isXalias) ? 100000 : 50000) + 1500 * demoMessage.length; @@ -300,17 +306,17 @@

Other demos:

const textEncoder = new TextEncoder(); const tx = new Transaction({ - nonce: ElvenJS.storage.get('nonce'), + nonce: storage.get('nonce'), receiver: egldTransferAddress, gasLimit, chainID: 'D', data: textEncoder.encode(demoMessage), value: parseAmount({ amount: '0.001', decimals: 18 }), - sender: ElvenJS.storage.get('address'), + sender: storage.get('address'), }); try { - await ElvenJS.signAndSendTransaction(tx); + await signAndSendTransaction(tx); } catch (e) { throw new Error(e?.message); } @@ -335,12 +341,12 @@

Other demos:

const tx = factory.createTransactionForESDTTokenTransfer({ receiver: new Address(esdtTransferAddress), - sender: new Address(ElvenJS.storage.get('address')), + sender: new Address(storage.get('address')), tokenTransfers: [tokenTransfer] }); try { - await ElvenJS.signAndSendTransaction(tx); + await signAndSendTransaction(tx); } catch (e) { throw new Error(e?.message); } @@ -352,7 +358,7 @@

Other demos:

document.getElementById('button-mint').addEventListener('click', async () => { const contractAddress = new Address(nftMinterSmartContract); - const isGuardian = ElvenJS.storage.get('activeGuardian'); + const isGuardian = storage.get('activeGuardian'); // Additional 50000 when there is an active guardian // See more about gas limit calculation here: https://docs.multiversx.com/developers/gas-and-fees/overview/ const gasLimit = isGuardian ? 14050000 : 14000000; @@ -362,7 +368,7 @@

Other demos:

}); const tx = factory.createTransactionForExecute({ - sender: new Address(ElvenJS.storage.get('address')), + sender: new Address(storage.get('address')), contract: new Address(contractAddress), function: 'mint', nativeTransferAmount: parseAmount({ amount: '0.01', decimals: 18 }), @@ -371,7 +377,7 @@

Other demos:

}); try { - await ElvenJS.signAndSendTransaction(tx); + await signAndSendTransaction(tx); } catch (e) { throw new Error(e?.message); } @@ -385,10 +391,10 @@

Other demos:

// Read more about the Elven Tools Smart Contract here: https://www.elven.tools/docs/sc-endpoints.html document.getElementById('button-query').addEventListener('click', async () => { try { - await ElvenJS.queryContract({ + await queryContract({ address: new Address(nftMinterSmartContract), func: 'getMintedPerAddressTotal', - args: [new AddressValue(new Address(ElvenJS.storage.get('address')))] + args: [new AddressValue(new Address(storage.get('address')))] }); } catch (e) { throw new Error(e?.message); @@ -397,10 +403,10 @@

Other demos:

// You can sign a single message, use // You will get a message and signature back in the ElvenJS callback function 'onSignMsgFinalized' - // In case of browser extension provider and xPortal you can also get it from ElvenJS.signMessage return + // In case of browser extension provider and xPortal you can also get it from signMessage return document.getElementById('button-sign-message').addEventListener('click', async () => { try { - await ElvenJS.signMessage('ElvenFamily'); + await signMessage('ElvenFamily'); } catch (e) { throw new Error(e?.message); } diff --git a/demo-app/mobile-signing-provider.js b/demo-app/mobile-signing-provider.js index 83de21e..eac6c71 100644 --- a/demo-app/mobile-signing-provider.js +++ b/demo-app/mobile-signing-provider.js @@ -6,7 +6,7 @@ * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE */ -var _y=Object.create;var Jo=Object.defineProperty;var xy=Object.getOwnPropertyDescriptor;var Ey=Object.getOwnPropertyNames;var Sy=Object.getPrototypeOf,Iy=Object.prototype.hasOwnProperty;var al=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var My=(r,e)=>()=>(r&&(e=r(r=0)),e);var Z=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Dt=(r,e)=>{for(var t in e)Jo(r,t,{get:e[t],enumerable:!0})},Wo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ey(e))!Iy.call(r,n)&&n!==t&&Jo(r,n,{get:()=>e[n],enumerable:!(i=xy(e,n))||i.enumerable});return r},qt=(r,e,t)=>(Wo(r,e,"default"),t&&Wo(t,e,"default")),qe=(r,e,t)=>(t=r!=null?_y(Sy(r)):{},Wo(e||!r||!r.__esModule?Jo(t,"default",{value:r,enumerable:!0}):t,r)),qs=r=>Wo(Jo({},"__esModule",{value:!0}),r);var un=Z((BS,uc)=>{"use strict";var qn=typeof Reflect=="object"?Reflect:null,fl=qn&&typeof qn.apply=="function"?qn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Yo;qn&&typeof qn.ownKeys=="function"?Yo=qn.ownKeys:Object.getOwnPropertySymbols?Yo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yo=function(e){return Object.getOwnPropertyNames(e)};function Ay(r){console&&console.warn&&console.warn(r)}var hl=Number.isNaN||function(e){return e!==e};function Ke(){Ke.init.call(this)}uc.exports=Ke;uc.exports.once=Py;Ke.EventEmitter=Ke;Ke.prototype._events=void 0;Ke.prototype._eventsCount=0;Ke.prototype._maxListeners=void 0;var cl=10;function Xo(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ke,"defaultMaxListeners",{enumerable:!0,get:function(){return cl},set:function(r){if(typeof r!="number"||r<0||hl(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");cl=r}});Ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ke.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||hl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ul(r){return r._maxListeners===void 0?Ke.defaultMaxListeners:r._maxListeners}Ke.prototype.getMaxListeners=function(){return ul(this)};Ke.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var u=s[e];if(u===void 0)return!1;if(typeof u=="function")fl(u,this,t);else for(var c=u.length,b=bl(u,c),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,Ay(f)}return r}Ke.prototype.addListener=function(e,t){return dl(this,e,t,!1)};Ke.prototype.on=Ke.prototype.addListener;Ke.prototype.prependListener=function(e,t){return dl(this,e,t,!0)};function Ry(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ll(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=Ry.bind(i);return n.listener=t,i.wrapFn=n,n}Ke.prototype.once=function(e,t){return Xo(t),this.on(e,ll(this,e,t)),this};Ke.prototype.prependOnceListener=function(e,t){return Xo(t),this.prependListener(e,ll(this,e,t)),this};Ke.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Xo(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Ty(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ke.prototype.off=Ke.prototype.removeListener;Ke.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function pl(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?Dy(n):bl(n,n.length)}Ke.prototype.listeners=function(e){return pl(this,e,!0)};Ke.prototype.rawListeners=function(e){return pl(this,e,!1)};Ke.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):gl.call(r,e)};Ke.prototype.listenerCount=gl;function gl(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ke.prototype.eventNames=function(){return this._eventsCount>0?Yo(this._events):[]};function bl(r,e){for(var t=new Array(e),i=0;ilc,__asyncDelegator:()=>$y,__asyncGenerator:()=>Vy,__asyncValues:()=>Hy,__await:()=>Us,__awaiter:()=>Uy,__classPrivateFieldGet:()=>Yy,__classPrivateFieldSet:()=>Xy,__createBinding:()=>By,__decorate:()=>Ly,__exportStar:()=>ky,__extends:()=>Cy,__generator:()=>zy,__importDefault:()=>Jy,__importStar:()=>Wy,__makeTemplateObject:()=>Gy,__metadata:()=>qy,__param:()=>Fy,__read:()=>ml,__rest:()=>Oy,__spread:()=>Ky,__spreadArrays:()=>jy,__values:()=>pc});function Cy(r,e){dc(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Fy(r,e){return function(t,i){e(t,i,r)}}function qy(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Uy(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{c(i.next(b))}catch(v){o(v)}}function u(b){try{c(i.throw(b))}catch(v){o(v)}}function c(b){b.done?s(b.value):n(b.value).then(f,u)}c((i=i.apply(r,e||[])).next())})}function zy(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(c){return function(b){return u([c,b])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=c[0]&2?n.return:c[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,c[1])).done)return s;switch(n=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,n=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ml(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Ky(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{u(i[S](I))}catch(M){v(s[0][3],M)}}function u(S){S.value instanceof Us?Promise.resolve(S.value.v).then(c,b):v(s[0][2],S)}function c(S){f("next",S)}function b(S){f("throw",S)}function v(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function $y(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Us(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function Hy(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof pc=="function"?pc(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(c){s({value:c,done:f})},o)}}function Gy(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wy(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function Jy(r){return r&&r.__esModule?r:{default:r}}function Yy(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Xy(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var dc,lc,zn=My(()=>{dc=function(r,e){return dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},dc(r,e)};lc=function(){return lc=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.delay=void 0;function Zy(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Zo.delay=Zy});var wl=Z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.ONE_THOUSAND=Bn.ONE_HUNDRED=void 0;Bn.ONE_HUNDRED=100;Bn.ONE_THOUSAND=1e3});var _l=Z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.ONE_YEAR=Q.FOUR_WEEKS=Q.THREE_WEEKS=Q.TWO_WEEKS=Q.ONE_WEEK=Q.THIRTY_DAYS=Q.SEVEN_DAYS=Q.FIVE_DAYS=Q.THREE_DAYS=Q.ONE_DAY=Q.TWENTY_FOUR_HOURS=Q.TWELVE_HOURS=Q.SIX_HOURS=Q.THREE_HOURS=Q.ONE_HOUR=Q.SIXTY_MINUTES=Q.THIRTY_MINUTES=Q.TEN_MINUTES=Q.FIVE_MINUTES=Q.ONE_MINUTE=Q.SIXTY_SECONDS=Q.THIRTY_SECONDS=Q.TEN_SECONDS=Q.FIVE_SECONDS=Q.ONE_SECOND=void 0;Q.ONE_SECOND=1;Q.FIVE_SECONDS=5;Q.TEN_SECONDS=10;Q.THIRTY_SECONDS=30;Q.SIXTY_SECONDS=60;Q.ONE_MINUTE=Q.SIXTY_SECONDS;Q.FIVE_MINUTES=Q.ONE_MINUTE*5;Q.TEN_MINUTES=Q.ONE_MINUTE*10;Q.THIRTY_MINUTES=Q.ONE_MINUTE*30;Q.SIXTY_MINUTES=Q.ONE_MINUTE*60;Q.ONE_HOUR=Q.SIXTY_MINUTES;Q.THREE_HOURS=Q.ONE_HOUR*3;Q.SIX_HOURS=Q.ONE_HOUR*6;Q.TWELVE_HOURS=Q.ONE_HOUR*12;Q.TWENTY_FOUR_HOURS=Q.ONE_HOUR*24;Q.ONE_DAY=Q.TWENTY_FOUR_HOURS;Q.THREE_DAYS=Q.ONE_DAY*3;Q.FIVE_DAYS=Q.ONE_DAY*5;Q.SEVEN_DAYS=Q.ONE_DAY*7;Q.THIRTY_DAYS=Q.ONE_DAY*30;Q.ONE_WEEK=Q.SEVEN_DAYS;Q.TWO_WEEKS=Q.ONE_WEEK*2;Q.THREE_WEEKS=Q.ONE_WEEK*3;Q.FOUR_WEEKS=Q.ONE_WEEK*4;Q.ONE_YEAR=Q.ONE_DAY*365});var gc=Z(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});var xl=(zn(),qs(Un));xl.__exportStar(wl(),Qo);xl.__exportStar(_l(),Qo)});var Sl=Z(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.fromMiliseconds=kn.toMiliseconds=void 0;var El=gc();function Qy(r){return r*El.ONE_THOUSAND}kn.toMiliseconds=Qy;function e2(r){return Math.floor(r/El.ONE_THOUSAND)}kn.fromMiliseconds=e2});var Ml=Z(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var Il=(zn(),qs(Un));Il.__exportStar(yl(),ea);Il.__exportStar(Sl(),ea)});var Al=Z(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.Watch=void 0;var ta=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};zs.Watch=ta;zs.default=ta});var Rl=Z(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.IWatch=void 0;var bc=class{};ra.IWatch=bc});var Tl=Z(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var t2=(zn(),qs(Un));t2.__exportStar(Rl(),vc)});var jn=Z(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var ia=(zn(),qs(Un));ia.__exportStar(Ml(),Kn);ia.__exportStar(Al(),Kn);ia.__exportStar(Tl(),Kn);ia.__exportStar(gc(),Kn)});var $l=Z((lI,Vl)=>{"use strict";function E2(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}Vl.exports=S2;function S2(r,e,t){var i=t&&t.stringify||E2,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?v:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=u||e[b]==null)break;v=u||e[b]==null)break;v=u||e[b]===void 0)break;v",v=I+2,I++;break}c+=i(e[b]),v=I+2,I++;break;case 115:if(b>=u)break;v{"use strict";var Hl=$l();Jl.exports=qr;var Vs=O2().console||{},I2={mapHttpRequest:fa,mapHttpResponse:fa,wrapRequestSerializer:Mc,wrapResponseSerializer:Mc,wrapErrorSerializer:Mc,req:fa,res:fa,err:D2};function M2(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function qr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||Vs;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=M2(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",u=Object.create(t);u.log||(u.log=$s),Object.defineProperty(u,"levelVal",{get:b}),Object.defineProperty(u,"level",{get:v,set:S});let c={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:P2(r)};u.levels=qr.levels,u.level=f,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=$s,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=I,e&&(u._logEvent=Ac());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function v(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,Vn(c,u,"error","log"),Vn(c,u,"fatal","error"),Vn(c,u,"warn","error"),Vn(c,u,"info","log"),Vn(c,u,"debug","log"),Vn(c,u,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let O=T.serializers;if(n&&O){var P=Object.assign({},i,O),z=r.browser.serialize===!0?Object.keys(P):n;delete M.serializers,ca([M],z,P,this._stdErrSerialize)}function B(U){this._childLevel=(U._childLevel|0)+1,this.error=$n(U,M,"error"),this.fatal=$n(U,M,"fatal"),this.warn=$n(U,M,"warn"),this.info=$n(U,M,"info"),this.debug=$n(U,M,"debug"),this.trace=$n(U,M,"trace"),P&&(this.serializers=P,this._serialize=z),e&&(this._logEvent=Ac([].concat(U._logEvent.bindings,M)))}return B.prototype=this,new B(this)}return u}qr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};qr.stdSerializers=I2;qr.stdTimeFunctions=Object.assign({},{nullTime:Gl,epochTime:Wl,unixTime:N2,isoTime:C2});function Vn(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?$s:n[t]?n[t]:Vs[t]||Vs[i]||$s,A2(r,e,t)}function A2(r,e,t){!r.transmit&&e[t]===$s||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Vs?Vs:this;for(var u=0;u-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function $n(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.BrowserRandomSource=void 0;var e0=65536,Cc=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function H2(r){for(var e=0;e{});var r0=Z(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.NodeRandomSource=void 0;var G2=Jt(),Fc=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof al<"u"){let e=Lc();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.SystemRandomSource=void 0;var W2=t0(),J2=r0(),qc=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new W2.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new J2.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Ta.SystemRandomSource=qc});var n0=Z(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Y2(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Ut.mul=Math.imul||Y2;function X2(r,e){return r+e|0}Ut.add=X2;function Z2(r,e){return r-e|0}Ut.sub=Z2;function Q2(r,e){return r<>>32-e}Ut.rotl=Q2;function e3(r,e){return r<<32-e|r>>>e}Ut.rotr=e3;function t3(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Ut.isInteger=Number.isInteger||t3;Ut.MAX_SAFE_INTEGER=9007199254740991;Ut.isSafeInteger=function(r){return Ut.isInteger(r)&&r>=-Ut.MAX_SAFE_INTEGER&&r<=Ut.MAX_SAFE_INTEGER}});var Hn=Z(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var s0=n0();function r3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Le.readInt16BE=r3;function i3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Le.readUint16BE=i3;function n3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Le.readInt16LE=n3;function s3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Le.readUint16LE=s3;function o0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Le.writeUint16BE=o0;Le.writeInt16BE=o0;function a0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Le.writeUint16LE=a0;Le.writeInt16LE=a0;function Uc(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Le.readInt32BE=Uc;function zc(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Le.readUint32BE=zc;function Bc(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Le.readInt32LE=Bc;function kc(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Le.readUint32LE=kc;function Da(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Le.writeUint32BE=Da;Le.writeInt32BE=Da;function Pa(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Le.writeUint32LE=Pa;Le.writeInt32LE=Pa;function o3(r,e){e===void 0&&(e=0);var t=Uc(r,e),i=Uc(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Le.readInt64BE=o3;function a3(r,e){e===void 0&&(e=0);var t=zc(r,e),i=zc(r,e+4);return t*4294967296+i}Le.readUint64BE=a3;function f3(r,e){e===void 0&&(e=0);var t=Bc(r,e),i=Bc(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Le.readInt64LE=f3;function c3(r,e){e===void 0&&(e=0);var t=kc(r,e),i=kc(r,e+4);return i*4294967296+t}Le.readUint64LE=c3;function f0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Da(r/4294967296>>>0,e,t),Da(r>>>0,e,t+4),e}Le.writeUint64BE=f0;Le.writeInt64BE=f0;function c0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Pa(r>>>0,e,t),Pa(r/4294967296>>>0,e,t+4),e}Le.writeUint64LE=c0;Le.writeInt64LE=c0;function h3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Le.readUintBE=h3;function u3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Le.writeUintBE=d3;function l3(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!s0.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.randomStringForEntropy=wt.randomString=wt.randomUint32=wt.randomBytes=wt.defaultRandomSource=void 0;var x3=i0(),E3=Hn(),h0=Jt();wt.defaultRandomSource=new x3.SystemRandomSource;function Kc(r,e=wt.defaultRandomSource){return e.randomBytes(r)}wt.randomBytes=Kc;function S3(r=wt.defaultRandomSource){let e=Kc(4,r),t=(0,E3.readUint32LE)(e);return(0,h0.wipe)(e),t}wt.randomUint32=S3;var u0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function d0(r,e=u0,t=wt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Kc(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let u=o[f];u{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});var Wn=Hn(),Gn=Jt();fi.DIGEST_LENGTH=64;fi.BLOCK_SIZE=128;var p0=function(){function r(){this.digestLength=fi.DIGEST_LENGTH,this.blockSize=fi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Gn.wipe(this._buffer),Gn.wipe(this._tempHi),Gn.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Gn.wipe(e.stateHi),Gn.wipe(e.stateLo),e.buffer&&Gn.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();fi.SHA512=p0;var l0=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function jc(r,e,t,i,n,s,o){for(var f=t[0],u=t[1],c=t[2],b=t[3],v=t[4],S=t[5],I=t[6],M=t[7],T=i[0],O=i[1],P=i[2],z=i[3],B=i[4],U=i[5],j=i[6],H=i[7],L,C,W,D,l,w,p,a;o>=128;){for(var d=0;d<16;d++){var m=8*d+s;r[d]=Wn.readUint32BE(n,m),e[d]=Wn.readUint32BE(n,m+4)}for(var d=0;d<80;d++){var _=f,y=u,h=c,x=b,A=v,g=S,R=I,k=M,E=T,N=O,F=P,q=z,K=B,J=U,$=j,V=H;if(L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(v>>>14|B<<18)^(v>>>18|B<<14)^(B>>>9|v<<23),C=(B>>>14|v<<18)^(B>>>18|v<<14)^(v>>>9|B<<23),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=v&S^~v&I,C=B&U^~B&j,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=l0[d*2],C=l0[d*2+1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=r[d%16],C=e[d%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,W=p&65535|a<<16,D=l&65535|w<<16,L=W,C=D,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),C=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=f&u^f&c^u&c,C=T&O^T&P^O&P,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,k=p&65535|a<<16,V=l&65535|w<<16,L=x,C=q,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=W,C=D,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,q=l&65535|w<<16,u=_,c=y,b=h,v=x,S=A,I=g,M=R,f=k,O=E,P=N,z=F,B=q,U=K,j=J,H=$,T=V,d%16===15)for(var m=0;m<16;m++)L=r[m],C=e[m],l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=r[(m+9)%16],C=e[(m+9)%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+1)%16],D=e[(m+1)%16],L=(W>>>1|D<<31)^(W>>>8|D<<24)^W>>>7,C=(D>>>1|W<<31)^(D>>>8|W<<24)^(D>>>7|W<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+14)%16],D=e[(m+14)%16],L=(W>>>19|D<<13)^(D>>>29|W<<3)^W>>>6,C=(D>>>19|W<<13)^(W>>>29|D<<3)^(D>>>6|W<<26),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[m]=p&65535|a<<16,e[m]=l&65535|w<<16}L=f,C=T,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[0],C=i[0],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=u,C=O,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[1],C=i[1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=u=p&65535|a<<16,i[1]=O=l&65535|w<<16,L=c,C=P,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[2],C=i[2],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=c=p&65535|a<<16,i[2]=P=l&65535|w<<16,L=b,C=z,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[3],C=i[3],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=z=l&65535|w<<16,L=v,C=B,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[4],C=i[4],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=v=p&65535|a<<16,i[4]=B=l&65535|w<<16,L=S,C=U,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[5],C=i[5],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=U=l&65535|w<<16,L=I,C=j,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[6],C=i[6],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=j=l&65535|w<<16,L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[7],C=i[7],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=H=l&65535|w<<16,s+=128,o-=128}return s}function M3(r){var e=new p0;e.update(r);var t=e.digest();return e.clean(),t}fi.hash=M3});var T0=Z(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var A3=Js(),Ys=g0(),w0=Jt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function te(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,_0(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function x0(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function m0(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Xs(t,r),Xs(i,e),x0(t,i)}function E0(r){let e=new Uint8Array(32);return Xs(e,r),e[0]&1}function N3(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function pn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function bn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function je(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function gn(r,e){je(r,e,e)}function S0(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)gn(t,t),i!==2&&i!==4&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function C3(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)gn(t,t),i!==1&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Gc(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te(),c=te(),b=te();bn(t,r[1],r[0]),bn(b,e[1],e[0]),je(t,t,b),pn(i,r[0],r[1]),pn(b,e[0],e[1]),je(i,i,b),je(n,r[3],e[3]),je(n,n,D3),je(s,r[2],e[2]),pn(s,s,s),bn(o,i,t),bn(f,s,n),pn(u,s,n),pn(c,i,t),je(r[0],o,f),je(r[1],c,u),je(r[2],u,f),je(r[3],o,c)}function y0(r,e,t){for(let i=0;i<4;i++)_0(r[i],e[i],t)}function Jc(r,e){let t=te(),i=te(),n=te();S0(n,e[2]),je(t,e[0],n),je(i,e[1],n),Xs(r,i),r[31]^=E0(t)<<7}function I0(r,e,t){Ri(r[0],Hc),Ri(r[1],Jn),Ri(r[2],Jn),Ri(r[3],Hc);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;y0(r,e,n),Gc(e,r),Gc(r,r),y0(r,e,n)}}function Yc(r,e){let t=[te(),te(),te(),te()];Ri(t[0],b0),Ri(t[1],v0),Ri(t[2],Jn),je(t[3],b0,v0),I0(r,t,e)}function M0(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ys.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[te(),te(),te(),te()];Yc(i,e),Jc(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=M0;function O3(r){let e=(0,A3.randomBytes)(32,r),t=M0(e);return(0,w0.wipe)(e),t}ze.generateKeyPair=O3;function L3(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=L3;var $c=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function A0(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*$c[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*$c[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Wc(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;A0(r,e)}function F3(r,e){let t=new Float64Array(64),i=[te(),te(),te(),te()],n=(0,Ys.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ys.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Wc(f),Yc(i,f),Jc(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let u=o.digest();Wc(u);for(let c=0;c<32;c++)t[c]=f[c];for(let c=0;c<32;c++)for(let b=0;b<32;b++)t[c+b]+=u[c]*n[b];return A0(s.subarray(32),t),s}ze.sign=F3;function R0(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te();return Ri(r[2],Jn),N3(r[1],e),gn(n,r[1]),je(s,n,T3),bn(n,n,r[2]),pn(s,r[2],s),gn(o,s),gn(f,o),je(u,f,o),je(t,u,n),je(t,t,s),C3(t,t),je(t,t,n),je(t,t,s),je(t,t,s),je(r[0],t,s),gn(i,r[0]),je(i,i,s),m0(i,n)&&je(r[0],r[0],P3),gn(i,r[0]),je(i,i,s),m0(i,n)?-1:(E0(r[0])===e[31]>>7&&bn(r[0],Hc,r[0]),je(r[3],r[0],r[1]),0)}function q3(r,e,t){let i=new Uint8Array(32),n=[te(),te(),te(),te()],s=[te(),te(),te(),te()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(R0(s,r))return!1;let o=new Ys.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Wc(f),I0(n,s,f),Yc(s,t.subarray(32)),Gc(n,s),Jc(i,n),!x0(t,i)}ze.verify=q3;function U3(r){let e=[te(),te(),te(),te()];if(R0(e,r))throw new Error("Ed25519: invalid public key");let t=te(),i=te(),n=e[1];pn(t,Jn,n),bn(i,Jn,n),S0(i,i),je(t,t,i);let s=new Uint8Array(32);return Xs(s,t),s}ze.convertPublicKeyToX25519=U3;function z3(r){let e=(0,Ys.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,w0.wipe)(e),t}ze.convertSecretKeyToX25519=z3});var za=Z(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.getLocalStorage=He.getLocalStorageOrThrow=He.getCrypto=He.getCryptoOrThrow=He.getLocation=He.getLocationOrThrow=He.getNavigator=He.getNavigatorOrThrow=He.getDocument=He.getDocumentOrThrow=He.getFromWindowOrThrow=He.getFromWindow=void 0;function yn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}He.getFromWindow=yn;function rs(r){let e=yn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}He.getFromWindowOrThrow=rs;function dw(){return rs("document")}He.getDocumentOrThrow=dw;function lw(){return yn("document")}He.getDocument=lw;function pw(){return rs("navigator")}He.getNavigatorOrThrow=pw;function gw(){return yn("navigator")}He.getNavigator=gw;function bw(){return rs("location")}He.getLocationOrThrow=bw;function vw(){return yn("location")}He.getLocation=vw;function mw(){return rs("crypto")}He.getCryptoOrThrow=mw;function yw(){return yn("crypto")}He.getCrypto=yw;function ww(){return rs("localStorage")}He.getLocalStorageOrThrow=ww;function _w(){return yn("localStorage")}He.getLocalStorage=_w});var gp=Z(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.getWindowMetadata=void 0;var pp=za();function xw(){let r,e;try{r=pp.getDocumentOrThrow(),e=pp.getLocationOrThrow()}catch{return null}function t(){let v=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=M.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let P=e.protocol+"//"+e.host;if(O.indexOf("/")===0)P+=O;else{let z=e.pathname.split("/");z.pop();let B=z.join("/");P+=B+"/"+O}S.push(P)}else if(O.indexOf("//")===0){let P=e.protocol+O;S.push(P)}else S.push(O)}}return S}function i(...v){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(O)).filter(O=>O?v.includes(O):!1);if(T.length&&T){let O=M.getAttribute("content");if(O)return O}}return""}function n(){let v=i("name","og:site_name","og:title","twitter:title");return v||(v=r.title),v}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),u=e.origin,c=t();return{description:f,url:u,icons:c,name:o}}Ba.getWindowMetadata=xw});var vp=Z((zM,bp)=>{"use strict";bp.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var xp=Z((BM,_p)=>{"use strict";var wp="%[a-f0-9]{2}",mp=new RegExp("("+wp+")|([^%]+?)","gi"),yp=new RegExp("("+wp+")+","gi");function xh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],xh(t),xh(i))}function Ew(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(mp)||[],t=1;t{"use strict";Ep.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Mp=Z((KM,Ip)=>{"use strict";Ip.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Iw=vp(),Mw=xp(),Rp=Sp(),Aw=Mp(),Rw=r=>r==null,Eh=Symbol("encodeFragmentIdentifier");function Tw(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[",n,"]"].join("")]:[...t,[it(e,r),"[",it(n,r),"]=",it(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[]"].join("")]:[...t,[it(e,r),"[]=",it(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),":list="].join("")]:[...t,[it(e,r),":list=",it(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[it(t,r),e,it(n,r)].join("")]:[[i,it(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,it(e,r)]:[...t,[it(e,r),"=",it(i,r)].join("")]}}function Dw(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&hi(i,r).includes(r.arrayFormatSeparator);i=o?hi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(u=>hi(u,r)):i===null?i:hi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&hi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>hi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Tp(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function it(r,e){return e.encode?e.strict?Iw(r):encodeURIComponent(r):r}function hi(r,e){return e.decode?Mw(r):r}function Dp(r){return Array.isArray(r)?r.sort():typeof r=="object"?Dp(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Pp(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Pw(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Np(r){r=Pp(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ap(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Cp(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Tp(e.arrayFormatSeparator);let t=Dw(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Rp(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:hi(o,e),t(hi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ap(s[o],e);else i[n]=Ap(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Dp(o):n[s]=o,n},Object.create(null))}Ct.extract=Np;Ct.parse=Cp;Ct.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Tp(e.arrayFormatSeparator);let t=o=>e.skipNull&&Rw(r[o])||e.skipEmptyString&&r[o]==="",i=Tw(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?it(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?it(o,e)+"[]":f.reduce(i(o),[]).join("&"):it(o,e)+"="+it(f,e)}).filter(o=>o.length>0).join("&")};Ct.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Rp(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Cp(Np(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:hi(i,e)}:{})};Ct.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Eh]:!0},e);let t=Pp(r.url).split("?")[0]||"",i=Ct.extract(r.url),n=Ct.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ct.stringify(s,e);o&&(o=`?${o}`);let f=Pw(r.url);return r.fragmentIdentifier&&(f=`#${e[Eh]?it(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ct.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Eh]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ct.parseUrl(r,t);return Ct.stringifyUrl({url:i,query:Aw(n,e),fragmentIdentifier:s},t)};Ct.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ct.pick(r,i,t)}});var Lp=Z((VM,ka)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=window:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ka=="object"&&ka.exports,f=typeof define=="function"&&define.amd,u=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],v=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],P=[128,256],z=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),u&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var U=function(E,N,F){return function(q){return new g(E,N,E).update(q)[F]()}},j=function(E,N,F){return function(q,K){return new g(E,N,K).update(q)[F]()}},H=function(E,N,F){return function(q,K,J,$){return a["cshake"+E].update(q,K,J,$)[F]()}},L=function(E,N,F){return function(q,K,J,$){return a["kmac"+E].update(q,K,J,$)[F]()}},C=function(E,N,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}for(var q=this.blocks,K=this.byteCount,J=E.length,$=this.blockCount,V=0,ee=this.s,G,Y;V>2]|=E[V]<>2]|=Y<>2]|=(192|Y>>6)<>2]|=(128|Y&63)<=57344?(q[G>>2]|=(224|Y>>12)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<>2]|=(240|Y>>18)<>2]|=(128|Y>>12&63)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<=K){for(this.start=G-K,this.block=q[$],G=0;G<$;++G)ee[G]^=q[G];k(ee),this.reset=!0}else this.start=G}return this},g.prototype.encode=function(E,N){var F=E&255,q=1,K=[F];for(E=E>>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return N?K.push(q):K.unshift(q),this.update(K),K.length},g.prototype.encodeString=function(E){var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}var q=0,K=E.length;if(N)q=K;else for(var J=0;J=57344?q+=3:($=65536+(($&1023)<<10|E.charCodeAt(++J)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},g.prototype.bytepad=function(E,N){for(var F=this.encode(N),q=0;q>2]|=this.padding[N&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],N=1;N>4&15]+c[V&15]+c[V>>12&15]+c[V>>8&15]+c[V>>20&15]+c[V>>16&15]+c[V>>28&15]+c[V>>24&15];J%E===0&&(k(N),K=0)}return q&&(V=N[K],$+=c[V>>4&15]+c[V&15],q>1&&($+=c[V>>12&15]+c[V>>8&15]),q>2&&($+=c[V>>20&15]+c[V>>16&15])),$},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,N=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,J=0,$=this.outputBits>>3,V;q?V=new ArrayBuffer(F+1<<2):V=new ArrayBuffer($);for(var ee=new Uint32Array(V);J>8&255,$[V+2]=ee>>16&255,$[V+3]=ee>>24&255;J%E===0&&k(N)}return q&&(V=J<<2,ee=N[K],$[V]=ee&255,q>1&&($[V+1]=ee>>8&255),q>2&&($[V+2]=ee>>16&255)),$};function R(E,N,F){g.call(this,E,N,F)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var k=function(E){var N,F,q,K,J,$,V,ee,G,Y,_r,ie,ne,xr,se,oe,Er,ae,fe,Sr,ce,he,Ir,ue,de,Mr,le,pe,Ar,ge,be,Rr,ve,me,Tr,ye,we,Dr,_e,xe,Pr,Ee,Se,Nr,Ie,Me,Cr,Ae,Re,Or,Te,De,Lr,Pe,Ne,nr,Be,ke,jt,Vt,$t,Ht,Gt;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],J=E[1]^E[11]^E[21]^E[31]^E[41],$=E[2]^E[12]^E[22]^E[32]^E[42],V=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],Y=E[6]^E[16]^E[26]^E[36]^E[46],_r=E[7]^E[17]^E[27]^E[37]^E[47],ie=E[8]^E[18]^E[28]^E[38]^E[48],ne=E[9]^E[19]^E[29]^E[39]^E[49],N=ie^($<<1|V>>>31),F=ne^(V<<1|$>>>31),E[0]^=N,E[1]^=F,E[10]^=N,E[11]^=F,E[20]^=N,E[21]^=F,E[30]^=N,E[31]^=F,E[40]^=N,E[41]^=F,N=K^(ee<<1|G>>>31),F=J^(G<<1|ee>>>31),E[2]^=N,E[3]^=F,E[12]^=N,E[13]^=F,E[22]^=N,E[23]^=F,E[32]^=N,E[33]^=F,E[42]^=N,E[43]^=F,N=$^(Y<<1|_r>>>31),F=V^(_r<<1|Y>>>31),E[4]^=N,E[5]^=F,E[14]^=N,E[15]^=F,E[24]^=N,E[25]^=F,E[34]^=N,E[35]^=F,E[44]^=N,E[45]^=F,N=ee^(ie<<1|ne>>>31),F=G^(ne<<1|ie>>>31),E[6]^=N,E[7]^=F,E[16]^=N,E[17]^=F,E[26]^=N,E[27]^=F,E[36]^=N,E[37]^=F,E[46]^=N,E[47]^=F,N=Y^(K<<1|J>>>31),F=_r^(J<<1|K>>>31),E[8]^=N,E[9]^=F,E[18]^=N,E[19]^=F,E[28]^=N,E[29]^=F,E[38]^=N,E[39]^=F,E[48]^=N,E[49]^=F,xr=E[0],se=E[1],Me=E[11]<<4|E[10]>>>28,Cr=E[10]<<4|E[11]>>>28,pe=E[20]<<3|E[21]>>>29,Ar=E[21]<<3|E[20]>>>29,Vt=E[31]<<9|E[30]>>>23,$t=E[30]<<9|E[31]>>>23,Ee=E[40]<<18|E[41]>>>14,Se=E[41]<<18|E[40]>>>14,me=E[2]<<1|E[3]>>>31,Tr=E[3]<<1|E[2]>>>31,oe=E[13]<<12|E[12]>>>20,Er=E[12]<<12|E[13]>>>20,Ae=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,ge=E[33]<<13|E[32]>>>19,be=E[32]<<13|E[33]>>>19,Ht=E[42]<<2|E[43]>>>30,Gt=E[43]<<2|E[42]>>>30,Pe=E[5]<<30|E[4]>>>2,Ne=E[4]<<30|E[5]>>>2,ye=E[14]<<6|E[15]>>>26,we=E[15]<<6|E[14]>>>26,ae=E[25]<<11|E[24]>>>21,fe=E[24]<<11|E[25]>>>21,Or=E[34]<<15|E[35]>>>17,Te=E[35]<<15|E[34]>>>17,Rr=E[45]<<29|E[44]>>>3,ve=E[44]<<29|E[45]>>>3,ue=E[6]<<28|E[7]>>>4,de=E[7]<<28|E[6]>>>4,nr=E[17]<<23|E[16]>>>9,Be=E[16]<<23|E[17]>>>9,Dr=E[26]<<25|E[27]>>>7,_e=E[27]<<25|E[26]>>>7,Sr=E[36]<<21|E[37]>>>11,ce=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Lr=E[46]<<24|E[47]>>>8,Nr=E[8]<<27|E[9]>>>5,Ie=E[9]<<27|E[8]>>>5,Mr=E[18]<<20|E[19]>>>12,le=E[19]<<20|E[18]>>>12,ke=E[29]<<7|E[28]>>>25,jt=E[28]<<7|E[29]>>>25,xe=E[38]<<8|E[39]>>>24,Pr=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Ir=E[49]<<14|E[48]>>>18,E[0]=xr^~oe&ae,E[1]=se^~Er&fe,E[10]=ue^~Mr&pe,E[11]=de^~le&Ar,E[20]=me^~ye&Dr,E[21]=Tr^~we&_e,E[30]=Nr^~Me&Ae,E[31]=Ie^~Cr&Re,E[40]=Pe^~nr&ke,E[41]=Ne^~Be&jt,E[2]=oe^~ae&Sr,E[3]=Er^~fe&ce,E[12]=Mr^~pe&ge,E[13]=le^~Ar&be,E[22]=ye^~Dr&xe,E[23]=we^~_e&Pr,E[32]=Me^~Ae&Or,E[33]=Cr^~Re&Te,E[42]=nr^~ke&Vt,E[43]=Be^~jt&$t,E[4]=ae^~Sr&he,E[5]=fe^~ce&Ir,E[14]=pe^~ge&Rr,E[15]=Ar^~be&ve,E[24]=Dr^~xe&Ee,E[25]=_e^~Pr&Se,E[34]=Ae^~Or&De,E[35]=Re^~Te&Lr,E[44]=ke^~Vt&Ht,E[45]=jt^~$t&Gt,E[6]=Sr^~he&xr,E[7]=ce^~Ir&se,E[16]=ge^~Rr&ue,E[17]=be^~ve&de,E[26]=xe^~Ee&me,E[27]=Pr^~Se&Tr,E[36]=Or^~De&Nr,E[37]=Te^~Lr&Ie,E[46]=Vt^~Ht&Pe,E[47]=$t^~Gt&Ne,E[8]=he^~xr&oe,E[9]=Ir^~se&Er,E[18]=Rr^~ue&Mr,E[19]=ve^~de&le,E[28]=Ee^~me&ye,E[29]=Se^~Tr&we,E[38]=De^~Nr&Me,E[39]=Lr^~Ie&Cr,E[48]=Ht^~Pe&nr,E[49]=Gt^~Ne&Be,E[0]^=T[q],E[1]^=T[q+1]};if(o)ka.exports=a;else{for(m=0;m{});var Ph=Z((Gp,Dh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var d=function(){};d.prototype=a.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,a,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(d=a,a=10),this._init(p||0,a||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,d){return a.cmp(d)>0?a:d},n.min=function(a,d){return a.cmp(d)<0?a:d},n.prototype._init=function(a,d,m){if(typeof a=="number")return this._initNumber(a,d,m);if(typeof a=="object")return this._initArray(a,d,m);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)h=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[y]|=h<>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);else if(m==="le")for(_=0,y=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);return this._strip()};function o(p,a){var d=p.charCodeAt(a);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function f(p,a,d){var m=o(p,d);return d-1>=a&&(m|=o(p,d-1)<<4),m}n.prototype._parseHex=function(a,d,m){this.length=Math.ceil((a.length-d)/6),this.words=new Array(this.length);for(var _=0;_=d;_-=2)x=f(a,d,_)<=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8;else{var A=a.length-d;for(_=A%2===0?d+1:d;_=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8}this._strip()};function u(p,a,d,m){for(var _=0,y=0,h=Math.min(p.length,d),x=a;x=49?y=A-49+10:A>=17?y=A-17+10:y=A,t(A>=0&&y1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var v=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,d){a=a||10,d=d|0||1;var m;if(a===16||a==="hex"){m="";for(var _=0,y=0,h=0;h>>24-_&16777215,_+=2,_>=26&&(_-=26,h--),y!==0||h!==this.length-1?m=v[6-A.length]+A+m:m=A+m}for(y!==0&&(m=y.toString(16)+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];m="";var k=this.clone();for(k.negative=0;!k.isZero();){var E=k.modrn(R).toString(a);k=k.idivn(R),k.isZero()?m=E+m:m=v[g-E.length]+E+m}for(this.isZero()&&(m="0"+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,d){return this.toArrayLike(s,a,d)}),n.prototype.toArray=function(a,d){return this.toArrayLike(Array,a,d)};var M=function(a,d){return a.allocUnsafe?a.allocUnsafe(d):new a(d)};n.prototype.toArrayLike=function(a,d,m){this._strip();var _=this.byteLength(),y=m||Math.max(1,_);t(_<=y,"byte array longer than desired length"),t(y>0,"Requested array length <= 0");var h=M(a,y),x=d==="le"?"LE":"BE";return this["_toArrayLike"+x](h,_),h},n.prototype._toArrayLikeLE=function(a,d){for(var m=0,_=0,y=0,h=0;y>8&255),m>16&255),h===6?(m>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m=0&&(a[m--]=x>>8&255),m>=0&&(a[m--]=x>>16&255),h===6?(m>=0&&(a[m--]=x>>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m>=0)for(a[m--]=_;m>=0;)a[m--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var d=a,m=0;return d>=4096&&(m+=13,d>>>=13),d>=64&&(m+=7,d>>>=7),d>=8&&(m+=4,d>>>=4),d>=2&&(m+=2,d>>>=2),m+d},n.prototype._zeroBits=function(a){if(a===0)return 26;var d=a,m=0;return d&8191||(m+=13,d>>>=13),d&127||(m+=7,d>>>=7),d&15||(m+=4,d>>>=4),d&3||(m+=2,d>>>=2),d&1||m++,m},n.prototype.bitLength=function(){var a=this.words[this.length-1],d=this._countBits(a);return(this.length-1)*26+d};function T(p){for(var a=new Array(p.bitLength()),d=0;d>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,d=0;da.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var d;this.length>a.length?d=a:d=this;for(var m=0;ma.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var d,m;this.length>a.length?(d=this,m=a):(d=a,m=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var d=Math.ceil(a/26)|0,m=a%26;this._expand(d),m>0&&d--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-m),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,d){t(typeof a=="number"&&a>=0);var m=a/26|0,_=a%26;return this._expand(m+1),d?this.words[m]=this.words[m]|1<<_:this.words[m]=this.words[m]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var d;if(this.negative!==0&&a.negative===0)return this.negative=0,d=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,d=this.isub(a),a.negative=1,d._normSign();var m,_;this.length>a.length?(m=this,_=a):(m=a,_=this);for(var y=0,h=0;h<_.length;h++)d=(m.words[h]|0)+(_.words[h]|0)+y,this.words[h]=d&67108863,y=d>>>26;for(;y!==0&&h>>26;if(this.length=m.length,y!==0)this.words[this.length]=y,this.length++;else if(m!==this)for(;ha.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var d=this.iadd(a);return a.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var m=this.cmp(a);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,y;m>0?(_=this,y=a):(_=a,y=this);for(var h=0,x=0;x>26,this.words[x]=d&67108863;for(;h!==0&&x<_.length;x++)d=(_.words[x]|0)+h,h=d>>26,this.words[x]=d&67108863;if(h===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function O(p,a,d){d.negative=a.negative^p.negative;var m=p.length+a.length|0;d.length=m,m=m-1|0;var _=p.words[0]|0,y=a.words[0]|0,h=_*y,x=h&67108863,A=h/67108864|0;d.words[0]=x;for(var g=1;g>>26,k=A&67108863,E=Math.min(g,a.length-1),N=Math.max(0,g-p.length+1);N<=E;N++){var F=g-N|0;_=p.words[F]|0,y=a.words[N]|0,h=_*y+k,R+=h/67108864|0,k=h&67108863}d.words[g]=k|0,A=R|0}return A!==0?d.words[g]=A|0:d.length--,d._strip()}var P=function(a,d,m){var _=a.words,y=d.words,h=m.words,x=0,A,g,R,k=_[0]|0,E=k&8191,N=k>>>13,F=_[1]|0,q=F&8191,K=F>>>13,J=_[2]|0,$=J&8191,V=J>>>13,ee=_[3]|0,G=ee&8191,Y=ee>>>13,_r=_[4]|0,ie=_r&8191,ne=_r>>>13,xr=_[5]|0,se=xr&8191,oe=xr>>>13,Er=_[6]|0,ae=Er&8191,fe=Er>>>13,Sr=_[7]|0,ce=Sr&8191,he=Sr>>>13,Ir=_[8]|0,ue=Ir&8191,de=Ir>>>13,Mr=_[9]|0,le=Mr&8191,pe=Mr>>>13,Ar=y[0]|0,ge=Ar&8191,be=Ar>>>13,Rr=y[1]|0,ve=Rr&8191,me=Rr>>>13,Tr=y[2]|0,ye=Tr&8191,we=Tr>>>13,Dr=y[3]|0,_e=Dr&8191,xe=Dr>>>13,Pr=y[4]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=y[5]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=y[6]|0,Ae=Cr&8191,Re=Cr>>>13,Or=y[7]|0,Te=Or&8191,De=Or>>>13,Lr=y[8]|0,Pe=Lr&8191,Ne=Lr>>>13,nr=y[9]|0,Be=nr&8191,ke=nr>>>13;m.negative=a.negative^d.negative,m.length=19,A=Math.imul(E,ge),g=Math.imul(E,be),g=g+Math.imul(N,ge)|0,R=Math.imul(N,be);var jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(jt>>>26)|0,jt&=67108863,A=Math.imul(q,ge),g=Math.imul(q,be),g=g+Math.imul(K,ge)|0,R=Math.imul(K,be),A=A+Math.imul(E,ve)|0,g=g+Math.imul(E,me)|0,g=g+Math.imul(N,ve)|0,R=R+Math.imul(N,me)|0;var Vt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,A=Math.imul($,ge),g=Math.imul($,be),g=g+Math.imul(V,ge)|0,R=Math.imul(V,be),A=A+Math.imul(q,ve)|0,g=g+Math.imul(q,me)|0,g=g+Math.imul(K,ve)|0,R=R+Math.imul(K,me)|0,A=A+Math.imul(E,ye)|0,g=g+Math.imul(E,we)|0,g=g+Math.imul(N,ye)|0,R=R+Math.imul(N,we)|0;var $t=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+($t>>>26)|0,$t&=67108863,A=Math.imul(G,ge),g=Math.imul(G,be),g=g+Math.imul(Y,ge)|0,R=Math.imul(Y,be),A=A+Math.imul($,ve)|0,g=g+Math.imul($,me)|0,g=g+Math.imul(V,ve)|0,R=R+Math.imul(V,me)|0,A=A+Math.imul(q,ye)|0,g=g+Math.imul(q,we)|0,g=g+Math.imul(K,ye)|0,R=R+Math.imul(K,we)|0,A=A+Math.imul(E,_e)|0,g=g+Math.imul(E,xe)|0,g=g+Math.imul(N,_e)|0,R=R+Math.imul(N,xe)|0;var Ht=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,A=Math.imul(ie,ge),g=Math.imul(ie,be),g=g+Math.imul(ne,ge)|0,R=Math.imul(ne,be),A=A+Math.imul(G,ve)|0,g=g+Math.imul(G,me)|0,g=g+Math.imul(Y,ve)|0,R=R+Math.imul(Y,me)|0,A=A+Math.imul($,ye)|0,g=g+Math.imul($,we)|0,g=g+Math.imul(V,ye)|0,R=R+Math.imul(V,we)|0,A=A+Math.imul(q,_e)|0,g=g+Math.imul(q,xe)|0,g=g+Math.imul(K,_e)|0,R=R+Math.imul(K,xe)|0,A=A+Math.imul(E,Ee)|0,g=g+Math.imul(E,Se)|0,g=g+Math.imul(N,Ee)|0,R=R+Math.imul(N,Se)|0;var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(se,ge),g=Math.imul(se,be),g=g+Math.imul(oe,ge)|0,R=Math.imul(oe,be),A=A+Math.imul(ie,ve)|0,g=g+Math.imul(ie,me)|0,g=g+Math.imul(ne,ve)|0,R=R+Math.imul(ne,me)|0,A=A+Math.imul(G,ye)|0,g=g+Math.imul(G,we)|0,g=g+Math.imul(Y,ye)|0,R=R+Math.imul(Y,we)|0,A=A+Math.imul($,_e)|0,g=g+Math.imul($,xe)|0,g=g+Math.imul(V,_e)|0,R=R+Math.imul(V,xe)|0,A=A+Math.imul(q,Ee)|0,g=g+Math.imul(q,Se)|0,g=g+Math.imul(K,Ee)|0,R=R+Math.imul(K,Se)|0,A=A+Math.imul(E,Ie)|0,g=g+Math.imul(E,Me)|0,g=g+Math.imul(N,Ie)|0,R=R+Math.imul(N,Me)|0;var Qi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,A=Math.imul(ae,ge),g=Math.imul(ae,be),g=g+Math.imul(fe,ge)|0,R=Math.imul(fe,be),A=A+Math.imul(se,ve)|0,g=g+Math.imul(se,me)|0,g=g+Math.imul(oe,ve)|0,R=R+Math.imul(oe,me)|0,A=A+Math.imul(ie,ye)|0,g=g+Math.imul(ie,we)|0,g=g+Math.imul(ne,ye)|0,R=R+Math.imul(ne,we)|0,A=A+Math.imul(G,_e)|0,g=g+Math.imul(G,xe)|0,g=g+Math.imul(Y,_e)|0,R=R+Math.imul(Y,xe)|0,A=A+Math.imul($,Ee)|0,g=g+Math.imul($,Se)|0,g=g+Math.imul(V,Ee)|0,R=R+Math.imul(V,Se)|0,A=A+Math.imul(q,Ie)|0,g=g+Math.imul(q,Me)|0,g=g+Math.imul(K,Ie)|0,R=R+Math.imul(K,Me)|0,A=A+Math.imul(E,Ae)|0,g=g+Math.imul(E,Re)|0,g=g+Math.imul(N,Ae)|0,R=R+Math.imul(N,Re)|0;var en=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(en>>>26)|0,en&=67108863,A=Math.imul(ce,ge),g=Math.imul(ce,be),g=g+Math.imul(he,ge)|0,R=Math.imul(he,be),A=A+Math.imul(ae,ve)|0,g=g+Math.imul(ae,me)|0,g=g+Math.imul(fe,ve)|0,R=R+Math.imul(fe,me)|0,A=A+Math.imul(se,ye)|0,g=g+Math.imul(se,we)|0,g=g+Math.imul(oe,ye)|0,R=R+Math.imul(oe,we)|0,A=A+Math.imul(ie,_e)|0,g=g+Math.imul(ie,xe)|0,g=g+Math.imul(ne,_e)|0,R=R+Math.imul(ne,xe)|0,A=A+Math.imul(G,Ee)|0,g=g+Math.imul(G,Se)|0,g=g+Math.imul(Y,Ee)|0,R=R+Math.imul(Y,Se)|0,A=A+Math.imul($,Ie)|0,g=g+Math.imul($,Me)|0,g=g+Math.imul(V,Ie)|0,R=R+Math.imul(V,Me)|0,A=A+Math.imul(q,Ae)|0,g=g+Math.imul(q,Re)|0,g=g+Math.imul(K,Ae)|0,R=R+Math.imul(K,Re)|0,A=A+Math.imul(E,Te)|0,g=g+Math.imul(E,De)|0,g=g+Math.imul(N,Te)|0,R=R+Math.imul(N,De)|0;var tn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(tn>>>26)|0,tn&=67108863,A=Math.imul(ue,ge),g=Math.imul(ue,be),g=g+Math.imul(de,ge)|0,R=Math.imul(de,be),A=A+Math.imul(ce,ve)|0,g=g+Math.imul(ce,me)|0,g=g+Math.imul(he,ve)|0,R=R+Math.imul(he,me)|0,A=A+Math.imul(ae,ye)|0,g=g+Math.imul(ae,we)|0,g=g+Math.imul(fe,ye)|0,R=R+Math.imul(fe,we)|0,A=A+Math.imul(se,_e)|0,g=g+Math.imul(se,xe)|0,g=g+Math.imul(oe,_e)|0,R=R+Math.imul(oe,xe)|0,A=A+Math.imul(ie,Ee)|0,g=g+Math.imul(ie,Se)|0,g=g+Math.imul(ne,Ee)|0,R=R+Math.imul(ne,Se)|0,A=A+Math.imul(G,Ie)|0,g=g+Math.imul(G,Me)|0,g=g+Math.imul(Y,Ie)|0,R=R+Math.imul(Y,Me)|0,A=A+Math.imul($,Ae)|0,g=g+Math.imul($,Re)|0,g=g+Math.imul(V,Ae)|0,R=R+Math.imul(V,Re)|0,A=A+Math.imul(q,Te)|0,g=g+Math.imul(q,De)|0,g=g+Math.imul(K,Te)|0,R=R+Math.imul(K,De)|0,A=A+Math.imul(E,Pe)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(N,Pe)|0,R=R+Math.imul(N,Ne)|0;var rn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(rn>>>26)|0,rn&=67108863,A=Math.imul(le,ge),g=Math.imul(le,be),g=g+Math.imul(pe,ge)|0,R=Math.imul(pe,be),A=A+Math.imul(ue,ve)|0,g=g+Math.imul(ue,me)|0,g=g+Math.imul(de,ve)|0,R=R+Math.imul(de,me)|0,A=A+Math.imul(ce,ye)|0,g=g+Math.imul(ce,we)|0,g=g+Math.imul(he,ye)|0,R=R+Math.imul(he,we)|0,A=A+Math.imul(ae,_e)|0,g=g+Math.imul(ae,xe)|0,g=g+Math.imul(fe,_e)|0,R=R+Math.imul(fe,xe)|0,A=A+Math.imul(se,Ee)|0,g=g+Math.imul(se,Se)|0,g=g+Math.imul(oe,Ee)|0,R=R+Math.imul(oe,Se)|0,A=A+Math.imul(ie,Ie)|0,g=g+Math.imul(ie,Me)|0,g=g+Math.imul(ne,Ie)|0,R=R+Math.imul(ne,Me)|0,A=A+Math.imul(G,Ae)|0,g=g+Math.imul(G,Re)|0,g=g+Math.imul(Y,Ae)|0,R=R+Math.imul(Y,Re)|0,A=A+Math.imul($,Te)|0,g=g+Math.imul($,De)|0,g=g+Math.imul(V,Te)|0,R=R+Math.imul(V,De)|0,A=A+Math.imul(q,Pe)|0,g=g+Math.imul(q,Ne)|0,g=g+Math.imul(K,Pe)|0,R=R+Math.imul(K,Ne)|0,A=A+Math.imul(E,Be)|0,g=g+Math.imul(E,ke)|0,g=g+Math.imul(N,Be)|0,R=R+Math.imul(N,ke)|0;var nn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nn>>>26)|0,nn&=67108863,A=Math.imul(le,ve),g=Math.imul(le,me),g=g+Math.imul(pe,ve)|0,R=Math.imul(pe,me),A=A+Math.imul(ue,ye)|0,g=g+Math.imul(ue,we)|0,g=g+Math.imul(de,ye)|0,R=R+Math.imul(de,we)|0,A=A+Math.imul(ce,_e)|0,g=g+Math.imul(ce,xe)|0,g=g+Math.imul(he,_e)|0,R=R+Math.imul(he,xe)|0,A=A+Math.imul(ae,Ee)|0,g=g+Math.imul(ae,Se)|0,g=g+Math.imul(fe,Ee)|0,R=R+Math.imul(fe,Se)|0,A=A+Math.imul(se,Ie)|0,g=g+Math.imul(se,Me)|0,g=g+Math.imul(oe,Ie)|0,R=R+Math.imul(oe,Me)|0,A=A+Math.imul(ie,Ae)|0,g=g+Math.imul(ie,Re)|0,g=g+Math.imul(ne,Ae)|0,R=R+Math.imul(ne,Re)|0,A=A+Math.imul(G,Te)|0,g=g+Math.imul(G,De)|0,g=g+Math.imul(Y,Te)|0,R=R+Math.imul(Y,De)|0,A=A+Math.imul($,Pe)|0,g=g+Math.imul($,Ne)|0,g=g+Math.imul(V,Pe)|0,R=R+Math.imul(V,Ne)|0,A=A+Math.imul(q,Be)|0,g=g+Math.imul(q,ke)|0,g=g+Math.imul(K,Be)|0,R=R+Math.imul(K,ke)|0;var sn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(sn>>>26)|0,sn&=67108863,A=Math.imul(le,ye),g=Math.imul(le,we),g=g+Math.imul(pe,ye)|0,R=Math.imul(pe,we),A=A+Math.imul(ue,_e)|0,g=g+Math.imul(ue,xe)|0,g=g+Math.imul(de,_e)|0,R=R+Math.imul(de,xe)|0,A=A+Math.imul(ce,Ee)|0,g=g+Math.imul(ce,Se)|0,g=g+Math.imul(he,Ee)|0,R=R+Math.imul(he,Se)|0,A=A+Math.imul(ae,Ie)|0,g=g+Math.imul(ae,Me)|0,g=g+Math.imul(fe,Ie)|0,R=R+Math.imul(fe,Me)|0,A=A+Math.imul(se,Ae)|0,g=g+Math.imul(se,Re)|0,g=g+Math.imul(oe,Ae)|0,R=R+Math.imul(oe,Re)|0,A=A+Math.imul(ie,Te)|0,g=g+Math.imul(ie,De)|0,g=g+Math.imul(ne,Te)|0,R=R+Math.imul(ne,De)|0,A=A+Math.imul(G,Pe)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(Y,Pe)|0,R=R+Math.imul(Y,Ne)|0,A=A+Math.imul($,Be)|0,g=g+Math.imul($,ke)|0,g=g+Math.imul(V,Be)|0,R=R+Math.imul(V,ke)|0;var on=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(on>>>26)|0,on&=67108863,A=Math.imul(le,_e),g=Math.imul(le,xe),g=g+Math.imul(pe,_e)|0,R=Math.imul(pe,xe),A=A+Math.imul(ue,Ee)|0,g=g+Math.imul(ue,Se)|0,g=g+Math.imul(de,Ee)|0,R=R+Math.imul(de,Se)|0,A=A+Math.imul(ce,Ie)|0,g=g+Math.imul(ce,Me)|0,g=g+Math.imul(he,Ie)|0,R=R+Math.imul(he,Me)|0,A=A+Math.imul(ae,Ae)|0,g=g+Math.imul(ae,Re)|0,g=g+Math.imul(fe,Ae)|0,R=R+Math.imul(fe,Re)|0,A=A+Math.imul(se,Te)|0,g=g+Math.imul(se,De)|0,g=g+Math.imul(oe,Te)|0,R=R+Math.imul(oe,De)|0,A=A+Math.imul(ie,Pe)|0,g=g+Math.imul(ie,Ne)|0,g=g+Math.imul(ne,Pe)|0,R=R+Math.imul(ne,Ne)|0,A=A+Math.imul(G,Be)|0,g=g+Math.imul(G,ke)|0,g=g+Math.imul(Y,Be)|0,R=R+Math.imul(Y,ke)|0;var an=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(an>>>26)|0,an&=67108863,A=Math.imul(le,Ee),g=Math.imul(le,Se),g=g+Math.imul(pe,Ee)|0,R=Math.imul(pe,Se),A=A+Math.imul(ue,Ie)|0,g=g+Math.imul(ue,Me)|0,g=g+Math.imul(de,Ie)|0,R=R+Math.imul(de,Me)|0,A=A+Math.imul(ce,Ae)|0,g=g+Math.imul(ce,Re)|0,g=g+Math.imul(he,Ae)|0,R=R+Math.imul(he,Re)|0,A=A+Math.imul(ae,Te)|0,g=g+Math.imul(ae,De)|0,g=g+Math.imul(fe,Te)|0,R=R+Math.imul(fe,De)|0,A=A+Math.imul(se,Pe)|0,g=g+Math.imul(se,Ne)|0,g=g+Math.imul(oe,Pe)|0,R=R+Math.imul(oe,Ne)|0,A=A+Math.imul(ie,Be)|0,g=g+Math.imul(ie,ke)|0,g=g+Math.imul(ne,Be)|0,R=R+Math.imul(ne,ke)|0;var fn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fn>>>26)|0,fn&=67108863,A=Math.imul(le,Ie),g=Math.imul(le,Me),g=g+Math.imul(pe,Ie)|0,R=Math.imul(pe,Me),A=A+Math.imul(ue,Ae)|0,g=g+Math.imul(ue,Re)|0,g=g+Math.imul(de,Ae)|0,R=R+Math.imul(de,Re)|0,A=A+Math.imul(ce,Te)|0,g=g+Math.imul(ce,De)|0,g=g+Math.imul(he,Te)|0,R=R+Math.imul(he,De)|0,A=A+Math.imul(ae,Pe)|0,g=g+Math.imul(ae,Ne)|0,g=g+Math.imul(fe,Pe)|0,R=R+Math.imul(fe,Ne)|0,A=A+Math.imul(se,Be)|0,g=g+Math.imul(se,ke)|0,g=g+Math.imul(oe,Be)|0,R=R+Math.imul(oe,ke)|0;var cn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cn>>>26)|0,cn&=67108863,A=Math.imul(le,Ae),g=Math.imul(le,Re),g=g+Math.imul(pe,Ae)|0,R=Math.imul(pe,Re),A=A+Math.imul(ue,Te)|0,g=g+Math.imul(ue,De)|0,g=g+Math.imul(de,Te)|0,R=R+Math.imul(de,De)|0,A=A+Math.imul(ce,Pe)|0,g=g+Math.imul(ce,Ne)|0,g=g+Math.imul(he,Pe)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(ae,Be)|0,g=g+Math.imul(ae,ke)|0,g=g+Math.imul(fe,Be)|0,R=R+Math.imul(fe,ke)|0;var hn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(hn>>>26)|0,hn&=67108863,A=Math.imul(le,Te),g=Math.imul(le,De),g=g+Math.imul(pe,Te)|0,R=Math.imul(pe,De),A=A+Math.imul(ue,Pe)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(de,Pe)|0,R=R+Math.imul(de,Ne)|0,A=A+Math.imul(ce,Be)|0,g=g+Math.imul(ce,ke)|0,g=g+Math.imul(he,Be)|0,R=R+Math.imul(he,ke)|0;var fc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fc>>>26)|0,fc&=67108863,A=Math.imul(le,Pe),g=Math.imul(le,Ne),g=g+Math.imul(pe,Pe)|0,R=Math.imul(pe,Ne),A=A+Math.imul(ue,Be)|0,g=g+Math.imul(ue,ke)|0,g=g+Math.imul(de,Be)|0,R=R+Math.imul(de,ke)|0;var cc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cc>>>26)|0,cc&=67108863,A=Math.imul(le,Be),g=Math.imul(le,ke),g=g+Math.imul(pe,Be)|0,R=Math.imul(pe,ke);var hc=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(hc>>>26)|0,hc&=67108863,h[0]=jt,h[1]=Vt,h[2]=$t,h[3]=Ht,h[4]=Gt,h[5]=Qi,h[6]=en,h[7]=tn,h[8]=rn,h[9]=nn,h[10]=sn,h[11]=on,h[12]=an,h[13]=fn,h[14]=cn,h[15]=hn,h[16]=fc,h[17]=cc,h[18]=hc,x!==0&&(h[19]=x,m.length++),m};Math.imul||(P=O);function z(p,a,d){d.negative=a.negative^p.negative,d.length=p.length+a.length;for(var m=0,_=0,y=0;y>>26)|0,_+=h>>>26,h&=67108863}d.words[y]=x,m=h,h=_}return m!==0?d.words[y]=m:d.length--,d._strip()}function B(p,a,d){return z(p,a,d)}n.prototype.mulTo=function(a,d){var m,_=this.length+a.length;return this.length===10&&a.length===10?m=P(this,a,d):_<63?m=O(this,a,d):_<1024?m=z(this,a,d):m=B(this,a,d),m};function U(p,a){this.x=p,this.y=a}U.prototype.makeRBT=function(a){for(var d=new Array(a),m=n.prototype._countBits(a)-1,_=0;_>=1;return _},U.prototype.permute=function(a,d,m,_,y,h){for(var x=0;x>>1)y++;return 1<>>13,m[2*h+1]=y&8191,y=y>>>13;for(h=2*d;h<_;++h)m[h]=0;t(y===0),t((y&-8192)===0)},U.prototype.stub=function(a){for(var d=new Array(a),m=0;m>=26,m+=y/67108864|0,m+=h>>>26,this.words[_]=h&67108863}return m!==0&&(this.words[_]=m,this.length++),d?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var d=T(a);if(d.length===0)return new n(1);for(var m=this,_=0;_=0);var d=a%26,m=(a-d)/26,_=67108863>>>26-d<<26-d,y;if(d!==0){var h=0;for(y=0;y>>26-d}h&&(this.words[y]=h,this.length++)}if(m!==0){for(y=this.length-1;y>=0;y--)this.words[y+m]=this.words[y];for(y=0;y=0);var _;d?_=(d-d%26)/26:_=0;var y=a%26,h=Math.min((a-y)/26,this.length),x=67108863^67108863>>>y<h)for(this.length-=h,g=0;g=0&&(R!==0||g>=_);g--){var k=this.words[g]|0;this.words[g]=R<<26-y|k>>>y,R=k&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,d,m){return t(this.negative===0),this.iushrn(a,d,m)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var d=a%26,m=(a-d)/26,_=1<=0);var d=a%26,m=(a-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(d!==0&&m++,this.length=Math.min(m,this.length),d!==0){var _=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(A/67108864|0),this.words[y+m]=h&67108863}for(;y>26,this.words[y+m]=h&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,y=0;y>26,this.words[y]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,d){var m=this.length-a.length,_=this.clone(),y=a,h=y.words[y.length-1]|0,x=this._countBits(h);m=26-x,m!==0&&(y=y.ushln(m),_.iushln(m),h=y.words[y.length-1]|0);var A=_.length-y.length,g;if(d!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var N=(_.words[y.length+E]|0)*67108864+(_.words[y.length+E-1]|0);for(N=Math.min(N/h|0,67108863),_._ishlnsubmul(y,N,E);_.negative!==0;)N--,_.negative=0,_._ishlnsubmul(y,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=N)}return g&&g._strip(),_._strip(),d!=="div"&&m!==0&&_.iushrn(m),{div:g||null,mod:_}},n.prototype.divmod=function(a,d,m){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,y,h;return this.negative!==0&&a.negative===0?(h=this.neg().divmod(a,d),d!=="mod"&&(_=h.div.neg()),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.iadd(a)),{div:_,mod:y}):this.negative===0&&a.negative!==0?(h=this.divmod(a.neg(),d),d!=="mod"&&(_=h.div.neg()),{div:_,mod:h.mod}):this.negative&a.negative?(h=this.neg().divmod(a.neg(),d),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.isub(a)),{div:h.div,mod:y}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?d==="div"?{div:this.divn(a.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,d)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var d=this.divmod(a);if(d.mod.isZero())return d.div;var m=d.div.negative!==0?d.mod.isub(a):d.mod,_=a.ushrn(1),y=a.andln(1),h=m.cmp(_);return h<0||y===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=(1<<26)%a,_=0,y=this.length-1;y>=0;y--)_=(m*_+(this.words[y]|0))%a;return d?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=0,_=this.length-1;_>=0;_--){var y=(this.words[_]|0)+m*67108864;this.words[_]=y/a|0,m=y%a}return this._strip(),d?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=new n(0),x=new n(1),A=0;d.isEven()&&m.isEven();)d.iushrn(1),m.iushrn(1),++A;for(var g=m.clone(),R=d.clone();!d.isZero();){for(var k=0,E=1;!(d.words[0]&E)&&k<26;++k,E<<=1);if(k>0)for(d.iushrn(k);k-- >0;)(_.isOdd()||y.isOdd())&&(_.iadd(g),y.isub(R)),_.iushrn(1),y.iushrn(1);for(var N=0,F=1;!(m.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(m.iushrn(N);N-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(g),x.isub(R)),h.iushrn(1),x.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(h),y.isub(x)):(m.isub(d),h.isub(_),x.isub(y))}return{a:h,b:x,gcd:m.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=m.clone();d.cmpn(1)>0&&m.cmpn(1)>0;){for(var x=0,A=1;!(d.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(d.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(h),_.iushrn(1);for(var g=0,R=1;!(m.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(m.iushrn(g);g-- >0;)y.isOdd()&&y.iadd(h),y.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(y)):(m.isub(d),y.isub(_))}var k;return d.cmpn(1)===0?k=_:k=y,k.cmpn(0)<0&&k.iadd(a),k},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var d=this.clone(),m=a.clone();d.negative=0,m.negative=0;for(var _=0;d.isEven()&&m.isEven();_++)d.iushrn(1),m.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;m.isEven();)m.iushrn(1);var y=d.cmp(m);if(y<0){var h=d;d=m,m=h}else if(y===0||m.cmpn(1)===0)break;d.isub(m)}while(!0);return m.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var d=a%26,m=(a-d)/26,_=1<>>26,x&=67108863,this.words[h]=x}return y!==0&&(this.words[h]=y,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var d=a<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var m;if(this.length>1)m=1;else{d&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;m=_===a?0:_a.length)return 1;if(this.length=0;m--){var _=this.words[m]|0,y=a.words[m]|0;if(_!==y){_y&&(d=1);break}}return d},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var j={k256:null,p224:null,p192:null,p25519:null};function H(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var d=a,m;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),m=d.bitLength();while(m>this.n);var _=m0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},H.prototype.split=function(a,d){a.iushrn(this.n,0,d)},H.prototype.imulK=function(a){return a.imul(this.k)};function L(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,H),L.prototype.split=function(a,d){for(var m=4194303,_=Math.min(a.length,9),y=0;y<_;y++)d.words[y]=a.words[y];if(d.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var h=a.words[9];for(d.words[d.length++]=h&m,y=10;y>>22,h=x}h>>>=22,a.words[y-10]=h,h===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var d=0,m=0;m>>=26,a.words[m]=y,d=_}return d!==0&&(a.words[a.length++]=d),a},n._prime=function(a){if(j[a])return j[a];var d;if(a==="k256")d=new L;else if(a==="p224")d=new C;else if(a==="p192")d=new W;else if(a==="p25519")d=new D;else throw new Error("Unknown prime "+a);return j[a]=d,d};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,d){t((a.negative|d.negative)===0,"red works only with positives"),t(a.red&&a.red===d.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(c(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,d){this._verify2(a,d);var m=a.add(d);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},l.prototype.iadd=function(a,d){this._verify2(a,d);var m=a.iadd(d);return m.cmp(this.m)>=0&&m.isub(this.m),m},l.prototype.sub=function(a,d){this._verify2(a,d);var m=a.sub(d);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},l.prototype.isub=function(a,d){this._verify2(a,d);var m=a.isub(d);return m.cmpn(0)<0&&m.iadd(this.m),m},l.prototype.shl=function(a,d){return this._verify1(a),this.imod(a.ushln(d))},l.prototype.imul=function(a,d){return this._verify2(a,d),this.imod(a.imul(d))},l.prototype.mul=function(a,d){return this._verify2(a,d),this.imod(a.mul(d))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var m=this.m.add(new n(1)).iushrn(2);return this.pow(a,m)}for(var _=this.m.subn(1),y=0;!_.isZero()&&_.andln(1)===0;)y++,_.iushrn(1);t(!_.isZero());var h=new n(1).toRed(this),x=h.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),k=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),N=y;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;y--){for(var R=d.words[y],k=g-1;k>=0;k--){var E=R>>k&1;if(h!==_[0]&&(h=this.sqr(h)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==m&&(y!==0||k!==0))&&(h=this.mul(h,_[x]),A=0,x=0)}g=26}return h},l.prototype.convertTo=function(a){var d=a.umod(this.m);return d===a?d.clone():d},l.prototype.convertFrom=function(a){var d=a.clone();return d.red=null,d},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var d=this.imod(a.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(a,d){if(a.isZero()||d.isZero())return a.words[0]=0,a.length=1,a;var m=a.imul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(a,d){if(a.isZero()||d.isZero())return new n(0)._forceRed(this);var m=a.mul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(a){var d=this.imod(a._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof Dh>"u"||Dh,Gp)});var Pi=Z((UA,o1)=>{o1.exports=s1;function s1(r,e){if(!r)throw new Error(e||"Assertion failed")}s1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var co=Z((zA,Oh)=>{typeof Object.create=="function"?Oh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Oh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var fr=Z(Ve=>{"use strict";var jw=Pi(),Vw=co();Ve.inherits=Vw;function $w(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Hw(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):$w(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ve.htonl=a1;function Ww(r,e){for(var t="",i=0;i>>0}return s}Ve.join32=Jw;function Yw(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ve.split32=Yw;function Xw(r,e){return r>>>e|r<<32-e}Ve.rotr32=Xw;function Zw(r,e){return r<>>32-e}Ve.rotl32=Zw;function Qw(r,e){return r+e>>>0}Ve.sum32=Qw;function e5(r,e,t){return r+e+t>>>0}Ve.sum32_3=e5;function t5(r,e,t,i){return r+e+t+i>>>0}Ve.sum32_4=t5;function r5(r,e,t,i,n){return r+e+t+i+n>>>0}Ve.sum32_5=r5;function i5(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}Ve.sum64=i5;function n5(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ve.sum64_hi=n5;function s5(r,e,t,i){var n=e+i;return n>>>0}Ve.sum64_lo=s5;function o5(r,e,t,i,n,s,o,f){var u=0,c=e;c=c+i>>>0,u+=c>>0,u+=c>>0,u+=c>>0}Ve.sum64_4_hi=o5;function a5(r,e,t,i,n,s,o,f){var u=e+i+s+f;return u>>>0}Ve.sum64_4_lo=a5;function f5(r,e,t,i,n,s,o,f,u,c){var b=0,v=e;v=v+i>>>0,b+=v>>0,b+=v>>0,b+=v>>0,b+=v>>0}Ve.sum64_5_hi=f5;function c5(r,e,t,i,n,s,o,f,u,c){var b=e+i+s+f+c;return b>>>0}Ve.sum64_5_lo=c5;function h5(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ve.rotr64_hi=h5;function u5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.rotr64_lo=u5;function d5(r,e,t){return r>>>t}Ve.shr64_hi=d5;function l5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.shr64_lo=l5});var os=Z(u1=>{"use strict";var h1=fr(),p5=Pi();function Ga(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}u1.BlockHash=Ga;Ga.prototype.update=function(e,t){if(e=h1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=h1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var g5=fr(),zr=g5.rotr32;function b5(r,e,t,i){if(r===0)return d1(e,t,i);if(r===1||r===3)return p1(e,t,i);if(r===2)return l1(e,t,i)}ui.ft_1=b5;function d1(r,e,t){return r&e^~r&t}ui.ch32=d1;function l1(r,e,t){return r&e^r&t^e&t}ui.maj32=l1;function p1(r,e,t){return r^e^t}ui.p32=p1;function v5(r){return zr(r,2)^zr(r,13)^zr(r,22)}ui.s0_256=v5;function m5(r){return zr(r,6)^zr(r,11)^zr(r,25)}ui.s1_256=m5;function y5(r){return zr(r,7)^zr(r,18)^r>>>3}ui.g0_256=y5;function w5(r){return zr(r,17)^zr(r,19)^r>>>10}ui.g1_256=w5});var v1=Z((jA,b1)=>{"use strict";var as=fr(),_5=os(),x5=Lh(),Fh=as.rotl32,ho=as.sum32,E5=as.sum32_5,S5=x5.ft_1,g1=_5.BlockHash,I5=[1518500249,1859775393,2400959708,3395469782];function Br(){if(!(this instanceof Br))return new Br;g1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}as.inherits(Br,g1);b1.exports=Br;Br.blockSize=512;Br.outSize=160;Br.hmacStrength=80;Br.padLength=64;Br.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var fs=fr(),M5=os(),cs=Lh(),A5=Pi(),cr=fs.sum32,R5=fs.sum32_4,T5=fs.sum32_5,D5=cs.ch32,P5=cs.maj32,N5=cs.s0_256,C5=cs.s1_256,O5=cs.g0_256,L5=cs.g1_256,m1=M5.BlockHash,F5=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function kr(){if(!(this instanceof kr))return new kr;m1.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=F5,this.W=new Array(64)}fs.inherits(kr,m1);y1.exports=kr;kr.blockSize=512;kr.outSize=256;kr.hmacStrength=192;kr.padLength=64;kr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Uh=fr(),w1=qh();function di(){if(!(this instanceof di))return new di;w1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Uh.inherits(di,w1);_1.exports=di;di.blockSize=512;di.outSize=224;di.hmacStrength=192;di.padLength=64;di.prototype._digest=function(e){return e==="hex"?Uh.toHex32(this.h.slice(0,7),"big"):Uh.split32(this.h.slice(0,7),"big")}});var kh=Z((HA,M1)=>{"use strict";var Ot=fr(),q5=os(),U5=Pi(),Kr=Ot.rotr64_hi,jr=Ot.rotr64_lo,E1=Ot.shr64_hi,S1=Ot.shr64_lo,Ni=Ot.sum64,zh=Ot.sum64_hi,Bh=Ot.sum64_lo,z5=Ot.sum64_4_hi,B5=Ot.sum64_4_lo,k5=Ot.sum64_5_hi,K5=Ot.sum64_5_lo,I1=q5.BlockHash,j5=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function hr(){if(!(this instanceof hr))return new hr;I1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=j5,this.W=new Array(160)}Ot.inherits(hr,I1);M1.exports=hr;hr.blockSize=1024;hr.outSize=512;hr.hmacStrength=192;hr.padLength=128;hr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Kh=fr(),A1=kh();function li(){if(!(this instanceof li))return new li;A1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Kh.inherits(li,A1);R1.exports=li;li.blockSize=1024;li.outSize=384;li.hmacStrength=192;li.padLength=128;li.prototype._digest=function(e){return e==="hex"?Kh.toHex32(this.h.slice(0,12),"big"):Kh.split32(this.h.slice(0,12),"big")}});var D1=Z(hs=>{"use strict";hs.sha1=v1();hs.sha224=x1();hs.sha256=qh();hs.sha384=T1();hs.sha512=kh()});var F1=Z(L1=>{"use strict";var _n=fr(),r8=os(),Wa=_n.rotl32,P1=_n.sum32,uo=_n.sum32_3,N1=_n.sum32_4,O1=r8.BlockHash;function Vr(){if(!(this instanceof Vr))return new Vr;O1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}_n.inherits(Vr,O1);L1.ripemd160=Vr;Vr.blockSize=512;Vr.outSize=160;Vr.hmacStrength=192;Vr.padLength=64;Vr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],u=i,c=n,b=s,v=o,S=f,I=0;I<80;I++){var M=P1(Wa(N1(i,C1(I,n,s,o),e[s8[I]+t],i8(I)),a8[I]),f);i=f,f=o,o=Wa(s,10),s=n,n=M,M=P1(Wa(N1(u,C1(79-I,c,b,v),e[o8[I]+t],n8(I)),f8[I]),S),u=S,S=v,v=Wa(b,10),b=c,c=M}M=uo(this.h[1],s,v),this.h[1]=uo(this.h[2],o,S),this.h[2]=uo(this.h[3],f,u),this.h[3]=uo(this.h[4],i,c),this.h[4]=uo(this.h[0],n,b),this.h[0]=M};Vr.prototype._digest=function(e){return e==="hex"?_n.toHex32(this.h,"little"):_n.split32(this.h,"little")};function C1(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function i8(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function n8(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var s8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o8=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],a8=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f8=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var U1=Z((YA,q1)=>{"use strict";var c8=fr(),h8=Pi();function us(r,e,t){if(!(this instanceof us))return new us(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(c8.toArray(e,t))}q1.exports=us;us.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),h8(e.length<=this.blockSize);for(var t=e.length;t{var pt=z1;pt.utils=fr();pt.common=os();pt.sha=D1();pt.ripemd=F1();pt.hmac=U1();pt.sha1=pt.sha.sha1;pt.sha256=pt.sha.sha256;pt.sha224=pt.sha.sha224;pt.sha384=pt.sha.sha384;pt.sha512=pt.sha.sha512;pt.ripemd160=pt.ripemd.ripemd160});var X1=Z(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var Et=Hn(),Qh=Jt(),_8=20;function x8(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],c=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],v=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],P=e[11]<<24|e[10]<<16|e[9]<<8|e[8],z=e[15]<<24|e[14]<<16|e[13]<<8|e[12],B=i,U=n,j=s,H=o,L=f,C=u,W=c,D=b,l=v,w=S,p=I,a=M,d=T,m=O,_=P,y=z,h=0;h<_8;h+=2)B=B+L|0,d^=B,d=d>>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,U=U+C|0,m^=U,m=m>>>16|m<<16,w=w+m|0,C^=w,C=C>>>20|C<<12,j=j+W|0,_^=j,_=_>>>16|_<<16,p=p+_|0,W^=p,W=W>>>20|W<<12,H=H+D|0,y^=H,y=y>>>16|y<<16,a=a+y|0,D^=a,D=D>>>20|D<<12,j=j+W|0,_^=j,_=_>>>24|_<<8,p=p+_|0,W^=p,W=W>>>25|W<<7,H=H+D|0,y^=H,y=y>>>24|y<<8,a=a+y|0,D^=a,D=D>>>25|D<<7,U=U+C|0,m^=U,m=m>>>24|m<<8,w=w+m|0,C^=w,C=C>>>25|C<<7,B=B+L|0,d^=B,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,B=B+C|0,y^=B,y=y>>>16|y<<16,p=p+y|0,C^=p,C=C>>>20|C<<12,U=U+W|0,d^=U,d=d>>>16|d<<16,a=a+d|0,W^=a,W=W>>>20|W<<12,j=j+D|0,m^=j,m=m>>>16|m<<16,l=l+m|0,D^=l,D=D>>>20|D<<12,H=H+L|0,_^=H,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,j=j+D|0,m^=j,m=m>>>24|m<<8,l=l+m|0,D^=l,D=D>>>25|D<<7,H=H+L|0,_^=H,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,U=U+W|0,d^=U,d=d>>>24|d<<8,a=a+d|0,W^=a,W=W>>>25|W<<7,B=B+C|0,y^=B,y=y>>>24|y<<8,p=p+y|0,C^=p,C=C>>>25|C<<7;Et.writeUint32LE(B+i|0,r,0),Et.writeUint32LE(U+n|0,r,4),Et.writeUint32LE(j+s|0,r,8),Et.writeUint32LE(H+o|0,r,12),Et.writeUint32LE(L+f|0,r,16),Et.writeUint32LE(C+u|0,r,20),Et.writeUint32LE(W+c|0,r,24),Et.writeUint32LE(D+b|0,r,28),Et.writeUint32LE(l+v|0,r,32),Et.writeUint32LE(w+S|0,r,36),Et.writeUint32LE(p+I|0,r,40),Et.writeUint32LE(a+M|0,r,44),Et.writeUint32LE(d+T|0,r,48),Et.writeUint32LE(m+O|0,r,52),Et.writeUint32LE(_+P|0,r,56),Et.writeUint32LE(y+z|0,r,60)}function Y1(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var rf=Z(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});function I8(r,e,t){return~(r-1)&e|r-1&t}ls.select=I8;function M8(r,e){return(r|0)-(e|0)-1>>>31&1}ls.lessOrEqual=M8;function Z1(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}ls.compare=Z1;function A8(r,e){return r.length===0||e.length===0?!1:Z1(r,e)!==0}ls.equal=A8});var eg=Z(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var R8=rf(),nf=Jt();pi.DIGEST_LENGTH=16;var Q1=function(){function r(e){this.digestLength=pi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var u=e[12]|e[13]<<8;this._r[7]=(f>>>11|u<<5)&8065;var c=e[14]|e[15]<<8;this._r[8]=(u>>>8|c<<8)&8191,this._r[9]=c>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],u=this._h[3],c=this._h[4],b=this._h[5],v=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],O=this._r[1],P=this._r[2],z=this._r[3],B=this._r[4],U=this._r[5],j=this._r[6],H=this._r[7],L=this._r[8],C=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var D=e[t+2]|e[t+3]<<8;o+=(W>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;u+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;c+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;v+=(p>>>14|a<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(a>>>11|d<<5)&8191;var m=e[t+14]|e[t+15]<<8;I+=(d>>>8|m<<8)&8191,M+=m>>>5|n;var _=0,y=_;y+=s*T,y+=o*(5*C),y+=f*(5*L),y+=u*(5*H),y+=c*(5*j),_=y>>>13,y&=8191,y+=b*(5*U),y+=v*(5*B),y+=S*(5*z),y+=I*(5*P),y+=M*(5*O),_+=y>>>13,y&=8191;var h=_;h+=s*O,h+=o*T,h+=f*(5*C),h+=u*(5*L),h+=c*(5*H),_=h>>>13,h&=8191,h+=b*(5*j),h+=v*(5*U),h+=S*(5*B),h+=I*(5*z),h+=M*(5*P),_+=h>>>13,h&=8191;var x=_;x+=s*P,x+=o*O,x+=f*T,x+=u*(5*C),x+=c*(5*L),_=x>>>13,x&=8191,x+=b*(5*H),x+=v*(5*j),x+=S*(5*U),x+=I*(5*B),x+=M*(5*z),_+=x>>>13,x&=8191;var A=_;A+=s*z,A+=o*P,A+=f*O,A+=u*T,A+=c*(5*C),_=A>>>13,A&=8191,A+=b*(5*L),A+=v*(5*H),A+=S*(5*j),A+=I*(5*U),A+=M*(5*B),_+=A>>>13,A&=8191;var g=_;g+=s*B,g+=o*z,g+=f*P,g+=u*O,g+=c*T,_=g>>>13,g&=8191,g+=b*(5*C),g+=v*(5*L),g+=S*(5*H),g+=I*(5*j),g+=M*(5*U),_+=g>>>13,g&=8191;var R=_;R+=s*U,R+=o*B,R+=f*z,R+=u*P,R+=c*O,_=R>>>13,R&=8191,R+=b*T,R+=v*(5*C),R+=S*(5*L),R+=I*(5*H),R+=M*(5*j),_+=R>>>13,R&=8191;var k=_;k+=s*j,k+=o*U,k+=f*B,k+=u*z,k+=c*P,_=k>>>13,k&=8191,k+=b*O,k+=v*T,k+=S*(5*C),k+=I*(5*L),k+=M*(5*H),_+=k>>>13,k&=8191;var E=_;E+=s*H,E+=o*j,E+=f*U,E+=u*B,E+=c*z,_=E>>>13,E&=8191,E+=b*P,E+=v*O,E+=S*T,E+=I*(5*C),E+=M*(5*L),_+=E>>>13,E&=8191;var N=_;N+=s*L,N+=o*H,N+=f*j,N+=u*U,N+=c*B,_=N>>>13,N&=8191,N+=b*z,N+=v*P,N+=S*O,N+=I*T,N+=M*(5*C),_+=N>>>13,N&=8191;var F=_;F+=s*C,F+=o*L,F+=f*H,F+=u*j,F+=c*U,_=F>>>13,F&=8191,F+=b*B,F+=v*z,F+=S*P,F+=I*O,F+=M*T,_+=F>>>13,F&=8191,_=(_<<2)+_|0,_=_+y|0,y=_&8191,_=_>>>13,h+=_,s=y,o=h,f=x,u=A,c=g,b=R,v=k,S=E,I=N,M=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=u,this._h[4]=c,this._h[5]=b,this._h[6]=v,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});var sf=X1(),P8=eg(),po=Jt(),tg=Hn(),N8=rf();gi.KEY_LENGTH=32;gi.NONCE_LENGTH=12;gi.TAG_LENGTH=16;var rg=new Uint8Array(16),C8=function(){function r(e){if(this.nonceLength=gi.NONCE_LENGTH,this.tagLength=gi.TAG_LENGTH,e.length!==gi.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);sf.stream(this._key,s,o,4);var f=t.length+this.tagLength,u;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");u=n}else u=new Uint8Array(f);return sf.streamXOR(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),i),po.wipe(s),u},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(rg.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(rg.subarray(i.length%16));var o=new Uint8Array(8);n&&tg.writeUint64LE(n.length,o),s.update(o),tg.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),u=0;u{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});function O8(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}eu.isSerializableHash=O8});var og=Z(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Gr=ng(),L8=rf(),F8=Jt(),sg=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ag=og(),fg=Jt(),U8=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ag.hmac(this._hash,i,t);this._hmac=new ag.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});var af=Hn(),of=Jt();Li.DIGEST_LENGTH=32;Li.BLOCK_SIZE=64;var hg=function(){function r(){this.digestLength=Li.DIGEST_LENGTH,this.blockSize=Li.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){of.wipe(this._buffer),of.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ru(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ru(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){of.wipe(e.state),e.buffer&&of.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Li.SHA256=hg;var z8=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ru(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],u=e[3],c=e[4],b=e[5],v=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=af.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],O=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var P=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(O+r[I-7]|0)+(P+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&b^~c&v)|0)+(S+(z8[I]+r[I]|0)|0)|0,P=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=v,v=b,b=c,c=u+O|0,u=f,f=o,o=s,s=O+P|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=u,e[4]+=c,e[5]+=b,e[6]+=v,e[7]+=S,i+=64,n-=64}return i}function B8(r){var e=new hg;e.update(r);var t=e.digest();return e.clean(),t}Li.hash=B8});var gg=Z(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.sharedKey=Qe.generateKeyPair=Qe.generateKeyPairFromSeed=Qe.scalarMultBase=Qe.scalarMult=Qe.SHARED_KEY_LENGTH=Qe.SECRET_KEY_LENGTH=Qe.PUBLIC_KEY_LENGTH=void 0;var k8=Js(),K8=Jt();Qe.PUBLIC_KEY_LENGTH=32;Qe.SECRET_KEY_LENGTH=32;Qe.SHARED_KEY_LENGTH=32;function Wr(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function $8(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ff(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function cf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function bi(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function vo(r,e){bi(r,e,e)}function H8(r,e){let t=Wr();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)vo(t,t),i!==2&&i!==4&&bi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function nu(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=Wr(),s=Wr(),o=Wr(),f=Wr(),u=Wr(),c=Wr();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,$8(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;bo(n,s,M),bo(o,f,M),ff(u,n,o),cf(n,n,o),ff(o,s,f),cf(s,s,f),vo(f,u),vo(c,n),bi(n,o,n),bi(o,s,u),ff(u,n,o),cf(n,n,o),vo(s,n),cf(o,f,c),bi(n,o,j8),ff(n,n,f),bi(o,o,n),bi(n,f,c),bi(f,s,i),vo(s,u),bo(n,s,M),bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),v=i.subarray(16);H8(b,b),bi(v,v,b);let S=new Uint8Array(32);return V8(S,v),S}Qe.scalarMult=nu;function lg(r){return nu(r,dg)}Qe.scalarMultBase=lg;function pg(r){if(r.length!==Qe.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${Qe.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:lg(e),secretKey:e}}Qe.generateKeyPairFromSeed=pg;function G8(r){let e=(0,k8.randomBytes)(32,r),t=pg(e);return(0,K8.wipe)(e),t}Qe.generateKeyPair=G8;function W8(r,e,t=!1){if(r.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=nu(r,e);if(t){let n=0;for(let s=0;s{J8.exports={name:"elliptic",version:"6.6.0",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var Jr=Z((vg,su)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)m=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[d]|=m<<_&67108863,this.words[d+1]=m>>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);else if(p==="le")for(a=0,d=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8;else{var y=l.length-w;for(a=y%2===0?w+1:w;a=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8}this.strip()};function u(D,l,w,p){for(var a=0,d=Math.min(D.length,w),m=l;m=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=w)a++;a--,d=d/w|0;for(var m=l.length-p,_=m%a,y=Math.min(m,m-_)+p,h=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,d=0,m=0;m>>24-a&16777215,d!==0||m!==this.length-1?p=c[6-y.length]+y+p:p=y+p,a+=2,a>=26&&(a-=26,m--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=b[l],x=v[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=c[h-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),d=p||Math.max(1,a);t(a<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var m=w==="le",_=new l(d),y,h,x=this.clone();if(m){for(h=0;!x.isZero();h++)y=x.andln(255),x.iushrn(8),_[h]=y;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var d=0,m=0;m>>26;for(;d!==0&&m>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;ml.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;p>0?(a=this,d=l):(a=l,d=this);for(var m=0,_=0;_>26,this.words[_]=w&67108863;for(;m!==0&&_>26,this.words[_]=w&67108863;if(m===0&&_>>26,A=y&67108863,g=Math.min(h,l.length-1),R=Math.max(0,h-D.length+1);R<=g;R++){var k=h-R|0;a=D.words[k]|0,d=l.words[R]|0,m=a*d+A,x+=m/67108864|0,A=m&67108863}w.words[h]=A|0,y=x|0}return y!==0?w.words[h]=y|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,d=w.words,m=p.words,_=0,y,h,x,A=a[0]|0,g=A&8191,R=A>>>13,k=a[1]|0,E=k&8191,N=k>>>13,F=a[2]|0,q=F&8191,K=F>>>13,J=a[3]|0,$=J&8191,V=J>>>13,ee=a[4]|0,G=ee&8191,Y=ee>>>13,_r=a[5]|0,ie=_r&8191,ne=_r>>>13,xr=a[6]|0,se=xr&8191,oe=xr>>>13,Er=a[7]|0,ae=Er&8191,fe=Er>>>13,Sr=a[8]|0,ce=Sr&8191,he=Sr>>>13,Ir=a[9]|0,ue=Ir&8191,de=Ir>>>13,Mr=d[0]|0,le=Mr&8191,pe=Mr>>>13,Ar=d[1]|0,ge=Ar&8191,be=Ar>>>13,Rr=d[2]|0,ve=Rr&8191,me=Rr>>>13,Tr=d[3]|0,ye=Tr&8191,we=Tr>>>13,Dr=d[4]|0,_e=Dr&8191,xe=Dr>>>13,Pr=d[5]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=d[6]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=d[7]|0,Ae=Cr&8191,Re=Cr>>>13,Or=d[8]|0,Te=Or&8191,De=Or>>>13,Lr=d[9]|0,Pe=Lr&8191,Ne=Lr>>>13;p.negative=l.negative^w.negative,p.length=19,y=Math.imul(g,le),h=Math.imul(g,pe),h=h+Math.imul(R,le)|0,x=Math.imul(R,pe);var nr=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,y=Math.imul(E,le),h=Math.imul(E,pe),h=h+Math.imul(N,le)|0,x=Math.imul(N,pe),y=y+Math.imul(g,ge)|0,h=h+Math.imul(g,be)|0,h=h+Math.imul(R,ge)|0,x=x+Math.imul(R,be)|0;var Be=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Be>>>26)|0,Be&=67108863,y=Math.imul(q,le),h=Math.imul(q,pe),h=h+Math.imul(K,le)|0,x=Math.imul(K,pe),y=y+Math.imul(E,ge)|0,h=h+Math.imul(E,be)|0,h=h+Math.imul(N,ge)|0,x=x+Math.imul(N,be)|0,y=y+Math.imul(g,ve)|0,h=h+Math.imul(g,me)|0,h=h+Math.imul(R,ve)|0,x=x+Math.imul(R,me)|0;var ke=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ke>>>26)|0,ke&=67108863,y=Math.imul($,le),h=Math.imul($,pe),h=h+Math.imul(V,le)|0,x=Math.imul(V,pe),y=y+Math.imul(q,ge)|0,h=h+Math.imul(q,be)|0,h=h+Math.imul(K,ge)|0,x=x+Math.imul(K,be)|0,y=y+Math.imul(E,ve)|0,h=h+Math.imul(E,me)|0,h=h+Math.imul(N,ve)|0,x=x+Math.imul(N,me)|0,y=y+Math.imul(g,ye)|0,h=h+Math.imul(g,we)|0,h=h+Math.imul(R,ye)|0,x=x+Math.imul(R,we)|0;var jt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(jt>>>26)|0,jt&=67108863,y=Math.imul(G,le),h=Math.imul(G,pe),h=h+Math.imul(Y,le)|0,x=Math.imul(Y,pe),y=y+Math.imul($,ge)|0,h=h+Math.imul($,be)|0,h=h+Math.imul(V,ge)|0,x=x+Math.imul(V,be)|0,y=y+Math.imul(q,ve)|0,h=h+Math.imul(q,me)|0,h=h+Math.imul(K,ve)|0,x=x+Math.imul(K,me)|0,y=y+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(N,ye)|0,x=x+Math.imul(N,we)|0,y=y+Math.imul(g,_e)|0,h=h+Math.imul(g,xe)|0,h=h+Math.imul(R,_e)|0,x=x+Math.imul(R,xe)|0;var Vt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,y=Math.imul(ie,le),h=Math.imul(ie,pe),h=h+Math.imul(ne,le)|0,x=Math.imul(ne,pe),y=y+Math.imul(G,ge)|0,h=h+Math.imul(G,be)|0,h=h+Math.imul(Y,ge)|0,x=x+Math.imul(Y,be)|0,y=y+Math.imul($,ve)|0,h=h+Math.imul($,me)|0,h=h+Math.imul(V,ve)|0,x=x+Math.imul(V,me)|0,y=y+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,x=x+Math.imul(K,we)|0,y=y+Math.imul(E,_e)|0,h=h+Math.imul(E,xe)|0,h=h+Math.imul(N,_e)|0,x=x+Math.imul(N,xe)|0,y=y+Math.imul(g,Ee)|0,h=h+Math.imul(g,Se)|0,h=h+Math.imul(R,Ee)|0,x=x+Math.imul(R,Se)|0;var $t=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,y=Math.imul(se,le),h=Math.imul(se,pe),h=h+Math.imul(oe,le)|0,x=Math.imul(oe,pe),y=y+Math.imul(ie,ge)|0,h=h+Math.imul(ie,be)|0,h=h+Math.imul(ne,ge)|0,x=x+Math.imul(ne,be)|0,y=y+Math.imul(G,ve)|0,h=h+Math.imul(G,me)|0,h=h+Math.imul(Y,ve)|0,x=x+Math.imul(Y,me)|0,y=y+Math.imul($,ye)|0,h=h+Math.imul($,we)|0,h=h+Math.imul(V,ye)|0,x=x+Math.imul(V,we)|0,y=y+Math.imul(q,_e)|0,h=h+Math.imul(q,xe)|0,h=h+Math.imul(K,_e)|0,x=x+Math.imul(K,xe)|0,y=y+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(N,Ee)|0,x=x+Math.imul(N,Se)|0,y=y+Math.imul(g,Ie)|0,h=h+Math.imul(g,Me)|0,h=h+Math.imul(R,Ie)|0,x=x+Math.imul(R,Me)|0;var Ht=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,y=Math.imul(ae,le),h=Math.imul(ae,pe),h=h+Math.imul(fe,le)|0,x=Math.imul(fe,pe),y=y+Math.imul(se,ge)|0,h=h+Math.imul(se,be)|0,h=h+Math.imul(oe,ge)|0,x=x+Math.imul(oe,be)|0,y=y+Math.imul(ie,ve)|0,h=h+Math.imul(ie,me)|0,h=h+Math.imul(ne,ve)|0,x=x+Math.imul(ne,me)|0,y=y+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(Y,ye)|0,x=x+Math.imul(Y,we)|0,y=y+Math.imul($,_e)|0,h=h+Math.imul($,xe)|0,h=h+Math.imul(V,_e)|0,x=x+Math.imul(V,xe)|0,y=y+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,x=x+Math.imul(K,Se)|0,y=y+Math.imul(E,Ie)|0,h=h+Math.imul(E,Me)|0,h=h+Math.imul(N,Ie)|0,x=x+Math.imul(N,Me)|0,y=y+Math.imul(g,Ae)|0,h=h+Math.imul(g,Re)|0,h=h+Math.imul(R,Ae)|0,x=x+Math.imul(R,Re)|0;var Gt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,y=Math.imul(ce,le),h=Math.imul(ce,pe),h=h+Math.imul(he,le)|0,x=Math.imul(he,pe),y=y+Math.imul(ae,ge)|0,h=h+Math.imul(ae,be)|0,h=h+Math.imul(fe,ge)|0,x=x+Math.imul(fe,be)|0,y=y+Math.imul(se,ve)|0,h=h+Math.imul(se,me)|0,h=h+Math.imul(oe,ve)|0,x=x+Math.imul(oe,me)|0,y=y+Math.imul(ie,ye)|0,h=h+Math.imul(ie,we)|0,h=h+Math.imul(ne,ye)|0,x=x+Math.imul(ne,we)|0,y=y+Math.imul(G,_e)|0,h=h+Math.imul(G,xe)|0,h=h+Math.imul(Y,_e)|0,x=x+Math.imul(Y,xe)|0,y=y+Math.imul($,Ee)|0,h=h+Math.imul($,Se)|0,h=h+Math.imul(V,Ee)|0,x=x+Math.imul(V,Se)|0,y=y+Math.imul(q,Ie)|0,h=h+Math.imul(q,Me)|0,h=h+Math.imul(K,Ie)|0,x=x+Math.imul(K,Me)|0,y=y+Math.imul(E,Ae)|0,h=h+Math.imul(E,Re)|0,h=h+Math.imul(N,Ae)|0,x=x+Math.imul(N,Re)|0,y=y+Math.imul(g,Te)|0,h=h+Math.imul(g,De)|0,h=h+Math.imul(R,Te)|0,x=x+Math.imul(R,De)|0;var Qi=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,y=Math.imul(ue,le),h=Math.imul(ue,pe),h=h+Math.imul(de,le)|0,x=Math.imul(de,pe),y=y+Math.imul(ce,ge)|0,h=h+Math.imul(ce,be)|0,h=h+Math.imul(he,ge)|0,x=x+Math.imul(he,be)|0,y=y+Math.imul(ae,ve)|0,h=h+Math.imul(ae,me)|0,h=h+Math.imul(fe,ve)|0,x=x+Math.imul(fe,me)|0,y=y+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,x=x+Math.imul(oe,we)|0,y=y+Math.imul(ie,_e)|0,h=h+Math.imul(ie,xe)|0,h=h+Math.imul(ne,_e)|0,x=x+Math.imul(ne,xe)|0,y=y+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(Y,Ee)|0,x=x+Math.imul(Y,Se)|0,y=y+Math.imul($,Ie)|0,h=h+Math.imul($,Me)|0,h=h+Math.imul(V,Ie)|0,x=x+Math.imul(V,Me)|0,y=y+Math.imul(q,Ae)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(K,Ae)|0,x=x+Math.imul(K,Re)|0,y=y+Math.imul(E,Te)|0,h=h+Math.imul(E,De)|0,h=h+Math.imul(N,Te)|0,x=x+Math.imul(N,De)|0,y=y+Math.imul(g,Pe)|0,h=h+Math.imul(g,Ne)|0,h=h+Math.imul(R,Pe)|0,x=x+Math.imul(R,Ne)|0;var en=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(en>>>26)|0,en&=67108863,y=Math.imul(ue,ge),h=Math.imul(ue,be),h=h+Math.imul(de,ge)|0,x=Math.imul(de,be),y=y+Math.imul(ce,ve)|0,h=h+Math.imul(ce,me)|0,h=h+Math.imul(he,ve)|0,x=x+Math.imul(he,me)|0,y=y+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(fe,ye)|0,x=x+Math.imul(fe,we)|0,y=y+Math.imul(se,_e)|0,h=h+Math.imul(se,xe)|0,h=h+Math.imul(oe,_e)|0,x=x+Math.imul(oe,xe)|0,y=y+Math.imul(ie,Ee)|0,h=h+Math.imul(ie,Se)|0,h=h+Math.imul(ne,Ee)|0,x=x+Math.imul(ne,Se)|0,y=y+Math.imul(G,Ie)|0,h=h+Math.imul(G,Me)|0,h=h+Math.imul(Y,Ie)|0,x=x+Math.imul(Y,Me)|0,y=y+Math.imul($,Ae)|0,h=h+Math.imul($,Re)|0,h=h+Math.imul(V,Ae)|0,x=x+Math.imul(V,Re)|0,y=y+Math.imul(q,Te)|0,h=h+Math.imul(q,De)|0,h=h+Math.imul(K,Te)|0,x=x+Math.imul(K,De)|0,y=y+Math.imul(E,Pe)|0,h=h+Math.imul(E,Ne)|0,h=h+Math.imul(N,Pe)|0,x=x+Math.imul(N,Ne)|0;var tn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(tn>>>26)|0,tn&=67108863,y=Math.imul(ue,ve),h=Math.imul(ue,me),h=h+Math.imul(de,ve)|0,x=Math.imul(de,me),y=y+Math.imul(ce,ye)|0,h=h+Math.imul(ce,we)|0,h=h+Math.imul(he,ye)|0,x=x+Math.imul(he,we)|0,y=y+Math.imul(ae,_e)|0,h=h+Math.imul(ae,xe)|0,h=h+Math.imul(fe,_e)|0,x=x+Math.imul(fe,xe)|0,y=y+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,x=x+Math.imul(oe,Se)|0,y=y+Math.imul(ie,Ie)|0,h=h+Math.imul(ie,Me)|0,h=h+Math.imul(ne,Ie)|0,x=x+Math.imul(ne,Me)|0,y=y+Math.imul(G,Ae)|0,h=h+Math.imul(G,Re)|0,h=h+Math.imul(Y,Ae)|0,x=x+Math.imul(Y,Re)|0,y=y+Math.imul($,Te)|0,h=h+Math.imul($,De)|0,h=h+Math.imul(V,Te)|0,x=x+Math.imul(V,De)|0,y=y+Math.imul(q,Pe)|0,h=h+Math.imul(q,Ne)|0,h=h+Math.imul(K,Pe)|0,x=x+Math.imul(K,Ne)|0;var rn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(rn>>>26)|0,rn&=67108863,y=Math.imul(ue,ye),h=Math.imul(ue,we),h=h+Math.imul(de,ye)|0,x=Math.imul(de,we),y=y+Math.imul(ce,_e)|0,h=h+Math.imul(ce,xe)|0,h=h+Math.imul(he,_e)|0,x=x+Math.imul(he,xe)|0,y=y+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(fe,Ee)|0,x=x+Math.imul(fe,Se)|0,y=y+Math.imul(se,Ie)|0,h=h+Math.imul(se,Me)|0,h=h+Math.imul(oe,Ie)|0,x=x+Math.imul(oe,Me)|0,y=y+Math.imul(ie,Ae)|0,h=h+Math.imul(ie,Re)|0,h=h+Math.imul(ne,Ae)|0,x=x+Math.imul(ne,Re)|0,y=y+Math.imul(G,Te)|0,h=h+Math.imul(G,De)|0,h=h+Math.imul(Y,Te)|0,x=x+Math.imul(Y,De)|0,y=y+Math.imul($,Pe)|0,h=h+Math.imul($,Ne)|0,h=h+Math.imul(V,Pe)|0,x=x+Math.imul(V,Ne)|0;var nn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nn>>>26)|0,nn&=67108863,y=Math.imul(ue,_e),h=Math.imul(ue,xe),h=h+Math.imul(de,_e)|0,x=Math.imul(de,xe),y=y+Math.imul(ce,Ee)|0,h=h+Math.imul(ce,Se)|0,h=h+Math.imul(he,Ee)|0,x=x+Math.imul(he,Se)|0,y=y+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Me)|0,h=h+Math.imul(fe,Ie)|0,x=x+Math.imul(fe,Me)|0,y=y+Math.imul(se,Ae)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(oe,Ae)|0,x=x+Math.imul(oe,Re)|0,y=y+Math.imul(ie,Te)|0,h=h+Math.imul(ie,De)|0,h=h+Math.imul(ne,Te)|0,x=x+Math.imul(ne,De)|0,y=y+Math.imul(G,Pe)|0,h=h+Math.imul(G,Ne)|0,h=h+Math.imul(Y,Pe)|0,x=x+Math.imul(Y,Ne)|0;var sn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(sn>>>26)|0,sn&=67108863,y=Math.imul(ue,Ee),h=Math.imul(ue,Se),h=h+Math.imul(de,Ee)|0,x=Math.imul(de,Se),y=y+Math.imul(ce,Ie)|0,h=h+Math.imul(ce,Me)|0,h=h+Math.imul(he,Ie)|0,x=x+Math.imul(he,Me)|0,y=y+Math.imul(ae,Ae)|0,h=h+Math.imul(ae,Re)|0,h=h+Math.imul(fe,Ae)|0,x=x+Math.imul(fe,Re)|0,y=y+Math.imul(se,Te)|0,h=h+Math.imul(se,De)|0,h=h+Math.imul(oe,Te)|0,x=x+Math.imul(oe,De)|0,y=y+Math.imul(ie,Pe)|0,h=h+Math.imul(ie,Ne)|0,h=h+Math.imul(ne,Pe)|0,x=x+Math.imul(ne,Ne)|0;var on=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(on>>>26)|0,on&=67108863,y=Math.imul(ue,Ie),h=Math.imul(ue,Me),h=h+Math.imul(de,Ie)|0,x=Math.imul(de,Me),y=y+Math.imul(ce,Ae)|0,h=h+Math.imul(ce,Re)|0,h=h+Math.imul(he,Ae)|0,x=x+Math.imul(he,Re)|0,y=y+Math.imul(ae,Te)|0,h=h+Math.imul(ae,De)|0,h=h+Math.imul(fe,Te)|0,x=x+Math.imul(fe,De)|0,y=y+Math.imul(se,Pe)|0,h=h+Math.imul(se,Ne)|0,h=h+Math.imul(oe,Pe)|0,x=x+Math.imul(oe,Ne)|0;var an=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(an>>>26)|0,an&=67108863,y=Math.imul(ue,Ae),h=Math.imul(ue,Re),h=h+Math.imul(de,Ae)|0,x=Math.imul(de,Re),y=y+Math.imul(ce,Te)|0,h=h+Math.imul(ce,De)|0,h=h+Math.imul(he,Te)|0,x=x+Math.imul(he,De)|0,y=y+Math.imul(ae,Pe)|0,h=h+Math.imul(ae,Ne)|0,h=h+Math.imul(fe,Pe)|0,x=x+Math.imul(fe,Ne)|0;var fn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(fn>>>26)|0,fn&=67108863,y=Math.imul(ue,Te),h=Math.imul(ue,De),h=h+Math.imul(de,Te)|0,x=Math.imul(de,De),y=y+Math.imul(ce,Pe)|0,h=h+Math.imul(ce,Ne)|0,h=h+Math.imul(he,Pe)|0,x=x+Math.imul(he,Ne)|0;var cn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(cn>>>26)|0,cn&=67108863,y=Math.imul(ue,Pe),h=Math.imul(ue,Ne),h=h+Math.imul(de,Pe)|0,x=Math.imul(de,Ne);var hn=(_+y|0)+((h&8191)<<13)|0;return _=(x+(h>>>13)|0)+(hn>>>26)|0,hn&=67108863,m[0]=nr,m[1]=Be,m[2]=ke,m[3]=jt,m[4]=Vt,m[5]=$t,m[6]=Ht,m[7]=Gt,m[8]=Qi,m[9]=en,m[10]=tn,m[11]=rn,m[12]=nn,m[13]=sn,m[14]=on,m[15]=an,m[16]=fn,m[17]=cn,m[18]=hn,_!==0&&(m[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,d=0;d>>26)|0,a+=m>>>26,m&=67108863}w.words[d]=_,p=m,m=a}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(D,l,w){var p=new P;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=O(this,l,w),p};function P(D,l){this.x=D,this.y=l}P.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},P.prototype.permute=function(l,w,p,a,d,m){for(var _=0;_>>1)d++;return 1<>>13,p[2*m+1]=d&8191,d=d>>>13;for(m=2*w;m>=26,w+=a/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,d;if(w!==0){var m=0;for(d=0;d>>26-w}m&&(this.words[d]=m,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var a;w?a=(w-w%26)/26:a=0;var d=l%26,m=Math.min((l-d)/26,this.length),_=67108863^67108863>>>d<m)for(this.length-=m,h=0;h=0&&(x!==0||h>=a);h--){var A=this.words[h]|0;this.words[h]=x<<26-d|A>>>d,x=A&_}return y&&x!==0&&(y.words[y.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(y/67108864|0),this.words[d+p]=m&67108863}for(;d>26,this.words[d+p]=m&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,d=0;d>26,this.words[d]=m&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),d=l,m=d.words[d.length-1]|0,_=this._countBits(m);p=26-_,p!==0&&(d=d.ushln(p),a.iushln(p),m=d.words[d.length-1]|0);var y=a.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=y+1,h.words=new Array(h.length);for(var x=0;x=0;g--){var R=(a.words[d.length+g]|0)*67108864+(a.words[d.length+g-1]|0);for(R=Math.min(R/m|0,67108863),a._ishlnsubmul(d,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(d,1,g),a.isZero()||(a.negative^=1);h&&(h.words[g]=R)}return h&&h.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:h||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,d,m;return this.negative!==0&&l.negative===0?(m=this.neg().divmod(l,w),w!=="mod"&&(a=m.div.neg()),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:a,mod:d}):this.negative===0&&l.negative!==0?(m=this.divmod(l.neg(),w),w!=="mod"&&(a=m.div.neg()),{div:a,mod:m.mod}):this.negative&l.negative?(m=this.neg().divmod(l.neg(),w),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:m.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),d=l.andln(1),m=p.cmp(a);return m<0||d===1&&m===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=new n(0),_=new n(1),y=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++y;for(var h=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(h),d.isub(x)),a.iushrn(1),d.iushrn(1);for(var R=0,k=1;!(p.words[0]&k)&&R<26;++R,k<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(m.isOdd()||_.isOdd())&&(m.iadd(h),_.isub(x)),m.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(m),d.isub(_)):(p.isub(w),m.isub(a),_.isub(d))}return{a:m,b:_,gcd:p.iushln(y)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,y=1;!(w.words[0]&y)&&_<26;++_,y<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(m),a.iushrn(1);for(var h=0,x=1;!(p.words[0]&x)&&h<26;++h,x<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(m),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(d)):(p.isub(w),d.isub(a))}var A;return w.cmpn(1)===0?A=a:A=d,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var m=w;w=p,p=m}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[m]=_}return d!==0&&(this.words[m]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,d=l.words[p]|0;if(a!==d){ad&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new C(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var z={k256:null,p224:null,p192:null,p25519:null};function B(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}B.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},B.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},B.prototype.split=function(l,w){l.iushrn(this.n,0,w)},B.prototype.imulK=function(l){return l.imul(this.k)};function U(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(U,B),U.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),d=0;d>>22,m=_}m>>>=22,l.words[d-10]=m,m===0&&l.length>10?l.length-=10:l.length-=9},U.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(z[l])return z[l];var w;if(l==="k256")w=new U;else if(l==="p224")w=new j;else if(l==="p192")w=new H;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return z[l]=w,w};function C(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}C.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},C.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},C.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},C.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},C.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},C.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},C.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},C.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},C.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},C.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},C.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},C.prototype.isqr=function(l){return this.imul(l,l.clone())},C.prototype.sqr=function(l){return this.mul(l,l)},C.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);t(!a.isZero());var m=new n(1).toRed(this),_=m.redNeg(),y=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,y).cmp(_)!==0;)h.redIAdd(_);for(var x=this.pow(h,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=d;g.cmp(m)!==0;){for(var k=g,E=0;k.cmp(m)!==0;E++)k=k.redSqr();t(E=0;d--){for(var x=w.words[d],A=h-1;A>=0;A--){var g=x>>A&1;if(m!==a[0]&&(m=this.sqr(m)),g===0&&_===0){y=0;continue}_<<=1,_|=g,y++,!(y!==p&&(d!==0||A!==0))&&(m=this.mul(m,a[_]),y=0,_=0)}h=26}return m},C.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},C.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(D){C.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,C),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof su>"u"||su,vg)});var ou=Z(wg=>{"use strict";var hf=wg;function Y8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}hf.toArray=Y8;function mg(r){return r.length===1?"0"+r:r}hf.zero2=mg;function yg(r){for(var e="",t=0;t{"use strict";var dr=_g,X8=Jr(),Z8=Pi(),uf=ou();dr.assert=Z8;dr.toArray=uf.toArray;dr.zero2=uf.zero2;dr.toHex=uf.toHex;dr.encode=uf.encode;function Q8(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-u:f=u,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}dr.getNAF=Q8;function e4(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var u;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?u=-o:u=o):u=0,t[0].push(u);var c;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?c=-f:c=f):c=0,t[1].push(c),2*i===u+1&&(i=1-i),2*n===c+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}dr.getJSF=e4;function t4(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}dr.cachedProperty=t4;function r4(r){return typeof r=="string"?dr.toArray(r,"hex"):r}dr.parseBytes=r4;function i4(r){return new X8(r,"hex","le")}dr.intFromLE=i4});var hu=Z((KR,cu)=>{var au;cu.exports=function(e){return au||(au=new Fi(null)),au.generate(e)};function Fi(r){this.rand=r}cu.exports.Rand=Fi;Fi.prototype.generate=function(e){return this._rand(e)};Fi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var En=Jr(),mo=Bt(),df=mo.getNAF,n4=mo.getJSF,lf=mo.assert;function qi(r,e){this.type=r,this.p=new En(e.p,16),this.red=e.prime?En.red(e.prime):En.mont(this.p),this.zero=new En(0).toRed(this.red),this.one=new En(1).toRed(this.red),this.two=new En(2).toRed(this.red),this.n=e.n&&new En(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}xg.exports=qi;qi.prototype.point=function(){throw new Error("Not implemented")};qi.prototype.validate=function(){throw new Error("Not implemented")};qi.prototype._fixedNafMul=function(e,t){lf(e.precomputed);var i=e._getDoubles(),n=df(t,1,this._bitLength),s=(1<=f;c--)u=(u<<1)+n[c];o.push(u)}for(var b=this.jpoint(null,null,null),v=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;u--){for(var c=0;u>=0&&o[u]===0;u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var b=o[u];lf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};qi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,c=0,b,v,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){u[M]=df(i[M],o[M],this._bitLength),u[T]=df(i[T],o[T],this._bitLength),c=Math.max(u[M].length,c),c=Math.max(u[T].length,c);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],z=n4(i[M],i[T]);for(c=Math.max(z[0].length,c),u[M]=new Array(c),u[T]=new Array(c),v=0;v=0;b--){for(var L=0;b>=0;){var C=!0;for(v=0;v=0&&L++,j=j.dblp(L),b<0)break;for(v=0;v0?S=f[v][W-1>>1]:W<0&&(S=f[v][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Qt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var s4=Bt(),et=Jr(),uu=co(),ps=yo(),o4=s4.assert;function er(r){ps.call(this,"short",r),this.a=new et(r.a,16).toRed(this.red),this.b=new et(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}uu(er,ps);Eg.exports=er;er.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new et(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new et(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],o4(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new et(f.a,16),b:new et(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};er.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:et.mont(e),i=new et(2).toRed(t).redInvm(),n=i.redNeg(),s=new et(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};er.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new et(1),o=new et(0),f=new et(0),u=new et(1),c,b,v,S,I,M,T,O=0,P,z;i.cmpn(0)!==0;){var B=n.div(i);P=n.sub(B.mul(i)),z=f.sub(B.mul(s));var U=u.sub(B.mul(o));if(!v&&P.cmp(t)<0)c=T.neg(),b=s,v=P.neg(),S=z;else if(v&&++O===2)break;T=P,n=i,i=P,f=s,s=z,u=o,o=U}I=P.neg(),M=z;var j=v.sqr().add(S.sqr()),H=I.sqr().add(M.sqr());return H.cmp(j)>=0&&(I=c,M=b),v.negative&&(v=v.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:v,b:S},{a:I,b:M}]};er.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),c=s.mul(i.b),b=o.mul(n.b),v=e.sub(f).sub(u),S=c.add(b).neg();return{k1:v,k2:S}};er.prototype.pointFromX=function(e,t){e=new et(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};er.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};er.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ct.prototype.isInfinity=function(){return this.inf};ct.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ct.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ct.prototype.getX=function(){return this.x.fromRed()};ct.prototype.getY=function(){return this.y.fromRed()};ct.prototype.mul=function(e){return e=new et(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ct.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ct.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ct.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ct.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ct.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function bt(r,e,t,i){ps.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new et(0)):(this.x=new et(e,16),this.y=new et(t,16),this.z=new et(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}uu(bt,ps.BasePoint);er.prototype.jpoint=function(e,t,i){return new bt(this,e,t,i)};bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),c=o.redSub(f);if(u.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=u.redSqr(),v=b.redMul(u),S=n.redMul(b),I=c.redSqr().redIAdd(v).redISub(S).redISub(S),M=c.redMul(S.redISub(I)).redISub(o.redMul(v)),T=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(I,M,T)};bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),b=c.redMul(f),v=i.redMul(c),S=u.redSqr().redIAdd(b).redISub(v).redISub(v),I=u.redMul(v.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};bt.prototype.inspect=function(){return this.isInfinity()?"":""};bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Ag=Z(($R,Mg)=>{"use strict";var gs=Jr(),Ig=co(),pf=yo(),a4=Bt();function bs(r){pf.call(this,"mont",r),this.a=new gs(r.a,16).toRed(this.red),this.b=new gs(r.b,16).toRed(this.red),this.i4=new gs(4).toRed(this.red).redInvm(),this.two=new gs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Ig(bs,pf);Mg.exports=bs;bs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function ht(r,e,t){pf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new gs(e,16),this.z=new gs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Ig(ht,pf.BasePoint);bs.prototype.decodePoint=function(e,t){return this.point(a4.toArray(e,t),1)};bs.prototype.point=function(e,t){return new ht(this,e,t)};bs.prototype.pointFromJSON=function(e){return ht.fromJSON(this,e)};ht.prototype.precompute=function(){};ht.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};ht.fromJSON=function(e,t){return new ht(e,t[0],t[1]||e.one)};ht.prototype.inspect=function(){return this.isInfinity()?"":""};ht.prototype.isInfinity=function(){return this.z.cmpn(0)===0};ht.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};ht.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),u=s.redMul(n),c=t.z.redMul(f.redAdd(u).redSqr()),b=t.x.redMul(f.redISub(u).redSqr());return this.curve.point(c,b)};ht.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};ht.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};ht.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};ht.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Dg=Z((HR,Tg)=>{"use strict";var f4=Bt(),vi=Jr(),Rg=co(),gf=yo(),c4=f4.assert;function Yr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,gf.call(this,"edwards",r),this.a=new vi(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new vi(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new vi(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c4(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Rg(Yr,gf);Tg.exports=Yr;Yr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Yr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Yr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Yr.prototype.pointFromX=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=f.fromRed().isOdd();return(t&&!u||!t&&u)&&(f=f.redNeg()),this.point(e,f)};Yr.prototype.pointFromY=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};Yr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ge(r,e,t,i,n){gf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new vi(e,16),this.y=new vi(t,16),this.z=i?new vi(i,16):this.curve.one,this.t=n&&new vi(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Rg(Ge,gf.BasePoint);Yr.prototype.pointFromJSON=function(e){return Ge.fromJSON(this,e)};Yr.prototype.point=function(e,t,i,n){return new Ge(this,e,t,i,n)};Ge.fromJSON=function(e,t){return new Ge(e,t[0],t[1],t[2])};Ge.prototype.inspect=function(){return this.isInfinity()?"":""};Ge.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ge.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),u=n.redSub(t),c=s.redMul(f),b=o.redMul(u),v=s.redMul(u),S=f.redMul(o);return this.curve.point(c,b,S,v)};Ge.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,u,c;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(u=this.z.redSqr(),c=b.redSub(u).redISub(u),n=e.redSub(t).redISub(i).redMul(c),s=b.redMul(f.redSub(i)),o=b.redMul(c))}else f=t.redAdd(i),u=this.curve._mulC(this.z).redSqr(),c=f.redSub(u).redSub(u),n=this.curve._mulC(e.redISub(f)).redMul(c),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(c);return this.curve.point(n,s,o)};Ge.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ge.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),u=s.redAdd(n),c=i.redAdd(t),b=o.redMul(f),v=u.redMul(c),S=o.redMul(c),I=f.redMul(u);return this.curve.point(b,v,I,S)};Ge.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),u=i.redAdd(o),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(c),v,S;return this.curve.twisted?(v=t.redMul(u).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(u)):(v=t.redMul(u).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(u)),this.curve.point(b,v,S)};Ge.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ge.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ge.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ge.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ge.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ge.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ge.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ge.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ge.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ge.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ge.prototype.toP=Ge.prototype.normalize;Ge.prototype.mixedAdd=Ge.prototype.add});var du=Z(Pg=>{"use strict";var bf=Pg;bf.base=yo();bf.short=Sg();bf.mont=Ag();bf.edwards=Dg()});var Cg=Z((WR,Ng)=>{Ng.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var vf=Z(Fg=>{"use strict";var pu=Fg,Ui=lo(),lu=du(),h4=Bt(),Og=h4.assert;function Lg(r){r.type==="short"?this.curve=new lu.short(r):r.type==="edwards"?this.curve=new lu.edwards(r):this.curve=new lu.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,Og(this.g.validate(),"Invalid curve"),Og(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}pu.PresetCurve=Lg;function zi(r,e){Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,get:function(){var t=new Lg(e);return Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,value:t}),t}})}zi("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ui.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});zi("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ui.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});zi("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ui.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});zi("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ui.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});zi("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ui.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});zi("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ui.sha256,gRed:!1,g:["9"]});zi("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ui.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var gu;try{gu=Cg()}catch{gu=void 0}zi("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ui.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",gu]})});var zg=Z((YR,Ug)=>{"use strict";var u4=lo(),Sn=ou(),qg=Pi();function Bi(r){if(!(this instanceof Bi))return new Bi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Sn.toArray(r.entropy,r.entropyEnc||"hex"),t=Sn.toArray(r.nonce,r.nonceEnc||"hex"),i=Sn.toArray(r.pers,r.persEnc||"hex");qg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}Ug.exports=Bi;Bi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Bi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Sn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var d4=Jr(),l4=Bt(),bu=l4.assert;function St(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}Bg.exports=St;St.fromPublic=function(e,t,i){return t instanceof St?t:new St(e,{pub:t,pubEnc:i})};St.fromPrivate=function(e,t,i){return t instanceof St?t:new St(e,{priv:t,privEnc:i})};St.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};St.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};St.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};St.prototype._importPrivate=function(e,t){this.priv=new d4(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};St.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?bu(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&bu(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};St.prototype.derive=function(e){return e.validate()||bu(e.validate(),"public point not validated"),e.mul(this.priv).getX()};St.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};St.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)};St.prototype.inspect=function(){return""}});var Vg=Z((ZR,jg)=>{"use strict";var mf=Jr(),yu=Bt(),p4=yu.assert;function yf(r,e){if(r instanceof yf)return r;this._importDER(r,e)||(p4(r.r&&r.s,"Signature without r or s"),this.r=new mf(r.r,16),this.s=new mf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}jg.exports=yf;function g4(){this.place=0}function vu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Kg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}yf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Kg(t),i=Kg(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];mu(n,t.length),n=n.concat(t),n.push(2),mu(n,i.length);var s=n.concat(i),o=[48];return mu(o,s.length),o=o.concat(s),yu.encode(o,e)}});var Wg=Z((QR,Gg)=>{"use strict";var mi=Jr(),$g=zg(),b4=Bt(),wu=vf(),v4=hu(),Hg=b4.assert,_u=kg(),wf=Vg();function tr(r){if(!(this instanceof tr))return new tr(r);typeof r=="string"&&(Hg(Object.prototype.hasOwnProperty.call(wu,r),"Unknown curve "+r),r=wu[r]),r instanceof wu.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}Gg.exports=tr;tr.prototype.keyPair=function(e){return new _u(this,e)};tr.prototype.keyFromPrivate=function(e,t){return _u.fromPrivate(this,e,t)};tr.prototype.keyFromPublic=function(e,t){return _u.fromPublic(this,e,t)};tr.prototype.genKeyPair=function(e){e||(e={});for(var t=new $g({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new mi(2));;){var s=new mi(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};tr.prototype._truncateToN=function(e,t,i){var n;if(mi.isBN(e)||typeof e=="number")e=new mi(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new mi(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new mi(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};tr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength);for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new $g({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new mi(1)),b=0;;b++){var v=n.k?n.k(b):new mi(u.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(c)>=0)){var S=this.g.mul(v);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=v.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new wf({r:M,s:T,recoveryParam:O})}}}}}};tr.prototype.verify=function(e,t,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),t=new wf(t,"hex");var o=t.r,f=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),c=u.mul(e).umod(this.n),b=u.mul(o).umod(this.n),v;return this.curve._maxwellTrick?(v=this.g.jmulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.eqXToP(o)):(v=this.g.mulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.getX().umod(this.n).cmp(o)===0)};tr.prototype.recoverPubKey=function(r,e,t,i){Hg((3&t)===t,"The recovery param is more than two bits"),e=new wf(e,i);var n=this.n,s=new mi(r),o=e.r,f=e.s,u=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var b=e.r.invm(n),v=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(v,o,S)};tr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new wf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Zg=Z((eT,Xg)=>{"use strict";var wo=Bt(),Yg=wo.assert,Jg=wo.parseBytes,vs=wo.cachedProperty;function ut(r,e){this.eddsa=r,this._secret=Jg(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Jg(e.pub)}ut.fromPublic=function(e,t){return t instanceof ut?t:new ut(e,{pub:t})};ut.fromSecret=function(e,t){return t instanceof ut?t:new ut(e,{secret:t})};ut.prototype.secret=function(){return this._secret};vs(ut,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});vs(ut,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});vs(ut,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});vs(ut,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});vs(ut,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});vs(ut,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});ut.prototype.sign=function(e){return Yg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};ut.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};ut.prototype.getSecret=function(e){return Yg(this._secret,"KeyPair is public only"),wo.encode(this.secret(),e)};ut.prototype.getPublic=function(e){return wo.encode(this.pubBytes(),e)};Xg.exports=ut});var tb=Z((tT,eb)=>{"use strict";var m4=Jr(),_f=Bt(),Qg=_f.assert,xf=_f.cachedProperty,y4=_f.parseBytes;function In(r,e){this.eddsa=r,typeof e!="object"&&(e=y4(e)),Array.isArray(e)&&(Qg(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Qg(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof m4&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}xf(In,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});xf(In,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});xf(In,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});xf(In,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});In.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};In.prototype.toHex=function(){return _f.encode(this.toBytes(),"hex").toUpperCase()};eb.exports=In});var ob=Z((rT,sb)=>{"use strict";var w4=lo(),_4=vf(),ms=Bt(),x4=ms.assert,ib=ms.parseBytes,nb=Zg(),rb=tb();function Lt(r){if(x4(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Lt))return new Lt(r);r=_4[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=w4.sha512}sb.exports=Lt;Lt.prototype.sign=function(e,t){e=ib(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),u=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})};Lt.prototype.verify=function(e,t,i){if(e=ib(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Lt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Mn=ab;Mn.version=bg().version;Mn.utils=Bt();Mn.rand=hu();Mn.curve=du();Mn.curves=vf();Mn.ec=Wg();Mn.eddsa=ob()});var vv=Z($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isBrowserCryptoAvailable=$i.getSubtleCrypto=$i.getBrowerCrypto=void 0;function Wu(){return window?.crypto||window?.msCrypto||{}}$i.getBrowerCrypto=Wu;function bv(){let r=Wu();return r.subtle||r.webkitSubtle}$i.getSubtleCrypto=bv;function U_(){return!!Wu()&&!!bv()}$i.isBrowserCryptoAvailable=U_});var wv=Z(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.isBrowser=Hi.isNode=Hi.isReactNative=void 0;function mv(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Hi.isReactNative=mv;function yv(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Hi.isNode=yv;function z_(){return!mv()&&!yv()}Hi.isBrowser=z_});var Ju=Z(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});var _v=(zn(),qs(Un));_v.__exportStar(vv(),Lf);_v.__exportStar(wv(),Lf)});var Rv=Z((UT,Av)=>{"use strict";Av.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var dm=Z((qo,Ns)=>{var X_=200,cd="__lodash_hash_undefined__",Jf=1,jv=2,Vv=9007199254740991,Kf="[object Arguments]",rd="[object Array]",Z_="[object AsyncFunction]",$v="[object Boolean]",Hv="[object Date]",Gv="[object Error]",Wv="[object Function]",Q_="[object GeneratorFunction]",jf="[object Map]",Jv="[object Number]",ex="[object Null]",Ps="[object Object]",Nv="[object Promise]",tx="[object Proxy]",Yv="[object RegExp]",Vf="[object Set]",Xv="[object String]",rx="[object Symbol]",ix="[object Undefined]",id="[object WeakMap]",Zv="[object ArrayBuffer]",$f="[object DataView]",nx="[object Float32Array]",sx="[object Float64Array]",ox="[object Int8Array]",ax="[object Int16Array]",fx="[object Int32Array]",cx="[object Uint8Array]",hx="[object Uint8ClampedArray]",ux="[object Uint16Array]",dx="[object Uint32Array]",lx=/[\\^$.*+?()[\]{}|]/g,px=/^\[object .+?Constructor\]$/,gx=/^(?:0|[1-9]\d*)$/,Je={};Je[nx]=Je[sx]=Je[ox]=Je[ax]=Je[fx]=Je[cx]=Je[hx]=Je[ux]=Je[dx]=!0;Je[Kf]=Je[rd]=Je[Zv]=Je[$v]=Je[$f]=Je[Hv]=Je[Gv]=Je[Wv]=Je[jf]=Je[Jv]=Je[Ps]=Je[Yv]=Je[Vf]=Je[Xv]=Je[id]=!1;var Qv=typeof window=="object"&&window&&window.Object===Object&&window,bx=typeof self=="object"&&self&&self.Object===Object&&self,xi=Qv||bx||Function("return this")(),em=typeof qo=="object"&&qo&&!qo.nodeType&&qo,Cv=em&&typeof Ns=="object"&&Ns&&!Ns.nodeType&&Ns,tm=Cv&&Cv.exports===em,Qu=tm&&Qv.process,Ov=function(){try{return Qu&&Qu.binding&&Qu.binding("util")}catch{}}(),Lv=Ov&&Ov.isTypedArray;function vx(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function Gx(r,e){var t=this.__data__,i=Xf(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}Ei.prototype.clear=jx;Ei.prototype.delete=Vx;Ei.prototype.get=$x;Ei.prototype.has=Hx;Ei.prototype.set=Gx;function On(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var c=s.get(r);if(c&&s.get(e))return c==e;var b=-1,v=!0,S=t&jv?new Gf:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=Vv}function hm(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function Bo(r){return r!=null&&typeof r=="object"}var um=Lv?_x(Lv):hE;function SE(r){return xE(r)?oE(r):uE(r)}function IE(){return[]}function ME(){return!1}Ns.exports=EE});var Si=qe(un());var Pl=qe(un()),sa=qe(jn());var sr=class{};var mc=class extends sr{constructor(e){super()}},Dl=sa.FIVE_SECONDS,dn={pulse:"heartbeat_pulse"},na=class r extends mc{constructor(e){super(e),this.events=new Pl.EventEmitter,this.interval=Dl,this.interval=e?.interval||Dl}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,sa.toMiliseconds)(this.interval))}pulse(){this.events.emit(dn.pulse)}};var r2=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,i2=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n2=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function s2(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){o2(r);return}return e}function o2(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Bs(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!n2.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(r2.test(r)||i2.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,s2)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function a2(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ot(r,...e){try{return a2(r(...e))}catch(t){return Promise.reject(t)}}function f2(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function c2(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ks(r){if(f2(r))return String(r);if(c2(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ks(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Nl(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var yc="base64:";function Cl(r){if(typeof r=="string")return r;Nl();let e=Buffer.from(r).toString("base64");return yc+e}function Ol(r){return typeof r!="string"||!r.startsWith(yc)?r:(Nl(),Buffer.from(r.slice(yc.length),"base64"))}function Pt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Ll(...r){return Pt(r.join(":"))}function Ks(r){return r=Pt(r),r?r+":":""}var h2="memory",u2=()=>{let r=new Map;return{name:h2,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Ul(r={}){let e={mounts:{"":r.driver||u2()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(let b of e.mountpoints)if(c.startsWith(b))return{base:b,relativeKey:c.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,b)=>e.mountpoints.filter(v=>v.startsWith(c)||b&&c.startsWith(v)).map(v=>({relativeBase:c.length>v.length?c.slice(v.length):void 0,mountpoint:v,driver:e.mounts[v]})),n=(c,b)=>{if(e.watching){b=Pt(b);for(let v of e.watchListeners)v(c,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let c in e.mounts)e.unwatch[c]=await Fl(e.mounts[c],n,c)}},o=async()=>{if(e.watching){for(let c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},f=(c,b,v)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of c){let T=typeof M=="string",O=Pt(T?M:M.key),P=T?void 0:M.value,z=T||!M.options?b:{...b,...M.options},B=t(O);I(B).items.push({key:O,value:P,relativeKey:B.relativeKey,options:z})}return Promise.all([...S.values()].map(M=>v(M))).then(M=>M.flat())},u={hasItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.hasItem,v,b)},getItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.getItem,v,b).then(I=>Bs(I))},getItems(c,b){return f(c,b,v=>v.driver.getItems?ot(v.driver.getItems,v.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:Ll(v.base,I.key),value:Bs(I.value)}))):Promise.all(v.items.map(S=>ot(v.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Bs(I)})))))},getItemRaw(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return S.getItemRaw?ot(S.getItemRaw,v,b):ot(S.getItem,v,b).then(I=>Ol(I))},async setItem(c,b,v={}){if(b===void 0)return u.removeItem(c);c=Pt(c);let{relativeKey:S,driver:I}=t(c);I.setItem&&(await ot(I.setItem,S,ks(b),v),I.watch||n("update",c))},async setItems(c,b){await f(c,b,async v=>{if(v.driver.setItems)return ot(v.driver.setItems,v.items.map(S=>({key:S.relativeKey,value:ks(S.value),options:S.options})),b);v.driver.setItem&&await Promise.all(v.items.map(S=>ot(v.driver.setItem,S.relativeKey,ks(S.value),S.options)))})},async setItemRaw(c,b,v={}){if(b===void 0)return u.removeItem(c,v);c=Pt(c);let{relativeKey:S,driver:I}=t(c);if(I.setItemRaw)await ot(I.setItemRaw,S,b,v);else if(I.setItem)await ot(I.setItem,S,Cl(b),v);else return;I.watch||n("update",c)},async removeItem(c,b={}){typeof b=="boolean"&&(b={removeMeta:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c);S.removeItem&&(await ot(S.removeItem,v,b),(b.removeMeta||b.removeMata)&&await ot(S.removeItem,v+"$",b),S.watch||n("remove",c))},async getMeta(c,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ot(S.getMeta,v,b)),!b.nativeOnly){let M=await ot(S.getItem,v+"$",b).then(T=>Bs(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(c,b,v={}){return this.setItem(c+"$",b,v)},removeMeta(c,b={}){return this.removeItem(c+"$",b)},async getKeys(c,b={}){c=Ks(c);let v=i(c,!0),S=[],I=[];for(let M of v){let T=await ot(M.driver.getKeys,M.relativeBase,b);for(let O of T){let P=M.mountpoint+Pt(O);S.some(z=>P.startsWith(z))||I.push(P)}S=[M.mountpoint,...S.filter(O=>!O.startsWith(M.mountpoint))]}return c?I.filter(M=>M.startsWith(c)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(c,b={}){c=Ks(c),await Promise.all(i(c,!1).map(async v=>{if(v.driver.clear)return ot(v.driver.clear,v.relativeBase,b);if(v.driver.removeItem){let S=await v.driver.getKeys(v.relativeBase||"",b);return Promise.all(S.map(I=>v.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>ql(c)))},async watch(c){return await s(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,b){if(c=Ks(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((v,S)=>S.length-v.length)),e.mounts[c]=b,e.watching&&Promise.resolve(Fl(b,n,c)).then(v=>{e.unwatch[c]=v}).catch(console.error),u},async unmount(c,b=!0){c=Ks(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&(e.unwatch[c](),delete e.unwatch[c]),b&&await ql(e.mounts[c]),e.mountpoints=e.mountpoints.filter(v=>v!==c),delete e.mounts[c])},getMount(c=""){c=Pt(c)+":";let b=t(c);return{driver:b.driver,base:b.base}},getMounts(c="",b={}){return c=Pt(c),i(c,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(c,b={})=>u.getKeys(c,b),get:(c,b={})=>u.getItem(c,b),set:(c,b,v={})=>u.setItem(c,b,v),has:(c,b={})=>u.hasItem(c,b),del:(c,b={})=>u.removeItem(c,b),remove:(c,b={})=>u.removeItem(c,b)};return u}function Fl(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ql(r){typeof r.dispose=="function"&&await ot(r.dispose)}function ln(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function _c(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=ln(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var wc;function js(){return wc||(wc=_c("keyval-store","keyval")),wc}function xc(r,e=js()){return e("readonly",t=>ln(t.get(r)))}function zl(r,e,t=js()){return t("readwrite",i=>(i.put(e,r),ln(i.transaction)))}function Bl(r,e=js()){return e("readwrite",t=>(t.delete(r),ln(t.transaction)))}function kl(r=js()){return r("readwrite",e=>(e.clear(),ln(e.transaction)))}function d2(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},ln(r.transaction)}function Kl(r=js()){return r("readonly",e=>{if(e.getAllKeys)return ln(e.getAllKeys());let t=[];return d2(e,i=>t.push(i.key)).then(()=>t)})}var l2=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),p2=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Fr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return p2(r)}catch{return r}}function Wt(r){return typeof r=="string"?r:l2(r)||""}var g2="idb-keyval",b2=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=_c(r.dbName,r.storeName)),{name:g2,options:r,async hasItem(n){return!(typeof await xc(t(n),i)>"u")},async getItem(n){return await xc(t(n),i)??null},setItem(n,s){return zl(t(n),s,i)},removeItem(n){return Bl(t(n),i)},getKeys(){return Kl(i)},clear(){return kl(i)}}},v2="WALLET_CONNECT_V2_INDEXED_DB",m2="keyvaluestorage",Sc=class{constructor(){this.indexedDb=Ul({driver:b2({dbName:v2,storeName:m2})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Wt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},Ec=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},oa={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ec<"u"&&Ec.localStorage?oa.exports=Ec.localStorage:typeof window<"u"&&window.localStorage?oa.exports=window.localStorage:oa.exports=new e})();function y2(r){var e;return[r[0],Fr((e=r[1])!=null?e:"")]}var Ic=class{constructor(){this.localStorage=oa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(y2)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Fr(t)}async setItem(e,t){this.localStorage.setItem(e,Wt(t))}async removeItem(e){this.localStorage.removeItem(e)}},w2="wc_storage_version",jl=1,_2=async(r,e,t)=>{let i=w2,n=await e.getItem(i);if(n&&n>=jl){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let u=f.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){let c=await r.getItem(f);await e.setItem(f,c),o.push(f)}}await e.setItem(i,jl),t(e),x2(r,o)},x2=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},aa=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new Ic;this.storage=e;try{let t=new Sc;_2(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var ai=qe(Rc()),Hs=qe(Rc());var L2={level:"info"},Gs="custom_context",Nc=1e3*1024,Tc=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ha=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Tc(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},ua=class{constructor(e,t=Nc){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===ai.levels.values.error?console.error(e):t===ai.levels.values.warn?console.warn(e):t===ai.levels.values.debug?console.debug(e):t===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Wt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Wt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Dc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Pc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},F2=Object.defineProperty,q2=Object.defineProperties,U2=Object.getOwnPropertyDescriptors,Yl=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,B2=Object.prototype.propertyIsEnumerable,Xl=(r,e,t)=>e in r?F2(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e)=>{for(var t in e||(e={}))z2.call(e,t)&&Xl(r,t,e[t]);if(Yl)for(var t of Yl(e))B2.call(e,t)&&Xl(r,t,e[t]);return r},la=(r,e)=>q2(r,U2(e));function Ws(r){return la(da({},r),{level:r?.level||L2.level})}function k2(r,e=Gs){return r[e]||""}function K2(r,e,t=Gs){return r[t]=e,r}function yt(r,e=Gs){let t="";return typeof r.bindings>"u"?t=k2(r,e):t=r.bindings().context||"",t}function j2(r,e,t=Gs){let i=yt(r,t);return i.trim()?`${i}/${e}`:e}function lt(r,e,t=Gs){let i=j2(r,e,t),n=r.child({context:i});return K2(n,i,t)}function V2(r){var e,t;let i=new Dc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace",browser:la(da({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function $2(r){var e;let t=new Pc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Zl(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?V2(r):$2(r)}var Ql=qe(un()),pa=class extends sr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var ga=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},ba=class{constructor(e,t){this.logger=e,this.core=t}},va=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}},ma=class extends sr{constructor(e){super()}},ya=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var wa=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}};var _a=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t}};var xa=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Ea=class{constructor(e,t){this.projectId=e,this.logger=t}},Sa=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Ia=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Ma=class{constructor(e){this.client=e}};var re=qe(jn());var so=qe(T0()),op=qe(Js()),ap=qe(jn());var D0="EdDSA",P0="JWT",Zs=".",Qs="base64url",Xc="utf8",Zc="utf8",N0=":",C0="did",O0="key",Qc="base58btc",L0="z",F0="K36";function eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function vn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var nh={};Dt(nh,{identity:()=>$3});function B3(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(B);P!==z;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var k3=B3,K3=k3,q0=K3;var FI=new Uint8Array(0);var U0=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var z0=r=>new TextEncoder().encode(r),B0=r=>new TextDecoder().decode(r);var eh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},th=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K0(this,e)}},rh=class{constructor(e){this.decoders=e}or(e){return K0(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},K0=(r,e)=>new rh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ih=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,t,i),this.decoder=new th(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Yn=({name:r,prefix:e,encode:t,decode:i})=>new ih(r,e,t,i),Ti=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=q0(t,e);return Yn({prefix:r,name:e,encode:i,decode:s=>ci(n(s))})},j3=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[c++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},V3=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Yn({prefix:e,name:r,encode(n){return V3(n,i,t)},decode(n){return j3(n,i,t,r)}});var $3=Yn({prefix:"\0",name:"identity",encode:r=>B0(r),decode:r=>z0(r)});var sh={};Dt(sh,{base2:()=>H3});var H3=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oh={};Dt(oh,{base8:()=>G3});var G3=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah={};Dt(ah,{base10:()=>W3});var W3=Ti({prefix:"9",name:"base10",alphabet:"0123456789"});var fh={};Dt(fh,{base16:()=>J3,base16upper:()=>Y3});var J3=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y3=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ch={};Dt(ch,{base32:()=>Xn,base32hex:()=>e6,base32hexpad:()=>r6,base32hexpadupper:()=>i6,base32hexupper:()=>t6,base32pad:()=>Z3,base32padupper:()=>Q3,base32upper:()=>X3,base32z:()=>n6});var Xn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X3=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z3=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q3=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hh={};Dt(hh,{base36:()=>s6,base36upper:()=>o6});var s6=Ti({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o6=Ti({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uh={};Dt(uh,{base58btc:()=>Ur,base58flickr:()=>a6});var Ur=Ti({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),a6=Ti({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh={};Dt(dh,{base64:()=>f6,base64pad:()=>c6,base64url:()=>h6,base64urlpad:()=>u6});var f6=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),u6=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lh={};Dt(lh,{base256emoji:()=>b6});var j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),d6=j0.reduce((r,e,t)=>(r[t]=e,r),[]),l6=j0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function p6(r){return r.reduce((e,t)=>(e+=d6[t],e),"")}function g6(r){let e=[];for(let t of r){let i=l6[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var b6=Yn({prefix:"\u{1F680}",name:"base256emoji",encode:p6,decode:g6});var vh={};Dt(vh,{sha256:()=>L6,sha512:()=>F6});var v6=H0,V0=128,m6=127,y6=~m6,w6=Math.pow(2,31);function H0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=w6;)e[t++]=r&255|V0,r/=128;for(;r&y6;)e[t++]=r&255|V0,r>>>=7;return e[t]=r|0,H0.bytes=t-i+1,e}var _6=ph,x6=128,$0=127;function ph(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw ph.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&$0)<=x6);return ph.bytes=s-i,t}var E6=Math.pow(2,7),S6=Math.pow(2,14),I6=Math.pow(2,21),M6=Math.pow(2,28),A6=Math.pow(2,35),R6=Math.pow(2,42),T6=Math.pow(2,49),D6=Math.pow(2,56),P6=Math.pow(2,63),N6=function(r){return r[to.decode(r,e),to.decode.bytes],Zn=(r,e,t=0)=>(to.encode(r,e,t),e),Qn=r=>to.encodingLength(r);var mn=(r,e)=>{let t=e.byteLength,i=Qn(r),n=i+Qn(t),s=new Uint8Array(n+t);return Zn(r,s,0),Zn(t,s,i),s.set(e,n),new es(r,t,e,s)},G0=r=>{let e=ci(r),[t,i]=ro(e),[n,s]=ro(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new es(t,n,o,e)},W0=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&U0(r.bytes,e.bytes),es=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var bh=({name:r,code:e,encode:t})=>new gh(r,e,t),gh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?mn(this.code,t):t.then(i=>mn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var Y0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),L6=bh({name:"sha2-256",code:18,encode:Y0("SHA-256")}),F6=bh({name:"sha2-512",code:19,encode:Y0("SHA-512")});var mh={};Dt(mh,{identity:()=>z6});var X0=0,q6="identity",Z0=ci,U6=r=>mn(X0,Z0(r)),z6={code:X0,name:q6,encode:Z0,digest:U6};var iM=new TextEncoder,nM=new TextDecoder;var La=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oa,byteLength:Oa,code:Ca,version:Ca,multihash:Ca,bytes:Ca,_baseCache:Oa,asCID:Oa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==no)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=mn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&W0(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return j6(t,n,e||Ur.encoder);default:return V6(t,n,e||Xn.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return G6(/^0\.0/,W6),!!(e&&(e[ep]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||Q0(t,i,n.bytes))}else if(e!=null&&e[ep]===!0){let{version:t,multihash:i,code:n}=e,s=G0(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==no)throw new Error(`Version 0 CID must use dag-pb (code: ${no}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Q0(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,no,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=ci(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new es(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[v,S]=ro(e.subarray(t));return t+=S,v},n=i(),s=no;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),u=i(),c=t+u,b=c-o;return{version:n,codec:s,multihashCode:f,digestSize:u,multihashSize:b,size:c}}static parse(e,t){let[i,n]=K6(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},K6=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ur;return[Ur.prefix,t.decode(`${Ur.prefix}${r}`)]}case Ur.prefix:{let t=e||Ur;return[Ur.prefix,t.decode(r)]}case Xn.prefix:{let t=e||Xn;return[Xn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},j6=(r,e,t)=>{let{prefix:i}=t;if(i!==Ur.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},V6=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},no=112,$6=18,Q0=(r,e,t)=>{let i=Qn(r),n=i+Qn(e),s=new Uint8Array(n+t.byteLength);return Zn(r,s,0),Zn(e,s,i),s.set(t,n),s},ep=Symbol.for("@ipld/js-cid/CID"),Ca={writable:!1,configurable:!1,enumerable:!0},Oa={writable:!1,enumerable:!1,configurable:!1},H6="0.0.0-dev",G6=(r,e)=>{if(r.test(H6))console.warn(e);else throw new Error(e)},W6=`CID.isCID(v) is deprecated and will be removed in the next major release. +var _y=Object.create;var Jo=Object.defineProperty;var xy=Object.getOwnPropertyDescriptor;var Ey=Object.getOwnPropertyNames;var Sy=Object.getPrototypeOf,Iy=Object.prototype.hasOwnProperty;var al=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var My=(r,e)=>()=>(r&&(e=r(r=0)),e);var Z=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Dt=(r,e)=>{for(var t in e)Jo(r,t,{get:e[t],enumerable:!0})},Wo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ey(e))!Iy.call(r,n)&&n!==t&&Jo(r,n,{get:()=>e[n],enumerable:!(i=xy(e,n))||i.enumerable});return r},qt=(r,e,t)=>(Wo(r,e,"default"),t&&Wo(t,e,"default")),qe=(r,e,t)=>(t=r!=null?_y(Sy(r)):{},Wo(e||!r||!r.__esModule?Jo(t,"default",{value:r,enumerable:!0}):t,r)),qs=r=>Wo(Jo({},"__esModule",{value:!0}),r);var un=Z((BS,uc)=>{"use strict";var qn=typeof Reflect=="object"?Reflect:null,fl=qn&&typeof qn.apply=="function"?qn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Yo;qn&&typeof qn.ownKeys=="function"?Yo=qn.ownKeys:Object.getOwnPropertySymbols?Yo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yo=function(e){return Object.getOwnPropertyNames(e)};function Ay(r){console&&console.warn&&console.warn(r)}var hl=Number.isNaN||function(e){return e!==e};function Ke(){Ke.init.call(this)}uc.exports=Ke;uc.exports.once=Py;Ke.EventEmitter=Ke;Ke.prototype._events=void 0;Ke.prototype._eventsCount=0;Ke.prototype._maxListeners=void 0;var cl=10;function Xo(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ke,"defaultMaxListeners",{enumerable:!0,get:function(){return cl},set:function(r){if(typeof r!="number"||r<0||hl(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");cl=r}});Ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ke.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||hl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ul(r){return r._maxListeners===void 0?Ke.defaultMaxListeners:r._maxListeners}Ke.prototype.getMaxListeners=function(){return ul(this)};Ke.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var u=s[e];if(u===void 0)return!1;if(typeof u=="function")fl(u,this,t);else for(var c=u.length,b=bl(u,c),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,Ay(f)}return r}Ke.prototype.addListener=function(e,t){return dl(this,e,t,!1)};Ke.prototype.on=Ke.prototype.addListener;Ke.prototype.prependListener=function(e,t){return dl(this,e,t,!0)};function Ry(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ll(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=Ry.bind(i);return n.listener=t,i.wrapFn=n,n}Ke.prototype.once=function(e,t){return Xo(t),this.on(e,ll(this,e,t)),this};Ke.prototype.prependOnceListener=function(e,t){return Xo(t),this.prependListener(e,ll(this,e,t)),this};Ke.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Xo(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Ty(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ke.prototype.off=Ke.prototype.removeListener;Ke.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function pl(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?Dy(n):bl(n,n.length)}Ke.prototype.listeners=function(e){return pl(this,e,!0)};Ke.prototype.rawListeners=function(e){return pl(this,e,!1)};Ke.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):gl.call(r,e)};Ke.prototype.listenerCount=gl;function gl(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ke.prototype.eventNames=function(){return this._eventsCount>0?Yo(this._events):[]};function bl(r,e){for(var t=new Array(e),i=0;ilc,__asyncDelegator:()=>$y,__asyncGenerator:()=>Vy,__asyncValues:()=>Hy,__await:()=>Us,__awaiter:()=>Uy,__classPrivateFieldGet:()=>Yy,__classPrivateFieldSet:()=>Xy,__createBinding:()=>By,__decorate:()=>Ly,__exportStar:()=>ky,__extends:()=>Cy,__generator:()=>zy,__importDefault:()=>Jy,__importStar:()=>Wy,__makeTemplateObject:()=>Gy,__metadata:()=>qy,__param:()=>Fy,__read:()=>ml,__rest:()=>Oy,__spread:()=>Ky,__spreadArrays:()=>jy,__values:()=>pc});function Cy(r,e){dc(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Fy(r,e){return function(t,i){e(t,i,r)}}function qy(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Uy(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{c(i.next(b))}catch(v){o(v)}}function u(b){try{c(i.throw(b))}catch(v){o(v)}}function c(b){b.done?s(b.value):n(b.value).then(f,u)}c((i=i.apply(r,e||[])).next())})}function zy(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(c){return function(b){return u([c,b])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=c[0]&2?n.return:c[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,c[1])).done)return s;switch(n=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,n=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ml(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Ky(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{u(i[S](I))}catch(M){v(s[0][3],M)}}function u(S){S.value instanceof Us?Promise.resolve(S.value.v).then(c,b):v(s[0][2],S)}function c(S){f("next",S)}function b(S){f("throw",S)}function v(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function $y(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Us(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function Hy(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof pc=="function"?pc(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(c){s({value:c,done:f})},o)}}function Gy(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wy(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function Jy(r){return r&&r.__esModule?r:{default:r}}function Yy(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Xy(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var dc,lc,zn=My(()=>{dc=function(r,e){return dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},dc(r,e)};lc=function(){return lc=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.delay=void 0;function Zy(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Zo.delay=Zy});var wl=Z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.ONE_THOUSAND=Bn.ONE_HUNDRED=void 0;Bn.ONE_HUNDRED=100;Bn.ONE_THOUSAND=1e3});var _l=Z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.ONE_YEAR=Q.FOUR_WEEKS=Q.THREE_WEEKS=Q.TWO_WEEKS=Q.ONE_WEEK=Q.THIRTY_DAYS=Q.SEVEN_DAYS=Q.FIVE_DAYS=Q.THREE_DAYS=Q.ONE_DAY=Q.TWENTY_FOUR_HOURS=Q.TWELVE_HOURS=Q.SIX_HOURS=Q.THREE_HOURS=Q.ONE_HOUR=Q.SIXTY_MINUTES=Q.THIRTY_MINUTES=Q.TEN_MINUTES=Q.FIVE_MINUTES=Q.ONE_MINUTE=Q.SIXTY_SECONDS=Q.THIRTY_SECONDS=Q.TEN_SECONDS=Q.FIVE_SECONDS=Q.ONE_SECOND=void 0;Q.ONE_SECOND=1;Q.FIVE_SECONDS=5;Q.TEN_SECONDS=10;Q.THIRTY_SECONDS=30;Q.SIXTY_SECONDS=60;Q.ONE_MINUTE=Q.SIXTY_SECONDS;Q.FIVE_MINUTES=Q.ONE_MINUTE*5;Q.TEN_MINUTES=Q.ONE_MINUTE*10;Q.THIRTY_MINUTES=Q.ONE_MINUTE*30;Q.SIXTY_MINUTES=Q.ONE_MINUTE*60;Q.ONE_HOUR=Q.SIXTY_MINUTES;Q.THREE_HOURS=Q.ONE_HOUR*3;Q.SIX_HOURS=Q.ONE_HOUR*6;Q.TWELVE_HOURS=Q.ONE_HOUR*12;Q.TWENTY_FOUR_HOURS=Q.ONE_HOUR*24;Q.ONE_DAY=Q.TWENTY_FOUR_HOURS;Q.THREE_DAYS=Q.ONE_DAY*3;Q.FIVE_DAYS=Q.ONE_DAY*5;Q.SEVEN_DAYS=Q.ONE_DAY*7;Q.THIRTY_DAYS=Q.ONE_DAY*30;Q.ONE_WEEK=Q.SEVEN_DAYS;Q.TWO_WEEKS=Q.ONE_WEEK*2;Q.THREE_WEEKS=Q.ONE_WEEK*3;Q.FOUR_WEEKS=Q.ONE_WEEK*4;Q.ONE_YEAR=Q.ONE_DAY*365});var gc=Z(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});var xl=(zn(),qs(Un));xl.__exportStar(wl(),Qo);xl.__exportStar(_l(),Qo)});var Sl=Z(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.fromMiliseconds=kn.toMiliseconds=void 0;var El=gc();function Qy(r){return r*El.ONE_THOUSAND}kn.toMiliseconds=Qy;function e2(r){return Math.floor(r/El.ONE_THOUSAND)}kn.fromMiliseconds=e2});var Ml=Z(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var Il=(zn(),qs(Un));Il.__exportStar(yl(),ea);Il.__exportStar(Sl(),ea)});var Al=Z(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.Watch=void 0;var ta=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};zs.Watch=ta;zs.default=ta});var Rl=Z(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.IWatch=void 0;var bc=class{};ra.IWatch=bc});var Tl=Z(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var t2=(zn(),qs(Un));t2.__exportStar(Rl(),vc)});var jn=Z(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var ia=(zn(),qs(Un));ia.__exportStar(Ml(),Kn);ia.__exportStar(Al(),Kn);ia.__exportStar(Tl(),Kn);ia.__exportStar(gc(),Kn)});var $l=Z((lI,Vl)=>{"use strict";function E2(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}Vl.exports=S2;function S2(r,e,t){var i=t&&t.stringify||E2,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?v:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=u||e[b]==null)break;v=u||e[b]==null)break;v=u||e[b]===void 0)break;v",v=I+2,I++;break}c+=i(e[b]),v=I+2,I++;break;case 115:if(b>=u)break;v{"use strict";var Hl=$l();Jl.exports=qr;var Vs=O2().console||{},I2={mapHttpRequest:fa,mapHttpResponse:fa,wrapRequestSerializer:Mc,wrapResponseSerializer:Mc,wrapErrorSerializer:Mc,req:fa,res:fa,err:D2};function M2(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function qr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||Vs;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=M2(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",u=Object.create(t);u.log||(u.log=$s),Object.defineProperty(u,"levelVal",{get:b}),Object.defineProperty(u,"level",{get:v,set:S});let c={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:P2(r)};u.levels=qr.levels,u.level=f,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=$s,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=I,e&&(u._logEvent=Ac());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function v(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,Vn(c,u,"error","log"),Vn(c,u,"fatal","error"),Vn(c,u,"warn","error"),Vn(c,u,"info","log"),Vn(c,u,"debug","log"),Vn(c,u,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let O=T.serializers;if(n&&O){var P=Object.assign({},i,O),z=r.browser.serialize===!0?Object.keys(P):n;delete M.serializers,ca([M],z,P,this._stdErrSerialize)}function B(U){this._childLevel=(U._childLevel|0)+1,this.error=$n(U,M,"error"),this.fatal=$n(U,M,"fatal"),this.warn=$n(U,M,"warn"),this.info=$n(U,M,"info"),this.debug=$n(U,M,"debug"),this.trace=$n(U,M,"trace"),P&&(this.serializers=P,this._serialize=z),e&&(this._logEvent=Ac([].concat(U._logEvent.bindings,M)))}return B.prototype=this,new B(this)}return u}qr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};qr.stdSerializers=I2;qr.stdTimeFunctions=Object.assign({},{nullTime:Gl,epochTime:Wl,unixTime:N2,isoTime:C2});function Vn(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?$s:n[t]?n[t]:Vs[t]||Vs[i]||$s,A2(r,e,t)}function A2(r,e,t){!r.transmit&&e[t]===$s||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Vs?Vs:this;for(var u=0;u-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function $n(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.BrowserRandomSource=void 0;var e0=65536,Cc=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function H2(r){for(var e=0;e{});var r0=Z(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.NodeRandomSource=void 0;var G2=Jt(),Fc=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof al<"u"){let e=Lc();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.SystemRandomSource=void 0;var W2=t0(),J2=r0(),qc=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new W2.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new J2.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Ta.SystemRandomSource=qc});var n0=Z(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Y2(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Ut.mul=Math.imul||Y2;function X2(r,e){return r+e|0}Ut.add=X2;function Z2(r,e){return r-e|0}Ut.sub=Z2;function Q2(r,e){return r<>>32-e}Ut.rotl=Q2;function e3(r,e){return r<<32-e|r>>>e}Ut.rotr=e3;function t3(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Ut.isInteger=Number.isInteger||t3;Ut.MAX_SAFE_INTEGER=9007199254740991;Ut.isSafeInteger=function(r){return Ut.isInteger(r)&&r>=-Ut.MAX_SAFE_INTEGER&&r<=Ut.MAX_SAFE_INTEGER}});var Hn=Z(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var s0=n0();function r3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Le.readInt16BE=r3;function i3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Le.readUint16BE=i3;function n3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Le.readInt16LE=n3;function s3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Le.readUint16LE=s3;function o0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Le.writeUint16BE=o0;Le.writeInt16BE=o0;function a0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Le.writeUint16LE=a0;Le.writeInt16LE=a0;function Uc(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Le.readInt32BE=Uc;function zc(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Le.readUint32BE=zc;function Bc(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Le.readInt32LE=Bc;function kc(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Le.readUint32LE=kc;function Da(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Le.writeUint32BE=Da;Le.writeInt32BE=Da;function Pa(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Le.writeUint32LE=Pa;Le.writeInt32LE=Pa;function o3(r,e){e===void 0&&(e=0);var t=Uc(r,e),i=Uc(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Le.readInt64BE=o3;function a3(r,e){e===void 0&&(e=0);var t=zc(r,e),i=zc(r,e+4);return t*4294967296+i}Le.readUint64BE=a3;function f3(r,e){e===void 0&&(e=0);var t=Bc(r,e),i=Bc(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Le.readInt64LE=f3;function c3(r,e){e===void 0&&(e=0);var t=kc(r,e),i=kc(r,e+4);return i*4294967296+t}Le.readUint64LE=c3;function f0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Da(r/4294967296>>>0,e,t),Da(r>>>0,e,t+4),e}Le.writeUint64BE=f0;Le.writeInt64BE=f0;function c0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Pa(r>>>0,e,t),Pa(r/4294967296>>>0,e,t+4),e}Le.writeUint64LE=c0;Le.writeInt64LE=c0;function h3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Le.readUintBE=h3;function u3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Le.writeUintBE=d3;function l3(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!s0.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.randomStringForEntropy=wt.randomString=wt.randomUint32=wt.randomBytes=wt.defaultRandomSource=void 0;var x3=i0(),E3=Hn(),h0=Jt();wt.defaultRandomSource=new x3.SystemRandomSource;function Kc(r,e=wt.defaultRandomSource){return e.randomBytes(r)}wt.randomBytes=Kc;function S3(r=wt.defaultRandomSource){let e=Kc(4,r),t=(0,E3.readUint32LE)(e);return(0,h0.wipe)(e),t}wt.randomUint32=S3;var u0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function d0(r,e=u0,t=wt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Kc(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let u=o[f];u{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});var Wn=Hn(),Gn=Jt();fi.DIGEST_LENGTH=64;fi.BLOCK_SIZE=128;var p0=function(){function r(){this.digestLength=fi.DIGEST_LENGTH,this.blockSize=fi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Gn.wipe(this._buffer),Gn.wipe(this._tempHi),Gn.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Gn.wipe(e.stateHi),Gn.wipe(e.stateLo),e.buffer&&Gn.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();fi.SHA512=p0;var l0=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function jc(r,e,t,i,n,s,o){for(var f=t[0],u=t[1],c=t[2],b=t[3],v=t[4],S=t[5],I=t[6],M=t[7],T=i[0],O=i[1],P=i[2],z=i[3],B=i[4],U=i[5],j=i[6],H=i[7],L,C,W,D,l,w,p,a;o>=128;){for(var d=0;d<16;d++){var m=8*d+s;r[d]=Wn.readUint32BE(n,m),e[d]=Wn.readUint32BE(n,m+4)}for(var d=0;d<80;d++){var _=f,y=u,h=c,x=b,A=v,g=S,R=I,k=M,E=T,N=O,F=P,q=z,K=B,J=U,$=j,V=H;if(L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(v>>>14|B<<18)^(v>>>18|B<<14)^(B>>>9|v<<23),C=(B>>>14|v<<18)^(B>>>18|v<<14)^(v>>>9|B<<23),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=v&S^~v&I,C=B&U^~B&j,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=l0[d*2],C=l0[d*2+1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=r[d%16],C=e[d%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,W=p&65535|a<<16,D=l&65535|w<<16,L=W,C=D,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),C=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=f&u^f&c^u&c,C=T&O^T&P^O&P,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,k=p&65535|a<<16,V=l&65535|w<<16,L=x,C=q,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=W,C=D,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,q=l&65535|w<<16,u=_,c=y,b=h,v=x,S=A,I=g,M=R,f=k,O=E,P=N,z=F,B=q,U=K,j=J,H=$,T=V,d%16===15)for(var m=0;m<16;m++)L=r[m],C=e[m],l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=r[(m+9)%16],C=e[(m+9)%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+1)%16],D=e[(m+1)%16],L=(W>>>1|D<<31)^(W>>>8|D<<24)^W>>>7,C=(D>>>1|W<<31)^(D>>>8|W<<24)^(D>>>7|W<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+14)%16],D=e[(m+14)%16],L=(W>>>19|D<<13)^(D>>>29|W<<3)^W>>>6,C=(D>>>19|W<<13)^(W>>>29|D<<3)^(D>>>6|W<<26),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[m]=p&65535|a<<16,e[m]=l&65535|w<<16}L=f,C=T,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[0],C=i[0],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=u,C=O,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[1],C=i[1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=u=p&65535|a<<16,i[1]=O=l&65535|w<<16,L=c,C=P,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[2],C=i[2],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=c=p&65535|a<<16,i[2]=P=l&65535|w<<16,L=b,C=z,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[3],C=i[3],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=z=l&65535|w<<16,L=v,C=B,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[4],C=i[4],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=v=p&65535|a<<16,i[4]=B=l&65535|w<<16,L=S,C=U,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[5],C=i[5],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=U=l&65535|w<<16,L=I,C=j,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[6],C=i[6],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=j=l&65535|w<<16,L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[7],C=i[7],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=H=l&65535|w<<16,s+=128,o-=128}return s}function M3(r){var e=new p0;e.update(r);var t=e.digest();return e.clean(),t}fi.hash=M3});var T0=Z(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var A3=Js(),Ys=g0(),w0=Jt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function te(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,_0(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function x0(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function m0(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Xs(t,r),Xs(i,e),x0(t,i)}function E0(r){let e=new Uint8Array(32);return Xs(e,r),e[0]&1}function N3(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function pn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function bn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function je(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function gn(r,e){je(r,e,e)}function S0(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)gn(t,t),i!==2&&i!==4&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function C3(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)gn(t,t),i!==1&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Gc(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te(),c=te(),b=te();bn(t,r[1],r[0]),bn(b,e[1],e[0]),je(t,t,b),pn(i,r[0],r[1]),pn(b,e[0],e[1]),je(i,i,b),je(n,r[3],e[3]),je(n,n,D3),je(s,r[2],e[2]),pn(s,s,s),bn(o,i,t),bn(f,s,n),pn(u,s,n),pn(c,i,t),je(r[0],o,f),je(r[1],c,u),je(r[2],u,f),je(r[3],o,c)}function y0(r,e,t){for(let i=0;i<4;i++)_0(r[i],e[i],t)}function Jc(r,e){let t=te(),i=te(),n=te();S0(n,e[2]),je(t,e[0],n),je(i,e[1],n),Xs(r,i),r[31]^=E0(t)<<7}function I0(r,e,t){Ri(r[0],Hc),Ri(r[1],Jn),Ri(r[2],Jn),Ri(r[3],Hc);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;y0(r,e,n),Gc(e,r),Gc(r,r),y0(r,e,n)}}function Yc(r,e){let t=[te(),te(),te(),te()];Ri(t[0],b0),Ri(t[1],v0),Ri(t[2],Jn),je(t[3],b0,v0),I0(r,t,e)}function M0(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ys.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[te(),te(),te(),te()];Yc(i,e),Jc(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=M0;function O3(r){let e=(0,A3.randomBytes)(32,r),t=M0(e);return(0,w0.wipe)(e),t}ze.generateKeyPair=O3;function L3(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=L3;var $c=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function A0(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*$c[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*$c[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Wc(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;A0(r,e)}function F3(r,e){let t=new Float64Array(64),i=[te(),te(),te(),te()],n=(0,Ys.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ys.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Wc(f),Yc(i,f),Jc(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let u=o.digest();Wc(u);for(let c=0;c<32;c++)t[c]=f[c];for(let c=0;c<32;c++)for(let b=0;b<32;b++)t[c+b]+=u[c]*n[b];return A0(s.subarray(32),t),s}ze.sign=F3;function R0(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te();return Ri(r[2],Jn),N3(r[1],e),gn(n,r[1]),je(s,n,T3),bn(n,n,r[2]),pn(s,r[2],s),gn(o,s),gn(f,o),je(u,f,o),je(t,u,n),je(t,t,s),C3(t,t),je(t,t,n),je(t,t,s),je(t,t,s),je(r[0],t,s),gn(i,r[0]),je(i,i,s),m0(i,n)&&je(r[0],r[0],P3),gn(i,r[0]),je(i,i,s),m0(i,n)?-1:(E0(r[0])===e[31]>>7&&bn(r[0],Hc,r[0]),je(r[3],r[0],r[1]),0)}function q3(r,e,t){let i=new Uint8Array(32),n=[te(),te(),te(),te()],s=[te(),te(),te(),te()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(R0(s,r))return!1;let o=new Ys.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Wc(f),I0(n,s,f),Yc(s,t.subarray(32)),Gc(n,s),Jc(i,n),!x0(t,i)}ze.verify=q3;function U3(r){let e=[te(),te(),te(),te()];if(R0(e,r))throw new Error("Ed25519: invalid public key");let t=te(),i=te(),n=e[1];pn(t,Jn,n),bn(i,Jn,n),S0(i,i),je(t,t,i);let s=new Uint8Array(32);return Xs(s,t),s}ze.convertPublicKeyToX25519=U3;function z3(r){let e=(0,Ys.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,w0.wipe)(e),t}ze.convertSecretKeyToX25519=z3});var za=Z(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.getLocalStorage=He.getLocalStorageOrThrow=He.getCrypto=He.getCryptoOrThrow=He.getLocation=He.getLocationOrThrow=He.getNavigator=He.getNavigatorOrThrow=He.getDocument=He.getDocumentOrThrow=He.getFromWindowOrThrow=He.getFromWindow=void 0;function yn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}He.getFromWindow=yn;function rs(r){let e=yn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}He.getFromWindowOrThrow=rs;function dw(){return rs("document")}He.getDocumentOrThrow=dw;function lw(){return yn("document")}He.getDocument=lw;function pw(){return rs("navigator")}He.getNavigatorOrThrow=pw;function gw(){return yn("navigator")}He.getNavigator=gw;function bw(){return rs("location")}He.getLocationOrThrow=bw;function vw(){return yn("location")}He.getLocation=vw;function mw(){return rs("crypto")}He.getCryptoOrThrow=mw;function yw(){return yn("crypto")}He.getCrypto=yw;function ww(){return rs("localStorage")}He.getLocalStorageOrThrow=ww;function _w(){return yn("localStorage")}He.getLocalStorage=_w});var gp=Z(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.getWindowMetadata=void 0;var pp=za();function xw(){let r,e;try{r=pp.getDocumentOrThrow(),e=pp.getLocationOrThrow()}catch{return null}function t(){let v=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=M.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let P=e.protocol+"//"+e.host;if(O.indexOf("/")===0)P+=O;else{let z=e.pathname.split("/");z.pop();let B=z.join("/");P+=B+"/"+O}S.push(P)}else if(O.indexOf("//")===0){let P=e.protocol+O;S.push(P)}else S.push(O)}}return S}function i(...v){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(O)).filter(O=>O?v.includes(O):!1);if(T.length&&T){let O=M.getAttribute("content");if(O)return O}}return""}function n(){let v=i("name","og:site_name","og:title","twitter:title");return v||(v=r.title),v}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),u=e.origin,c=t();return{description:f,url:u,icons:c,name:o}}Ba.getWindowMetadata=xw});var vp=Z((zM,bp)=>{"use strict";bp.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var xp=Z((BM,_p)=>{"use strict";var wp="%[a-f0-9]{2}",mp=new RegExp("("+wp+")|([^%]+?)","gi"),yp=new RegExp("("+wp+")+","gi");function xh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],xh(t),xh(i))}function Ew(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(mp)||[],t=1;t{"use strict";Ep.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Mp=Z((KM,Ip)=>{"use strict";Ip.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Iw=vp(),Mw=xp(),Rp=Sp(),Aw=Mp(),Rw=r=>r==null,Eh=Symbol("encodeFragmentIdentifier");function Tw(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[",n,"]"].join("")]:[...t,[it(e,r),"[",it(n,r),"]=",it(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[]"].join("")]:[...t,[it(e,r),"[]=",it(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),":list="].join("")]:[...t,[it(e,r),":list=",it(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[it(t,r),e,it(n,r)].join("")]:[[i,it(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,it(e,r)]:[...t,[it(e,r),"=",it(i,r)].join("")]}}function Dw(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&hi(i,r).includes(r.arrayFormatSeparator);i=o?hi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(u=>hi(u,r)):i===null?i:hi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&hi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>hi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Tp(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function it(r,e){return e.encode?e.strict?Iw(r):encodeURIComponent(r):r}function hi(r,e){return e.decode?Mw(r):r}function Dp(r){return Array.isArray(r)?r.sort():typeof r=="object"?Dp(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Pp(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Pw(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Np(r){r=Pp(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ap(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Cp(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Tp(e.arrayFormatSeparator);let t=Dw(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Rp(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:hi(o,e),t(hi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ap(s[o],e);else i[n]=Ap(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Dp(o):n[s]=o,n},Object.create(null))}Ct.extract=Np;Ct.parse=Cp;Ct.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Tp(e.arrayFormatSeparator);let t=o=>e.skipNull&&Rw(r[o])||e.skipEmptyString&&r[o]==="",i=Tw(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?it(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?it(o,e)+"[]":f.reduce(i(o),[]).join("&"):it(o,e)+"="+it(f,e)}).filter(o=>o.length>0).join("&")};Ct.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Rp(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Cp(Np(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:hi(i,e)}:{})};Ct.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Eh]:!0},e);let t=Pp(r.url).split("?")[0]||"",i=Ct.extract(r.url),n=Ct.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ct.stringify(s,e);o&&(o=`?${o}`);let f=Pw(r.url);return r.fragmentIdentifier&&(f=`#${e[Eh]?it(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ct.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Eh]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ct.parseUrl(r,t);return Ct.stringifyUrl({url:i,query:Aw(n,e),fragmentIdentifier:s},t)};Ct.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ct.pick(r,i,t)}});var Lp=Z((VM,ka)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=window:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ka=="object"&&ka.exports,f=typeof define=="function"&&define.amd,u=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],v=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],P=[128,256],z=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),u&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var U=function(E,N,F){return function(q){return new g(E,N,E).update(q)[F]()}},j=function(E,N,F){return function(q,K){return new g(E,N,K).update(q)[F]()}},H=function(E,N,F){return function(q,K,J,$){return a["cshake"+E].update(q,K,J,$)[F]()}},L=function(E,N,F){return function(q,K,J,$){return a["kmac"+E].update(q,K,J,$)[F]()}},C=function(E,N,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}for(var q=this.blocks,K=this.byteCount,J=E.length,$=this.blockCount,V=0,ee=this.s,G,Y;V>2]|=E[V]<>2]|=Y<>2]|=(192|Y>>6)<>2]|=(128|Y&63)<=57344?(q[G>>2]|=(224|Y>>12)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<>2]|=(240|Y>>18)<>2]|=(128|Y>>12&63)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<=K){for(this.start=G-K,this.block=q[$],G=0;G<$;++G)ee[G]^=q[G];k(ee),this.reset=!0}else this.start=G}return this},g.prototype.encode=function(E,N){var F=E&255,q=1,K=[F];for(E=E>>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return N?K.push(q):K.unshift(q),this.update(K),K.length},g.prototype.encodeString=function(E){var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}var q=0,K=E.length;if(N)q=K;else for(var J=0;J=57344?q+=3:($=65536+(($&1023)<<10|E.charCodeAt(++J)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},g.prototype.bytepad=function(E,N){for(var F=this.encode(N),q=0;q>2]|=this.padding[N&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],N=1;N>4&15]+c[V&15]+c[V>>12&15]+c[V>>8&15]+c[V>>20&15]+c[V>>16&15]+c[V>>28&15]+c[V>>24&15];J%E===0&&(k(N),K=0)}return q&&(V=N[K],$+=c[V>>4&15]+c[V&15],q>1&&($+=c[V>>12&15]+c[V>>8&15]),q>2&&($+=c[V>>20&15]+c[V>>16&15])),$},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,N=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,J=0,$=this.outputBits>>3,V;q?V=new ArrayBuffer(F+1<<2):V=new ArrayBuffer($);for(var ee=new Uint32Array(V);J>8&255,$[V+2]=ee>>16&255,$[V+3]=ee>>24&255;J%E===0&&k(N)}return q&&(V=J<<2,ee=N[K],$[V]=ee&255,q>1&&($[V+1]=ee>>8&255),q>2&&($[V+2]=ee>>16&255)),$};function R(E,N,F){g.call(this,E,N,F)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var k=function(E){var N,F,q,K,J,$,V,ee,G,Y,_r,ie,ne,xr,se,oe,Er,ae,fe,Sr,ce,he,Ir,ue,de,Mr,le,pe,Ar,ge,be,Rr,ve,me,Tr,ye,we,Dr,_e,xe,Pr,Ee,Se,Nr,Ie,Me,Cr,Ae,Re,Or,Te,De,Lr,Pe,Ne,nr,Be,ke,jt,Vt,$t,Ht,Gt;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],J=E[1]^E[11]^E[21]^E[31]^E[41],$=E[2]^E[12]^E[22]^E[32]^E[42],V=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],Y=E[6]^E[16]^E[26]^E[36]^E[46],_r=E[7]^E[17]^E[27]^E[37]^E[47],ie=E[8]^E[18]^E[28]^E[38]^E[48],ne=E[9]^E[19]^E[29]^E[39]^E[49],N=ie^($<<1|V>>>31),F=ne^(V<<1|$>>>31),E[0]^=N,E[1]^=F,E[10]^=N,E[11]^=F,E[20]^=N,E[21]^=F,E[30]^=N,E[31]^=F,E[40]^=N,E[41]^=F,N=K^(ee<<1|G>>>31),F=J^(G<<1|ee>>>31),E[2]^=N,E[3]^=F,E[12]^=N,E[13]^=F,E[22]^=N,E[23]^=F,E[32]^=N,E[33]^=F,E[42]^=N,E[43]^=F,N=$^(Y<<1|_r>>>31),F=V^(_r<<1|Y>>>31),E[4]^=N,E[5]^=F,E[14]^=N,E[15]^=F,E[24]^=N,E[25]^=F,E[34]^=N,E[35]^=F,E[44]^=N,E[45]^=F,N=ee^(ie<<1|ne>>>31),F=G^(ne<<1|ie>>>31),E[6]^=N,E[7]^=F,E[16]^=N,E[17]^=F,E[26]^=N,E[27]^=F,E[36]^=N,E[37]^=F,E[46]^=N,E[47]^=F,N=Y^(K<<1|J>>>31),F=_r^(J<<1|K>>>31),E[8]^=N,E[9]^=F,E[18]^=N,E[19]^=F,E[28]^=N,E[29]^=F,E[38]^=N,E[39]^=F,E[48]^=N,E[49]^=F,xr=E[0],se=E[1],Me=E[11]<<4|E[10]>>>28,Cr=E[10]<<4|E[11]>>>28,pe=E[20]<<3|E[21]>>>29,Ar=E[21]<<3|E[20]>>>29,Vt=E[31]<<9|E[30]>>>23,$t=E[30]<<9|E[31]>>>23,Ee=E[40]<<18|E[41]>>>14,Se=E[41]<<18|E[40]>>>14,me=E[2]<<1|E[3]>>>31,Tr=E[3]<<1|E[2]>>>31,oe=E[13]<<12|E[12]>>>20,Er=E[12]<<12|E[13]>>>20,Ae=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,ge=E[33]<<13|E[32]>>>19,be=E[32]<<13|E[33]>>>19,Ht=E[42]<<2|E[43]>>>30,Gt=E[43]<<2|E[42]>>>30,Pe=E[5]<<30|E[4]>>>2,Ne=E[4]<<30|E[5]>>>2,ye=E[14]<<6|E[15]>>>26,we=E[15]<<6|E[14]>>>26,ae=E[25]<<11|E[24]>>>21,fe=E[24]<<11|E[25]>>>21,Or=E[34]<<15|E[35]>>>17,Te=E[35]<<15|E[34]>>>17,Rr=E[45]<<29|E[44]>>>3,ve=E[44]<<29|E[45]>>>3,ue=E[6]<<28|E[7]>>>4,de=E[7]<<28|E[6]>>>4,nr=E[17]<<23|E[16]>>>9,Be=E[16]<<23|E[17]>>>9,Dr=E[26]<<25|E[27]>>>7,_e=E[27]<<25|E[26]>>>7,Sr=E[36]<<21|E[37]>>>11,ce=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Lr=E[46]<<24|E[47]>>>8,Nr=E[8]<<27|E[9]>>>5,Ie=E[9]<<27|E[8]>>>5,Mr=E[18]<<20|E[19]>>>12,le=E[19]<<20|E[18]>>>12,ke=E[29]<<7|E[28]>>>25,jt=E[28]<<7|E[29]>>>25,xe=E[38]<<8|E[39]>>>24,Pr=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Ir=E[49]<<14|E[48]>>>18,E[0]=xr^~oe&ae,E[1]=se^~Er&fe,E[10]=ue^~Mr&pe,E[11]=de^~le&Ar,E[20]=me^~ye&Dr,E[21]=Tr^~we&_e,E[30]=Nr^~Me&Ae,E[31]=Ie^~Cr&Re,E[40]=Pe^~nr&ke,E[41]=Ne^~Be&jt,E[2]=oe^~ae&Sr,E[3]=Er^~fe&ce,E[12]=Mr^~pe&ge,E[13]=le^~Ar&be,E[22]=ye^~Dr&xe,E[23]=we^~_e&Pr,E[32]=Me^~Ae&Or,E[33]=Cr^~Re&Te,E[42]=nr^~ke&Vt,E[43]=Be^~jt&$t,E[4]=ae^~Sr&he,E[5]=fe^~ce&Ir,E[14]=pe^~ge&Rr,E[15]=Ar^~be&ve,E[24]=Dr^~xe&Ee,E[25]=_e^~Pr&Se,E[34]=Ae^~Or&De,E[35]=Re^~Te&Lr,E[44]=ke^~Vt&Ht,E[45]=jt^~$t&Gt,E[6]=Sr^~he&xr,E[7]=ce^~Ir&se,E[16]=ge^~Rr&ue,E[17]=be^~ve&de,E[26]=xe^~Ee&me,E[27]=Pr^~Se&Tr,E[36]=Or^~De&Nr,E[37]=Te^~Lr&Ie,E[46]=Vt^~Ht&Pe,E[47]=$t^~Gt&Ne,E[8]=he^~xr&oe,E[9]=Ir^~se&Er,E[18]=Rr^~ue&Mr,E[19]=ve^~de&le,E[28]=Ee^~me&ye,E[29]=Se^~Tr&we,E[38]=De^~Nr&Me,E[39]=Lr^~Ie&Cr,E[48]=Ht^~Pe&nr,E[49]=Gt^~Ne&Be,E[0]^=T[q],E[1]^=T[q+1]};if(o)ka.exports=a;else{for(m=0;m{});var Ph=Z((Gp,Dh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var d=function(){};d.prototype=a.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,a,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(d=a,a=10),this._init(p||0,a||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,d){return a.cmp(d)>0?a:d},n.min=function(a,d){return a.cmp(d)<0?a:d},n.prototype._init=function(a,d,m){if(typeof a=="number")return this._initNumber(a,d,m);if(typeof a=="object")return this._initArray(a,d,m);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)h=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[y]|=h<>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);else if(m==="le")for(_=0,y=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);return this._strip()};function o(p,a){var d=p.charCodeAt(a);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function f(p,a,d){var m=o(p,d);return d-1>=a&&(m|=o(p,d-1)<<4),m}n.prototype._parseHex=function(a,d,m){this.length=Math.ceil((a.length-d)/6),this.words=new Array(this.length);for(var _=0;_=d;_-=2)x=f(a,d,_)<=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8;else{var A=a.length-d;for(_=A%2===0?d+1:d;_=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8}this._strip()};function u(p,a,d,m){for(var _=0,y=0,h=Math.min(p.length,d),x=a;x=49?y=A-49+10:A>=17?y=A-17+10:y=A,t(A>=0&&y1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var v=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,d){a=a||10,d=d|0||1;var m;if(a===16||a==="hex"){m="";for(var _=0,y=0,h=0;h>>24-_&16777215,_+=2,_>=26&&(_-=26,h--),y!==0||h!==this.length-1?m=v[6-A.length]+A+m:m=A+m}for(y!==0&&(m=y.toString(16)+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];m="";var k=this.clone();for(k.negative=0;!k.isZero();){var E=k.modrn(R).toString(a);k=k.idivn(R),k.isZero()?m=E+m:m=v[g-E.length]+E+m}for(this.isZero()&&(m="0"+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,d){return this.toArrayLike(s,a,d)}),n.prototype.toArray=function(a,d){return this.toArrayLike(Array,a,d)};var M=function(a,d){return a.allocUnsafe?a.allocUnsafe(d):new a(d)};n.prototype.toArrayLike=function(a,d,m){this._strip();var _=this.byteLength(),y=m||Math.max(1,_);t(_<=y,"byte array longer than desired length"),t(y>0,"Requested array length <= 0");var h=M(a,y),x=d==="le"?"LE":"BE";return this["_toArrayLike"+x](h,_),h},n.prototype._toArrayLikeLE=function(a,d){for(var m=0,_=0,y=0,h=0;y>8&255),m>16&255),h===6?(m>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m=0&&(a[m--]=x>>8&255),m>=0&&(a[m--]=x>>16&255),h===6?(m>=0&&(a[m--]=x>>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m>=0)for(a[m--]=_;m>=0;)a[m--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var d=a,m=0;return d>=4096&&(m+=13,d>>>=13),d>=64&&(m+=7,d>>>=7),d>=8&&(m+=4,d>>>=4),d>=2&&(m+=2,d>>>=2),m+d},n.prototype._zeroBits=function(a){if(a===0)return 26;var d=a,m=0;return d&8191||(m+=13,d>>>=13),d&127||(m+=7,d>>>=7),d&15||(m+=4,d>>>=4),d&3||(m+=2,d>>>=2),d&1||m++,m},n.prototype.bitLength=function(){var a=this.words[this.length-1],d=this._countBits(a);return(this.length-1)*26+d};function T(p){for(var a=new Array(p.bitLength()),d=0;d>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,d=0;da.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var d;this.length>a.length?d=a:d=this;for(var m=0;ma.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var d,m;this.length>a.length?(d=this,m=a):(d=a,m=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var d=Math.ceil(a/26)|0,m=a%26;this._expand(d),m>0&&d--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-m),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,d){t(typeof a=="number"&&a>=0);var m=a/26|0,_=a%26;return this._expand(m+1),d?this.words[m]=this.words[m]|1<<_:this.words[m]=this.words[m]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var d;if(this.negative!==0&&a.negative===0)return this.negative=0,d=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,d=this.isub(a),a.negative=1,d._normSign();var m,_;this.length>a.length?(m=this,_=a):(m=a,_=this);for(var y=0,h=0;h<_.length;h++)d=(m.words[h]|0)+(_.words[h]|0)+y,this.words[h]=d&67108863,y=d>>>26;for(;y!==0&&h>>26;if(this.length=m.length,y!==0)this.words[this.length]=y,this.length++;else if(m!==this)for(;ha.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var d=this.iadd(a);return a.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var m=this.cmp(a);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,y;m>0?(_=this,y=a):(_=a,y=this);for(var h=0,x=0;x>26,this.words[x]=d&67108863;for(;h!==0&&x<_.length;x++)d=(_.words[x]|0)+h,h=d>>26,this.words[x]=d&67108863;if(h===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function O(p,a,d){d.negative=a.negative^p.negative;var m=p.length+a.length|0;d.length=m,m=m-1|0;var _=p.words[0]|0,y=a.words[0]|0,h=_*y,x=h&67108863,A=h/67108864|0;d.words[0]=x;for(var g=1;g>>26,k=A&67108863,E=Math.min(g,a.length-1),N=Math.max(0,g-p.length+1);N<=E;N++){var F=g-N|0;_=p.words[F]|0,y=a.words[N]|0,h=_*y+k,R+=h/67108864|0,k=h&67108863}d.words[g]=k|0,A=R|0}return A!==0?d.words[g]=A|0:d.length--,d._strip()}var P=function(a,d,m){var _=a.words,y=d.words,h=m.words,x=0,A,g,R,k=_[0]|0,E=k&8191,N=k>>>13,F=_[1]|0,q=F&8191,K=F>>>13,J=_[2]|0,$=J&8191,V=J>>>13,ee=_[3]|0,G=ee&8191,Y=ee>>>13,_r=_[4]|0,ie=_r&8191,ne=_r>>>13,xr=_[5]|0,se=xr&8191,oe=xr>>>13,Er=_[6]|0,ae=Er&8191,fe=Er>>>13,Sr=_[7]|0,ce=Sr&8191,he=Sr>>>13,Ir=_[8]|0,ue=Ir&8191,de=Ir>>>13,Mr=_[9]|0,le=Mr&8191,pe=Mr>>>13,Ar=y[0]|0,ge=Ar&8191,be=Ar>>>13,Rr=y[1]|0,ve=Rr&8191,me=Rr>>>13,Tr=y[2]|0,ye=Tr&8191,we=Tr>>>13,Dr=y[3]|0,_e=Dr&8191,xe=Dr>>>13,Pr=y[4]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=y[5]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=y[6]|0,Ae=Cr&8191,Re=Cr>>>13,Or=y[7]|0,Te=Or&8191,De=Or>>>13,Lr=y[8]|0,Pe=Lr&8191,Ne=Lr>>>13,nr=y[9]|0,Be=nr&8191,ke=nr>>>13;m.negative=a.negative^d.negative,m.length=19,A=Math.imul(E,ge),g=Math.imul(E,be),g=g+Math.imul(N,ge)|0,R=Math.imul(N,be);var jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(jt>>>26)|0,jt&=67108863,A=Math.imul(q,ge),g=Math.imul(q,be),g=g+Math.imul(K,ge)|0,R=Math.imul(K,be),A=A+Math.imul(E,ve)|0,g=g+Math.imul(E,me)|0,g=g+Math.imul(N,ve)|0,R=R+Math.imul(N,me)|0;var Vt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,A=Math.imul($,ge),g=Math.imul($,be),g=g+Math.imul(V,ge)|0,R=Math.imul(V,be),A=A+Math.imul(q,ve)|0,g=g+Math.imul(q,me)|0,g=g+Math.imul(K,ve)|0,R=R+Math.imul(K,me)|0,A=A+Math.imul(E,ye)|0,g=g+Math.imul(E,we)|0,g=g+Math.imul(N,ye)|0,R=R+Math.imul(N,we)|0;var $t=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+($t>>>26)|0,$t&=67108863,A=Math.imul(G,ge),g=Math.imul(G,be),g=g+Math.imul(Y,ge)|0,R=Math.imul(Y,be),A=A+Math.imul($,ve)|0,g=g+Math.imul($,me)|0,g=g+Math.imul(V,ve)|0,R=R+Math.imul(V,me)|0,A=A+Math.imul(q,ye)|0,g=g+Math.imul(q,we)|0,g=g+Math.imul(K,ye)|0,R=R+Math.imul(K,we)|0,A=A+Math.imul(E,_e)|0,g=g+Math.imul(E,xe)|0,g=g+Math.imul(N,_e)|0,R=R+Math.imul(N,xe)|0;var Ht=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,A=Math.imul(ie,ge),g=Math.imul(ie,be),g=g+Math.imul(ne,ge)|0,R=Math.imul(ne,be),A=A+Math.imul(G,ve)|0,g=g+Math.imul(G,me)|0,g=g+Math.imul(Y,ve)|0,R=R+Math.imul(Y,me)|0,A=A+Math.imul($,ye)|0,g=g+Math.imul($,we)|0,g=g+Math.imul(V,ye)|0,R=R+Math.imul(V,we)|0,A=A+Math.imul(q,_e)|0,g=g+Math.imul(q,xe)|0,g=g+Math.imul(K,_e)|0,R=R+Math.imul(K,xe)|0,A=A+Math.imul(E,Ee)|0,g=g+Math.imul(E,Se)|0,g=g+Math.imul(N,Ee)|0,R=R+Math.imul(N,Se)|0;var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(se,ge),g=Math.imul(se,be),g=g+Math.imul(oe,ge)|0,R=Math.imul(oe,be),A=A+Math.imul(ie,ve)|0,g=g+Math.imul(ie,me)|0,g=g+Math.imul(ne,ve)|0,R=R+Math.imul(ne,me)|0,A=A+Math.imul(G,ye)|0,g=g+Math.imul(G,we)|0,g=g+Math.imul(Y,ye)|0,R=R+Math.imul(Y,we)|0,A=A+Math.imul($,_e)|0,g=g+Math.imul($,xe)|0,g=g+Math.imul(V,_e)|0,R=R+Math.imul(V,xe)|0,A=A+Math.imul(q,Ee)|0,g=g+Math.imul(q,Se)|0,g=g+Math.imul(K,Ee)|0,R=R+Math.imul(K,Se)|0,A=A+Math.imul(E,Ie)|0,g=g+Math.imul(E,Me)|0,g=g+Math.imul(N,Ie)|0,R=R+Math.imul(N,Me)|0;var Qi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,A=Math.imul(ae,ge),g=Math.imul(ae,be),g=g+Math.imul(fe,ge)|0,R=Math.imul(fe,be),A=A+Math.imul(se,ve)|0,g=g+Math.imul(se,me)|0,g=g+Math.imul(oe,ve)|0,R=R+Math.imul(oe,me)|0,A=A+Math.imul(ie,ye)|0,g=g+Math.imul(ie,we)|0,g=g+Math.imul(ne,ye)|0,R=R+Math.imul(ne,we)|0,A=A+Math.imul(G,_e)|0,g=g+Math.imul(G,xe)|0,g=g+Math.imul(Y,_e)|0,R=R+Math.imul(Y,xe)|0,A=A+Math.imul($,Ee)|0,g=g+Math.imul($,Se)|0,g=g+Math.imul(V,Ee)|0,R=R+Math.imul(V,Se)|0,A=A+Math.imul(q,Ie)|0,g=g+Math.imul(q,Me)|0,g=g+Math.imul(K,Ie)|0,R=R+Math.imul(K,Me)|0,A=A+Math.imul(E,Ae)|0,g=g+Math.imul(E,Re)|0,g=g+Math.imul(N,Ae)|0,R=R+Math.imul(N,Re)|0;var en=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(en>>>26)|0,en&=67108863,A=Math.imul(ce,ge),g=Math.imul(ce,be),g=g+Math.imul(he,ge)|0,R=Math.imul(he,be),A=A+Math.imul(ae,ve)|0,g=g+Math.imul(ae,me)|0,g=g+Math.imul(fe,ve)|0,R=R+Math.imul(fe,me)|0,A=A+Math.imul(se,ye)|0,g=g+Math.imul(se,we)|0,g=g+Math.imul(oe,ye)|0,R=R+Math.imul(oe,we)|0,A=A+Math.imul(ie,_e)|0,g=g+Math.imul(ie,xe)|0,g=g+Math.imul(ne,_e)|0,R=R+Math.imul(ne,xe)|0,A=A+Math.imul(G,Ee)|0,g=g+Math.imul(G,Se)|0,g=g+Math.imul(Y,Ee)|0,R=R+Math.imul(Y,Se)|0,A=A+Math.imul($,Ie)|0,g=g+Math.imul($,Me)|0,g=g+Math.imul(V,Ie)|0,R=R+Math.imul(V,Me)|0,A=A+Math.imul(q,Ae)|0,g=g+Math.imul(q,Re)|0,g=g+Math.imul(K,Ae)|0,R=R+Math.imul(K,Re)|0,A=A+Math.imul(E,Te)|0,g=g+Math.imul(E,De)|0,g=g+Math.imul(N,Te)|0,R=R+Math.imul(N,De)|0;var tn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(tn>>>26)|0,tn&=67108863,A=Math.imul(ue,ge),g=Math.imul(ue,be),g=g+Math.imul(de,ge)|0,R=Math.imul(de,be),A=A+Math.imul(ce,ve)|0,g=g+Math.imul(ce,me)|0,g=g+Math.imul(he,ve)|0,R=R+Math.imul(he,me)|0,A=A+Math.imul(ae,ye)|0,g=g+Math.imul(ae,we)|0,g=g+Math.imul(fe,ye)|0,R=R+Math.imul(fe,we)|0,A=A+Math.imul(se,_e)|0,g=g+Math.imul(se,xe)|0,g=g+Math.imul(oe,_e)|0,R=R+Math.imul(oe,xe)|0,A=A+Math.imul(ie,Ee)|0,g=g+Math.imul(ie,Se)|0,g=g+Math.imul(ne,Ee)|0,R=R+Math.imul(ne,Se)|0,A=A+Math.imul(G,Ie)|0,g=g+Math.imul(G,Me)|0,g=g+Math.imul(Y,Ie)|0,R=R+Math.imul(Y,Me)|0,A=A+Math.imul($,Ae)|0,g=g+Math.imul($,Re)|0,g=g+Math.imul(V,Ae)|0,R=R+Math.imul(V,Re)|0,A=A+Math.imul(q,Te)|0,g=g+Math.imul(q,De)|0,g=g+Math.imul(K,Te)|0,R=R+Math.imul(K,De)|0,A=A+Math.imul(E,Pe)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(N,Pe)|0,R=R+Math.imul(N,Ne)|0;var rn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(rn>>>26)|0,rn&=67108863,A=Math.imul(le,ge),g=Math.imul(le,be),g=g+Math.imul(pe,ge)|0,R=Math.imul(pe,be),A=A+Math.imul(ue,ve)|0,g=g+Math.imul(ue,me)|0,g=g+Math.imul(de,ve)|0,R=R+Math.imul(de,me)|0,A=A+Math.imul(ce,ye)|0,g=g+Math.imul(ce,we)|0,g=g+Math.imul(he,ye)|0,R=R+Math.imul(he,we)|0,A=A+Math.imul(ae,_e)|0,g=g+Math.imul(ae,xe)|0,g=g+Math.imul(fe,_e)|0,R=R+Math.imul(fe,xe)|0,A=A+Math.imul(se,Ee)|0,g=g+Math.imul(se,Se)|0,g=g+Math.imul(oe,Ee)|0,R=R+Math.imul(oe,Se)|0,A=A+Math.imul(ie,Ie)|0,g=g+Math.imul(ie,Me)|0,g=g+Math.imul(ne,Ie)|0,R=R+Math.imul(ne,Me)|0,A=A+Math.imul(G,Ae)|0,g=g+Math.imul(G,Re)|0,g=g+Math.imul(Y,Ae)|0,R=R+Math.imul(Y,Re)|0,A=A+Math.imul($,Te)|0,g=g+Math.imul($,De)|0,g=g+Math.imul(V,Te)|0,R=R+Math.imul(V,De)|0,A=A+Math.imul(q,Pe)|0,g=g+Math.imul(q,Ne)|0,g=g+Math.imul(K,Pe)|0,R=R+Math.imul(K,Ne)|0,A=A+Math.imul(E,Be)|0,g=g+Math.imul(E,ke)|0,g=g+Math.imul(N,Be)|0,R=R+Math.imul(N,ke)|0;var nn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nn>>>26)|0,nn&=67108863,A=Math.imul(le,ve),g=Math.imul(le,me),g=g+Math.imul(pe,ve)|0,R=Math.imul(pe,me),A=A+Math.imul(ue,ye)|0,g=g+Math.imul(ue,we)|0,g=g+Math.imul(de,ye)|0,R=R+Math.imul(de,we)|0,A=A+Math.imul(ce,_e)|0,g=g+Math.imul(ce,xe)|0,g=g+Math.imul(he,_e)|0,R=R+Math.imul(he,xe)|0,A=A+Math.imul(ae,Ee)|0,g=g+Math.imul(ae,Se)|0,g=g+Math.imul(fe,Ee)|0,R=R+Math.imul(fe,Se)|0,A=A+Math.imul(se,Ie)|0,g=g+Math.imul(se,Me)|0,g=g+Math.imul(oe,Ie)|0,R=R+Math.imul(oe,Me)|0,A=A+Math.imul(ie,Ae)|0,g=g+Math.imul(ie,Re)|0,g=g+Math.imul(ne,Ae)|0,R=R+Math.imul(ne,Re)|0,A=A+Math.imul(G,Te)|0,g=g+Math.imul(G,De)|0,g=g+Math.imul(Y,Te)|0,R=R+Math.imul(Y,De)|0,A=A+Math.imul($,Pe)|0,g=g+Math.imul($,Ne)|0,g=g+Math.imul(V,Pe)|0,R=R+Math.imul(V,Ne)|0,A=A+Math.imul(q,Be)|0,g=g+Math.imul(q,ke)|0,g=g+Math.imul(K,Be)|0,R=R+Math.imul(K,ke)|0;var sn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(sn>>>26)|0,sn&=67108863,A=Math.imul(le,ye),g=Math.imul(le,we),g=g+Math.imul(pe,ye)|0,R=Math.imul(pe,we),A=A+Math.imul(ue,_e)|0,g=g+Math.imul(ue,xe)|0,g=g+Math.imul(de,_e)|0,R=R+Math.imul(de,xe)|0,A=A+Math.imul(ce,Ee)|0,g=g+Math.imul(ce,Se)|0,g=g+Math.imul(he,Ee)|0,R=R+Math.imul(he,Se)|0,A=A+Math.imul(ae,Ie)|0,g=g+Math.imul(ae,Me)|0,g=g+Math.imul(fe,Ie)|0,R=R+Math.imul(fe,Me)|0,A=A+Math.imul(se,Ae)|0,g=g+Math.imul(se,Re)|0,g=g+Math.imul(oe,Ae)|0,R=R+Math.imul(oe,Re)|0,A=A+Math.imul(ie,Te)|0,g=g+Math.imul(ie,De)|0,g=g+Math.imul(ne,Te)|0,R=R+Math.imul(ne,De)|0,A=A+Math.imul(G,Pe)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(Y,Pe)|0,R=R+Math.imul(Y,Ne)|0,A=A+Math.imul($,Be)|0,g=g+Math.imul($,ke)|0,g=g+Math.imul(V,Be)|0,R=R+Math.imul(V,ke)|0;var on=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(on>>>26)|0,on&=67108863,A=Math.imul(le,_e),g=Math.imul(le,xe),g=g+Math.imul(pe,_e)|0,R=Math.imul(pe,xe),A=A+Math.imul(ue,Ee)|0,g=g+Math.imul(ue,Se)|0,g=g+Math.imul(de,Ee)|0,R=R+Math.imul(de,Se)|0,A=A+Math.imul(ce,Ie)|0,g=g+Math.imul(ce,Me)|0,g=g+Math.imul(he,Ie)|0,R=R+Math.imul(he,Me)|0,A=A+Math.imul(ae,Ae)|0,g=g+Math.imul(ae,Re)|0,g=g+Math.imul(fe,Ae)|0,R=R+Math.imul(fe,Re)|0,A=A+Math.imul(se,Te)|0,g=g+Math.imul(se,De)|0,g=g+Math.imul(oe,Te)|0,R=R+Math.imul(oe,De)|0,A=A+Math.imul(ie,Pe)|0,g=g+Math.imul(ie,Ne)|0,g=g+Math.imul(ne,Pe)|0,R=R+Math.imul(ne,Ne)|0,A=A+Math.imul(G,Be)|0,g=g+Math.imul(G,ke)|0,g=g+Math.imul(Y,Be)|0,R=R+Math.imul(Y,ke)|0;var an=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(an>>>26)|0,an&=67108863,A=Math.imul(le,Ee),g=Math.imul(le,Se),g=g+Math.imul(pe,Ee)|0,R=Math.imul(pe,Se),A=A+Math.imul(ue,Ie)|0,g=g+Math.imul(ue,Me)|0,g=g+Math.imul(de,Ie)|0,R=R+Math.imul(de,Me)|0,A=A+Math.imul(ce,Ae)|0,g=g+Math.imul(ce,Re)|0,g=g+Math.imul(he,Ae)|0,R=R+Math.imul(he,Re)|0,A=A+Math.imul(ae,Te)|0,g=g+Math.imul(ae,De)|0,g=g+Math.imul(fe,Te)|0,R=R+Math.imul(fe,De)|0,A=A+Math.imul(se,Pe)|0,g=g+Math.imul(se,Ne)|0,g=g+Math.imul(oe,Pe)|0,R=R+Math.imul(oe,Ne)|0,A=A+Math.imul(ie,Be)|0,g=g+Math.imul(ie,ke)|0,g=g+Math.imul(ne,Be)|0,R=R+Math.imul(ne,ke)|0;var fn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fn>>>26)|0,fn&=67108863,A=Math.imul(le,Ie),g=Math.imul(le,Me),g=g+Math.imul(pe,Ie)|0,R=Math.imul(pe,Me),A=A+Math.imul(ue,Ae)|0,g=g+Math.imul(ue,Re)|0,g=g+Math.imul(de,Ae)|0,R=R+Math.imul(de,Re)|0,A=A+Math.imul(ce,Te)|0,g=g+Math.imul(ce,De)|0,g=g+Math.imul(he,Te)|0,R=R+Math.imul(he,De)|0,A=A+Math.imul(ae,Pe)|0,g=g+Math.imul(ae,Ne)|0,g=g+Math.imul(fe,Pe)|0,R=R+Math.imul(fe,Ne)|0,A=A+Math.imul(se,Be)|0,g=g+Math.imul(se,ke)|0,g=g+Math.imul(oe,Be)|0,R=R+Math.imul(oe,ke)|0;var cn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cn>>>26)|0,cn&=67108863,A=Math.imul(le,Ae),g=Math.imul(le,Re),g=g+Math.imul(pe,Ae)|0,R=Math.imul(pe,Re),A=A+Math.imul(ue,Te)|0,g=g+Math.imul(ue,De)|0,g=g+Math.imul(de,Te)|0,R=R+Math.imul(de,De)|0,A=A+Math.imul(ce,Pe)|0,g=g+Math.imul(ce,Ne)|0,g=g+Math.imul(he,Pe)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(ae,Be)|0,g=g+Math.imul(ae,ke)|0,g=g+Math.imul(fe,Be)|0,R=R+Math.imul(fe,ke)|0;var hn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(hn>>>26)|0,hn&=67108863,A=Math.imul(le,Te),g=Math.imul(le,De),g=g+Math.imul(pe,Te)|0,R=Math.imul(pe,De),A=A+Math.imul(ue,Pe)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(de,Pe)|0,R=R+Math.imul(de,Ne)|0,A=A+Math.imul(ce,Be)|0,g=g+Math.imul(ce,ke)|0,g=g+Math.imul(he,Be)|0,R=R+Math.imul(he,ke)|0;var fc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fc>>>26)|0,fc&=67108863,A=Math.imul(le,Pe),g=Math.imul(le,Ne),g=g+Math.imul(pe,Pe)|0,R=Math.imul(pe,Ne),A=A+Math.imul(ue,Be)|0,g=g+Math.imul(ue,ke)|0,g=g+Math.imul(de,Be)|0,R=R+Math.imul(de,ke)|0;var cc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cc>>>26)|0,cc&=67108863,A=Math.imul(le,Be),g=Math.imul(le,ke),g=g+Math.imul(pe,Be)|0,R=Math.imul(pe,ke);var hc=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(hc>>>26)|0,hc&=67108863,h[0]=jt,h[1]=Vt,h[2]=$t,h[3]=Ht,h[4]=Gt,h[5]=Qi,h[6]=en,h[7]=tn,h[8]=rn,h[9]=nn,h[10]=sn,h[11]=on,h[12]=an,h[13]=fn,h[14]=cn,h[15]=hn,h[16]=fc,h[17]=cc,h[18]=hc,x!==0&&(h[19]=x,m.length++),m};Math.imul||(P=O);function z(p,a,d){d.negative=a.negative^p.negative,d.length=p.length+a.length;for(var m=0,_=0,y=0;y>>26)|0,_+=h>>>26,h&=67108863}d.words[y]=x,m=h,h=_}return m!==0?d.words[y]=m:d.length--,d._strip()}function B(p,a,d){return z(p,a,d)}n.prototype.mulTo=function(a,d){var m,_=this.length+a.length;return this.length===10&&a.length===10?m=P(this,a,d):_<63?m=O(this,a,d):_<1024?m=z(this,a,d):m=B(this,a,d),m};function U(p,a){this.x=p,this.y=a}U.prototype.makeRBT=function(a){for(var d=new Array(a),m=n.prototype._countBits(a)-1,_=0;_>=1;return _},U.prototype.permute=function(a,d,m,_,y,h){for(var x=0;x>>1)y++;return 1<>>13,m[2*h+1]=y&8191,y=y>>>13;for(h=2*d;h<_;++h)m[h]=0;t(y===0),t((y&-8192)===0)},U.prototype.stub=function(a){for(var d=new Array(a),m=0;m>=26,m+=y/67108864|0,m+=h>>>26,this.words[_]=h&67108863}return m!==0&&(this.words[_]=m,this.length++),d?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var d=T(a);if(d.length===0)return new n(1);for(var m=this,_=0;_=0);var d=a%26,m=(a-d)/26,_=67108863>>>26-d<<26-d,y;if(d!==0){var h=0;for(y=0;y>>26-d}h&&(this.words[y]=h,this.length++)}if(m!==0){for(y=this.length-1;y>=0;y--)this.words[y+m]=this.words[y];for(y=0;y=0);var _;d?_=(d-d%26)/26:_=0;var y=a%26,h=Math.min((a-y)/26,this.length),x=67108863^67108863>>>y<h)for(this.length-=h,g=0;g=0&&(R!==0||g>=_);g--){var k=this.words[g]|0;this.words[g]=R<<26-y|k>>>y,R=k&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,d,m){return t(this.negative===0),this.iushrn(a,d,m)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var d=a%26,m=(a-d)/26,_=1<=0);var d=a%26,m=(a-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(d!==0&&m++,this.length=Math.min(m,this.length),d!==0){var _=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(A/67108864|0),this.words[y+m]=h&67108863}for(;y>26,this.words[y+m]=h&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,y=0;y>26,this.words[y]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,d){var m=this.length-a.length,_=this.clone(),y=a,h=y.words[y.length-1]|0,x=this._countBits(h);m=26-x,m!==0&&(y=y.ushln(m),_.iushln(m),h=y.words[y.length-1]|0);var A=_.length-y.length,g;if(d!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var N=(_.words[y.length+E]|0)*67108864+(_.words[y.length+E-1]|0);for(N=Math.min(N/h|0,67108863),_._ishlnsubmul(y,N,E);_.negative!==0;)N--,_.negative=0,_._ishlnsubmul(y,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=N)}return g&&g._strip(),_._strip(),d!=="div"&&m!==0&&_.iushrn(m),{div:g||null,mod:_}},n.prototype.divmod=function(a,d,m){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,y,h;return this.negative!==0&&a.negative===0?(h=this.neg().divmod(a,d),d!=="mod"&&(_=h.div.neg()),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.iadd(a)),{div:_,mod:y}):this.negative===0&&a.negative!==0?(h=this.divmod(a.neg(),d),d!=="mod"&&(_=h.div.neg()),{div:_,mod:h.mod}):this.negative&a.negative?(h=this.neg().divmod(a.neg(),d),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.isub(a)),{div:h.div,mod:y}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?d==="div"?{div:this.divn(a.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,d)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var d=this.divmod(a);if(d.mod.isZero())return d.div;var m=d.div.negative!==0?d.mod.isub(a):d.mod,_=a.ushrn(1),y=a.andln(1),h=m.cmp(_);return h<0||y===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=(1<<26)%a,_=0,y=this.length-1;y>=0;y--)_=(m*_+(this.words[y]|0))%a;return d?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=0,_=this.length-1;_>=0;_--){var y=(this.words[_]|0)+m*67108864;this.words[_]=y/a|0,m=y%a}return this._strip(),d?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=new n(0),x=new n(1),A=0;d.isEven()&&m.isEven();)d.iushrn(1),m.iushrn(1),++A;for(var g=m.clone(),R=d.clone();!d.isZero();){for(var k=0,E=1;!(d.words[0]&E)&&k<26;++k,E<<=1);if(k>0)for(d.iushrn(k);k-- >0;)(_.isOdd()||y.isOdd())&&(_.iadd(g),y.isub(R)),_.iushrn(1),y.iushrn(1);for(var N=0,F=1;!(m.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(m.iushrn(N);N-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(g),x.isub(R)),h.iushrn(1),x.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(h),y.isub(x)):(m.isub(d),h.isub(_),x.isub(y))}return{a:h,b:x,gcd:m.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=m.clone();d.cmpn(1)>0&&m.cmpn(1)>0;){for(var x=0,A=1;!(d.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(d.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(h),_.iushrn(1);for(var g=0,R=1;!(m.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(m.iushrn(g);g-- >0;)y.isOdd()&&y.iadd(h),y.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(y)):(m.isub(d),y.isub(_))}var k;return d.cmpn(1)===0?k=_:k=y,k.cmpn(0)<0&&k.iadd(a),k},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var d=this.clone(),m=a.clone();d.negative=0,m.negative=0;for(var _=0;d.isEven()&&m.isEven();_++)d.iushrn(1),m.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;m.isEven();)m.iushrn(1);var y=d.cmp(m);if(y<0){var h=d;d=m,m=h}else if(y===0||m.cmpn(1)===0)break;d.isub(m)}while(!0);return m.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var d=a%26,m=(a-d)/26,_=1<>>26,x&=67108863,this.words[h]=x}return y!==0&&(this.words[h]=y,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var d=a<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var m;if(this.length>1)m=1;else{d&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;m=_===a?0:_a.length)return 1;if(this.length=0;m--){var _=this.words[m]|0,y=a.words[m]|0;if(_!==y){_y&&(d=1);break}}return d},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var j={k256:null,p224:null,p192:null,p25519:null};function H(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var d=a,m;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),m=d.bitLength();while(m>this.n);var _=m0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},H.prototype.split=function(a,d){a.iushrn(this.n,0,d)},H.prototype.imulK=function(a){return a.imul(this.k)};function L(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,H),L.prototype.split=function(a,d){for(var m=4194303,_=Math.min(a.length,9),y=0;y<_;y++)d.words[y]=a.words[y];if(d.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var h=a.words[9];for(d.words[d.length++]=h&m,y=10;y>>22,h=x}h>>>=22,a.words[y-10]=h,h===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var d=0,m=0;m>>=26,a.words[m]=y,d=_}return d!==0&&(a.words[a.length++]=d),a},n._prime=function(a){if(j[a])return j[a];var d;if(a==="k256")d=new L;else if(a==="p224")d=new C;else if(a==="p192")d=new W;else if(a==="p25519")d=new D;else throw new Error("Unknown prime "+a);return j[a]=d,d};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,d){t((a.negative|d.negative)===0,"red works only with positives"),t(a.red&&a.red===d.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(c(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,d){this._verify2(a,d);var m=a.add(d);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},l.prototype.iadd=function(a,d){this._verify2(a,d);var m=a.iadd(d);return m.cmp(this.m)>=0&&m.isub(this.m),m},l.prototype.sub=function(a,d){this._verify2(a,d);var m=a.sub(d);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},l.prototype.isub=function(a,d){this._verify2(a,d);var m=a.isub(d);return m.cmpn(0)<0&&m.iadd(this.m),m},l.prototype.shl=function(a,d){return this._verify1(a),this.imod(a.ushln(d))},l.prototype.imul=function(a,d){return this._verify2(a,d),this.imod(a.imul(d))},l.prototype.mul=function(a,d){return this._verify2(a,d),this.imod(a.mul(d))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var m=this.m.add(new n(1)).iushrn(2);return this.pow(a,m)}for(var _=this.m.subn(1),y=0;!_.isZero()&&_.andln(1)===0;)y++,_.iushrn(1);t(!_.isZero());var h=new n(1).toRed(this),x=h.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),k=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),N=y;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;y--){for(var R=d.words[y],k=g-1;k>=0;k--){var E=R>>k&1;if(h!==_[0]&&(h=this.sqr(h)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==m&&(y!==0||k!==0))&&(h=this.mul(h,_[x]),A=0,x=0)}g=26}return h},l.prototype.convertTo=function(a){var d=a.umod(this.m);return d===a?d.clone():d},l.prototype.convertFrom=function(a){var d=a.clone();return d.red=null,d},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var d=this.imod(a.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(a,d){if(a.isZero()||d.isZero())return a.words[0]=0,a.length=1,a;var m=a.imul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(a,d){if(a.isZero()||d.isZero())return new n(0)._forceRed(this);var m=a.mul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(a){var d=this.imod(a._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof Dh>"u"||Dh,Gp)});var Pi=Z((UA,o1)=>{o1.exports=s1;function s1(r,e){if(!r)throw new Error(e||"Assertion failed")}s1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var co=Z((zA,Oh)=>{typeof Object.create=="function"?Oh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Oh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var fr=Z(Ve=>{"use strict";var jw=Pi(),Vw=co();Ve.inherits=Vw;function $w(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Hw(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):$w(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ve.htonl=a1;function Ww(r,e){for(var t="",i=0;i>>0}return s}Ve.join32=Jw;function Yw(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ve.split32=Yw;function Xw(r,e){return r>>>e|r<<32-e}Ve.rotr32=Xw;function Zw(r,e){return r<>>32-e}Ve.rotl32=Zw;function Qw(r,e){return r+e>>>0}Ve.sum32=Qw;function e5(r,e,t){return r+e+t>>>0}Ve.sum32_3=e5;function t5(r,e,t,i){return r+e+t+i>>>0}Ve.sum32_4=t5;function r5(r,e,t,i,n){return r+e+t+i+n>>>0}Ve.sum32_5=r5;function i5(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}Ve.sum64=i5;function n5(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ve.sum64_hi=n5;function s5(r,e,t,i){var n=e+i;return n>>>0}Ve.sum64_lo=s5;function o5(r,e,t,i,n,s,o,f){var u=0,c=e;c=c+i>>>0,u+=c>>0,u+=c>>0,u+=c>>0}Ve.sum64_4_hi=o5;function a5(r,e,t,i,n,s,o,f){var u=e+i+s+f;return u>>>0}Ve.sum64_4_lo=a5;function f5(r,e,t,i,n,s,o,f,u,c){var b=0,v=e;v=v+i>>>0,b+=v>>0,b+=v>>0,b+=v>>0,b+=v>>0}Ve.sum64_5_hi=f5;function c5(r,e,t,i,n,s,o,f,u,c){var b=e+i+s+f+c;return b>>>0}Ve.sum64_5_lo=c5;function h5(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ve.rotr64_hi=h5;function u5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.rotr64_lo=u5;function d5(r,e,t){return r>>>t}Ve.shr64_hi=d5;function l5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.shr64_lo=l5});var os=Z(u1=>{"use strict";var h1=fr(),p5=Pi();function Ga(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}u1.BlockHash=Ga;Ga.prototype.update=function(e,t){if(e=h1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=h1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var g5=fr(),zr=g5.rotr32;function b5(r,e,t,i){if(r===0)return d1(e,t,i);if(r===1||r===3)return p1(e,t,i);if(r===2)return l1(e,t,i)}ui.ft_1=b5;function d1(r,e,t){return r&e^~r&t}ui.ch32=d1;function l1(r,e,t){return r&e^r&t^e&t}ui.maj32=l1;function p1(r,e,t){return r^e^t}ui.p32=p1;function v5(r){return zr(r,2)^zr(r,13)^zr(r,22)}ui.s0_256=v5;function m5(r){return zr(r,6)^zr(r,11)^zr(r,25)}ui.s1_256=m5;function y5(r){return zr(r,7)^zr(r,18)^r>>>3}ui.g0_256=y5;function w5(r){return zr(r,17)^zr(r,19)^r>>>10}ui.g1_256=w5});var v1=Z((jA,b1)=>{"use strict";var as=fr(),_5=os(),x5=Lh(),Fh=as.rotl32,ho=as.sum32,E5=as.sum32_5,S5=x5.ft_1,g1=_5.BlockHash,I5=[1518500249,1859775393,2400959708,3395469782];function Br(){if(!(this instanceof Br))return new Br;g1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}as.inherits(Br,g1);b1.exports=Br;Br.blockSize=512;Br.outSize=160;Br.hmacStrength=80;Br.padLength=64;Br.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var fs=fr(),M5=os(),cs=Lh(),A5=Pi(),cr=fs.sum32,R5=fs.sum32_4,T5=fs.sum32_5,D5=cs.ch32,P5=cs.maj32,N5=cs.s0_256,C5=cs.s1_256,O5=cs.g0_256,L5=cs.g1_256,m1=M5.BlockHash,F5=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function kr(){if(!(this instanceof kr))return new kr;m1.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=F5,this.W=new Array(64)}fs.inherits(kr,m1);y1.exports=kr;kr.blockSize=512;kr.outSize=256;kr.hmacStrength=192;kr.padLength=64;kr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Uh=fr(),w1=qh();function di(){if(!(this instanceof di))return new di;w1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Uh.inherits(di,w1);_1.exports=di;di.blockSize=512;di.outSize=224;di.hmacStrength=192;di.padLength=64;di.prototype._digest=function(e){return e==="hex"?Uh.toHex32(this.h.slice(0,7),"big"):Uh.split32(this.h.slice(0,7),"big")}});var kh=Z((HA,M1)=>{"use strict";var Ot=fr(),q5=os(),U5=Pi(),Kr=Ot.rotr64_hi,jr=Ot.rotr64_lo,E1=Ot.shr64_hi,S1=Ot.shr64_lo,Ni=Ot.sum64,zh=Ot.sum64_hi,Bh=Ot.sum64_lo,z5=Ot.sum64_4_hi,B5=Ot.sum64_4_lo,k5=Ot.sum64_5_hi,K5=Ot.sum64_5_lo,I1=q5.BlockHash,j5=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function hr(){if(!(this instanceof hr))return new hr;I1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=j5,this.W=new Array(160)}Ot.inherits(hr,I1);M1.exports=hr;hr.blockSize=1024;hr.outSize=512;hr.hmacStrength=192;hr.padLength=128;hr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Kh=fr(),A1=kh();function li(){if(!(this instanceof li))return new li;A1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Kh.inherits(li,A1);R1.exports=li;li.blockSize=1024;li.outSize=384;li.hmacStrength=192;li.padLength=128;li.prototype._digest=function(e){return e==="hex"?Kh.toHex32(this.h.slice(0,12),"big"):Kh.split32(this.h.slice(0,12),"big")}});var D1=Z(hs=>{"use strict";hs.sha1=v1();hs.sha224=x1();hs.sha256=qh();hs.sha384=T1();hs.sha512=kh()});var F1=Z(L1=>{"use strict";var _n=fr(),r8=os(),Wa=_n.rotl32,P1=_n.sum32,uo=_n.sum32_3,N1=_n.sum32_4,O1=r8.BlockHash;function Vr(){if(!(this instanceof Vr))return new Vr;O1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}_n.inherits(Vr,O1);L1.ripemd160=Vr;Vr.blockSize=512;Vr.outSize=160;Vr.hmacStrength=192;Vr.padLength=64;Vr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],u=i,c=n,b=s,v=o,S=f,I=0;I<80;I++){var M=P1(Wa(N1(i,C1(I,n,s,o),e[s8[I]+t],i8(I)),a8[I]),f);i=f,f=o,o=Wa(s,10),s=n,n=M,M=P1(Wa(N1(u,C1(79-I,c,b,v),e[o8[I]+t],n8(I)),f8[I]),S),u=S,S=v,v=Wa(b,10),b=c,c=M}M=uo(this.h[1],s,v),this.h[1]=uo(this.h[2],o,S),this.h[2]=uo(this.h[3],f,u),this.h[3]=uo(this.h[4],i,c),this.h[4]=uo(this.h[0],n,b),this.h[0]=M};Vr.prototype._digest=function(e){return e==="hex"?_n.toHex32(this.h,"little"):_n.split32(this.h,"little")};function C1(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function i8(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function n8(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var s8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o8=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],a8=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f8=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var U1=Z((YA,q1)=>{"use strict";var c8=fr(),h8=Pi();function us(r,e,t){if(!(this instanceof us))return new us(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(c8.toArray(e,t))}q1.exports=us;us.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),h8(e.length<=this.blockSize);for(var t=e.length;t{var pt=z1;pt.utils=fr();pt.common=os();pt.sha=D1();pt.ripemd=F1();pt.hmac=U1();pt.sha1=pt.sha.sha1;pt.sha256=pt.sha.sha256;pt.sha224=pt.sha.sha224;pt.sha384=pt.sha.sha384;pt.sha512=pt.sha.sha512;pt.ripemd160=pt.ripemd.ripemd160});var X1=Z(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var Et=Hn(),Qh=Jt(),_8=20;function x8(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],c=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],v=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],P=e[11]<<24|e[10]<<16|e[9]<<8|e[8],z=e[15]<<24|e[14]<<16|e[13]<<8|e[12],B=i,U=n,j=s,H=o,L=f,C=u,W=c,D=b,l=v,w=S,p=I,a=M,d=T,m=O,_=P,y=z,h=0;h<_8;h+=2)B=B+L|0,d^=B,d=d>>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,U=U+C|0,m^=U,m=m>>>16|m<<16,w=w+m|0,C^=w,C=C>>>20|C<<12,j=j+W|0,_^=j,_=_>>>16|_<<16,p=p+_|0,W^=p,W=W>>>20|W<<12,H=H+D|0,y^=H,y=y>>>16|y<<16,a=a+y|0,D^=a,D=D>>>20|D<<12,j=j+W|0,_^=j,_=_>>>24|_<<8,p=p+_|0,W^=p,W=W>>>25|W<<7,H=H+D|0,y^=H,y=y>>>24|y<<8,a=a+y|0,D^=a,D=D>>>25|D<<7,U=U+C|0,m^=U,m=m>>>24|m<<8,w=w+m|0,C^=w,C=C>>>25|C<<7,B=B+L|0,d^=B,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,B=B+C|0,y^=B,y=y>>>16|y<<16,p=p+y|0,C^=p,C=C>>>20|C<<12,U=U+W|0,d^=U,d=d>>>16|d<<16,a=a+d|0,W^=a,W=W>>>20|W<<12,j=j+D|0,m^=j,m=m>>>16|m<<16,l=l+m|0,D^=l,D=D>>>20|D<<12,H=H+L|0,_^=H,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,j=j+D|0,m^=j,m=m>>>24|m<<8,l=l+m|0,D^=l,D=D>>>25|D<<7,H=H+L|0,_^=H,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,U=U+W|0,d^=U,d=d>>>24|d<<8,a=a+d|0,W^=a,W=W>>>25|W<<7,B=B+C|0,y^=B,y=y>>>24|y<<8,p=p+y|0,C^=p,C=C>>>25|C<<7;Et.writeUint32LE(B+i|0,r,0),Et.writeUint32LE(U+n|0,r,4),Et.writeUint32LE(j+s|0,r,8),Et.writeUint32LE(H+o|0,r,12),Et.writeUint32LE(L+f|0,r,16),Et.writeUint32LE(C+u|0,r,20),Et.writeUint32LE(W+c|0,r,24),Et.writeUint32LE(D+b|0,r,28),Et.writeUint32LE(l+v|0,r,32),Et.writeUint32LE(w+S|0,r,36),Et.writeUint32LE(p+I|0,r,40),Et.writeUint32LE(a+M|0,r,44),Et.writeUint32LE(d+T|0,r,48),Et.writeUint32LE(m+O|0,r,52),Et.writeUint32LE(_+P|0,r,56),Et.writeUint32LE(y+z|0,r,60)}function Y1(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var rf=Z(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});function I8(r,e,t){return~(r-1)&e|r-1&t}ls.select=I8;function M8(r,e){return(r|0)-(e|0)-1>>>31&1}ls.lessOrEqual=M8;function Z1(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}ls.compare=Z1;function A8(r,e){return r.length===0||e.length===0?!1:Z1(r,e)!==0}ls.equal=A8});var eg=Z(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var R8=rf(),nf=Jt();pi.DIGEST_LENGTH=16;var Q1=function(){function r(e){this.digestLength=pi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var u=e[12]|e[13]<<8;this._r[7]=(f>>>11|u<<5)&8065;var c=e[14]|e[15]<<8;this._r[8]=(u>>>8|c<<8)&8191,this._r[9]=c>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],u=this._h[3],c=this._h[4],b=this._h[5],v=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],O=this._r[1],P=this._r[2],z=this._r[3],B=this._r[4],U=this._r[5],j=this._r[6],H=this._r[7],L=this._r[8],C=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var D=e[t+2]|e[t+3]<<8;o+=(W>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;u+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;c+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;v+=(p>>>14|a<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(a>>>11|d<<5)&8191;var m=e[t+14]|e[t+15]<<8;I+=(d>>>8|m<<8)&8191,M+=m>>>5|n;var _=0,y=_;y+=s*T,y+=o*(5*C),y+=f*(5*L),y+=u*(5*H),y+=c*(5*j),_=y>>>13,y&=8191,y+=b*(5*U),y+=v*(5*B),y+=S*(5*z),y+=I*(5*P),y+=M*(5*O),_+=y>>>13,y&=8191;var h=_;h+=s*O,h+=o*T,h+=f*(5*C),h+=u*(5*L),h+=c*(5*H),_=h>>>13,h&=8191,h+=b*(5*j),h+=v*(5*U),h+=S*(5*B),h+=I*(5*z),h+=M*(5*P),_+=h>>>13,h&=8191;var x=_;x+=s*P,x+=o*O,x+=f*T,x+=u*(5*C),x+=c*(5*L),_=x>>>13,x&=8191,x+=b*(5*H),x+=v*(5*j),x+=S*(5*U),x+=I*(5*B),x+=M*(5*z),_+=x>>>13,x&=8191;var A=_;A+=s*z,A+=o*P,A+=f*O,A+=u*T,A+=c*(5*C),_=A>>>13,A&=8191,A+=b*(5*L),A+=v*(5*H),A+=S*(5*j),A+=I*(5*U),A+=M*(5*B),_+=A>>>13,A&=8191;var g=_;g+=s*B,g+=o*z,g+=f*P,g+=u*O,g+=c*T,_=g>>>13,g&=8191,g+=b*(5*C),g+=v*(5*L),g+=S*(5*H),g+=I*(5*j),g+=M*(5*U),_+=g>>>13,g&=8191;var R=_;R+=s*U,R+=o*B,R+=f*z,R+=u*P,R+=c*O,_=R>>>13,R&=8191,R+=b*T,R+=v*(5*C),R+=S*(5*L),R+=I*(5*H),R+=M*(5*j),_+=R>>>13,R&=8191;var k=_;k+=s*j,k+=o*U,k+=f*B,k+=u*z,k+=c*P,_=k>>>13,k&=8191,k+=b*O,k+=v*T,k+=S*(5*C),k+=I*(5*L),k+=M*(5*H),_+=k>>>13,k&=8191;var E=_;E+=s*H,E+=o*j,E+=f*U,E+=u*B,E+=c*z,_=E>>>13,E&=8191,E+=b*P,E+=v*O,E+=S*T,E+=I*(5*C),E+=M*(5*L),_+=E>>>13,E&=8191;var N=_;N+=s*L,N+=o*H,N+=f*j,N+=u*U,N+=c*B,_=N>>>13,N&=8191,N+=b*z,N+=v*P,N+=S*O,N+=I*T,N+=M*(5*C),_+=N>>>13,N&=8191;var F=_;F+=s*C,F+=o*L,F+=f*H,F+=u*j,F+=c*U,_=F>>>13,F&=8191,F+=b*B,F+=v*z,F+=S*P,F+=I*O,F+=M*T,_+=F>>>13,F&=8191,_=(_<<2)+_|0,_=_+y|0,y=_&8191,_=_>>>13,h+=_,s=y,o=h,f=x,u=A,c=g,b=R,v=k,S=E,I=N,M=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=u,this._h[4]=c,this._h[5]=b,this._h[6]=v,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});var sf=X1(),P8=eg(),po=Jt(),tg=Hn(),N8=rf();gi.KEY_LENGTH=32;gi.NONCE_LENGTH=12;gi.TAG_LENGTH=16;var rg=new Uint8Array(16),C8=function(){function r(e){if(this.nonceLength=gi.NONCE_LENGTH,this.tagLength=gi.TAG_LENGTH,e.length!==gi.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);sf.stream(this._key,s,o,4);var f=t.length+this.tagLength,u;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");u=n}else u=new Uint8Array(f);return sf.streamXOR(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),i),po.wipe(s),u},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(rg.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(rg.subarray(i.length%16));var o=new Uint8Array(8);n&&tg.writeUint64LE(n.length,o),s.update(o),tg.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),u=0;u{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});function O8(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}eu.isSerializableHash=O8});var og=Z(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Gr=ng(),L8=rf(),F8=Jt(),sg=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ag=og(),fg=Jt(),U8=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ag.hmac(this._hash,i,t);this._hmac=new ag.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});var af=Hn(),of=Jt();Li.DIGEST_LENGTH=32;Li.BLOCK_SIZE=64;var hg=function(){function r(){this.digestLength=Li.DIGEST_LENGTH,this.blockSize=Li.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){of.wipe(this._buffer),of.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ru(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ru(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){of.wipe(e.state),e.buffer&&of.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Li.SHA256=hg;var z8=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ru(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],u=e[3],c=e[4],b=e[5],v=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=af.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],O=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var P=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(O+r[I-7]|0)+(P+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&b^~c&v)|0)+(S+(z8[I]+r[I]|0)|0)|0,P=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=v,v=b,b=c,c=u+O|0,u=f,f=o,o=s,s=O+P|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=u,e[4]+=c,e[5]+=b,e[6]+=v,e[7]+=S,i+=64,n-=64}return i}function B8(r){var e=new hg;e.update(r);var t=e.digest();return e.clean(),t}Li.hash=B8});var gg=Z(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.sharedKey=Qe.generateKeyPair=Qe.generateKeyPairFromSeed=Qe.scalarMultBase=Qe.scalarMult=Qe.SHARED_KEY_LENGTH=Qe.SECRET_KEY_LENGTH=Qe.PUBLIC_KEY_LENGTH=void 0;var k8=Js(),K8=Jt();Qe.PUBLIC_KEY_LENGTH=32;Qe.SECRET_KEY_LENGTH=32;Qe.SHARED_KEY_LENGTH=32;function Wr(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function $8(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ff(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function cf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function bi(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function vo(r,e){bi(r,e,e)}function H8(r,e){let t=Wr();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)vo(t,t),i!==2&&i!==4&&bi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function nu(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=Wr(),s=Wr(),o=Wr(),f=Wr(),u=Wr(),c=Wr();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,$8(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;bo(n,s,M),bo(o,f,M),ff(u,n,o),cf(n,n,o),ff(o,s,f),cf(s,s,f),vo(f,u),vo(c,n),bi(n,o,n),bi(o,s,u),ff(u,n,o),cf(n,n,o),vo(s,n),cf(o,f,c),bi(n,o,j8),ff(n,n,f),bi(o,o,n),bi(n,f,c),bi(f,s,i),vo(s,u),bo(n,s,M),bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),v=i.subarray(16);H8(b,b),bi(v,v,b);let S=new Uint8Array(32);return V8(S,v),S}Qe.scalarMult=nu;function lg(r){return nu(r,dg)}Qe.scalarMultBase=lg;function pg(r){if(r.length!==Qe.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${Qe.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:lg(e),secretKey:e}}Qe.generateKeyPairFromSeed=pg;function G8(r){let e=(0,k8.randomBytes)(32,r),t=pg(e);return(0,K8.wipe)(e),t}Qe.generateKeyPair=G8;function W8(r,e,t=!1){if(r.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=nu(r,e);if(t){let n=0;for(let s=0;s{J8.exports={name:"elliptic",version:"6.6.0",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var Jr=Z((vg,su)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)m=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[d]|=m<<_&67108863,this.words[d+1]=m>>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);else if(p==="le")for(a=0,d=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8;else{var y=l.length-w;for(a=y%2===0?w+1:w;a=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8}this.strip()};function u(D,l,w,p){for(var a=0,d=Math.min(D.length,w),m=l;m=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=w)a++;a--,d=d/w|0;for(var m=l.length-p,_=m%a,y=Math.min(m,m-_)+p,h=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,d=0,m=0;m>>24-a&16777215,a+=2,a>=26&&(a-=26,m--),d!==0||m!==this.length-1?p=c[6-y.length]+y+p:p=y+p}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=b[l],x=v[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=c[h-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),d=p||Math.max(1,a);t(a<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var m=w==="le",_=new l(d),y,h,x=this.clone();if(m){for(h=0;!x.isZero();h++)y=x.andln(255),x.iushrn(8),_[h]=y;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var d=0,m=0;m>>26;for(;d!==0&&m>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;ml.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;p>0?(a=this,d=l):(a=l,d=this);for(var m=0,_=0;_>26,this.words[_]=w&67108863;for(;m!==0&&_>26,this.words[_]=w&67108863;if(m===0&&_>>26,A=y&67108863,g=Math.min(h,l.length-1),R=Math.max(0,h-D.length+1);R<=g;R++){var k=h-R|0;a=D.words[k]|0,d=l.words[R]|0,m=a*d+A,x+=m/67108864|0,A=m&67108863}w.words[h]=A|0,y=x|0}return y!==0?w.words[h]=y|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,d=w.words,m=p.words,_=0,y,h,x,A=a[0]|0,g=A&8191,R=A>>>13,k=a[1]|0,E=k&8191,N=k>>>13,F=a[2]|0,q=F&8191,K=F>>>13,J=a[3]|0,$=J&8191,V=J>>>13,ee=a[4]|0,G=ee&8191,Y=ee>>>13,_r=a[5]|0,ie=_r&8191,ne=_r>>>13,xr=a[6]|0,se=xr&8191,oe=xr>>>13,Er=a[7]|0,ae=Er&8191,fe=Er>>>13,Sr=a[8]|0,ce=Sr&8191,he=Sr>>>13,Ir=a[9]|0,ue=Ir&8191,de=Ir>>>13,Mr=d[0]|0,le=Mr&8191,pe=Mr>>>13,Ar=d[1]|0,ge=Ar&8191,be=Ar>>>13,Rr=d[2]|0,ve=Rr&8191,me=Rr>>>13,Tr=d[3]|0,ye=Tr&8191,we=Tr>>>13,Dr=d[4]|0,_e=Dr&8191,xe=Dr>>>13,Pr=d[5]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=d[6]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=d[7]|0,Ae=Cr&8191,Re=Cr>>>13,Or=d[8]|0,Te=Or&8191,De=Or>>>13,Lr=d[9]|0,Pe=Lr&8191,Ne=Lr>>>13;p.negative=l.negative^w.negative,p.length=19,y=Math.imul(g,le),h=Math.imul(g,pe),h=h+Math.imul(R,le)|0,x=Math.imul(R,pe);var nr=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,y=Math.imul(E,le),h=Math.imul(E,pe),h=h+Math.imul(N,le)|0,x=Math.imul(N,pe),y=y+Math.imul(g,ge)|0,h=h+Math.imul(g,be)|0,h=h+Math.imul(R,ge)|0,x=x+Math.imul(R,be)|0;var Be=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Be>>>26)|0,Be&=67108863,y=Math.imul(q,le),h=Math.imul(q,pe),h=h+Math.imul(K,le)|0,x=Math.imul(K,pe),y=y+Math.imul(E,ge)|0,h=h+Math.imul(E,be)|0,h=h+Math.imul(N,ge)|0,x=x+Math.imul(N,be)|0,y=y+Math.imul(g,ve)|0,h=h+Math.imul(g,me)|0,h=h+Math.imul(R,ve)|0,x=x+Math.imul(R,me)|0;var ke=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ke>>>26)|0,ke&=67108863,y=Math.imul($,le),h=Math.imul($,pe),h=h+Math.imul(V,le)|0,x=Math.imul(V,pe),y=y+Math.imul(q,ge)|0,h=h+Math.imul(q,be)|0,h=h+Math.imul(K,ge)|0,x=x+Math.imul(K,be)|0,y=y+Math.imul(E,ve)|0,h=h+Math.imul(E,me)|0,h=h+Math.imul(N,ve)|0,x=x+Math.imul(N,me)|0,y=y+Math.imul(g,ye)|0,h=h+Math.imul(g,we)|0,h=h+Math.imul(R,ye)|0,x=x+Math.imul(R,we)|0;var jt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(jt>>>26)|0,jt&=67108863,y=Math.imul(G,le),h=Math.imul(G,pe),h=h+Math.imul(Y,le)|0,x=Math.imul(Y,pe),y=y+Math.imul($,ge)|0,h=h+Math.imul($,be)|0,h=h+Math.imul(V,ge)|0,x=x+Math.imul(V,be)|0,y=y+Math.imul(q,ve)|0,h=h+Math.imul(q,me)|0,h=h+Math.imul(K,ve)|0,x=x+Math.imul(K,me)|0,y=y+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(N,ye)|0,x=x+Math.imul(N,we)|0,y=y+Math.imul(g,_e)|0,h=h+Math.imul(g,xe)|0,h=h+Math.imul(R,_e)|0,x=x+Math.imul(R,xe)|0;var Vt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,y=Math.imul(ie,le),h=Math.imul(ie,pe),h=h+Math.imul(ne,le)|0,x=Math.imul(ne,pe),y=y+Math.imul(G,ge)|0,h=h+Math.imul(G,be)|0,h=h+Math.imul(Y,ge)|0,x=x+Math.imul(Y,be)|0,y=y+Math.imul($,ve)|0,h=h+Math.imul($,me)|0,h=h+Math.imul(V,ve)|0,x=x+Math.imul(V,me)|0,y=y+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,x=x+Math.imul(K,we)|0,y=y+Math.imul(E,_e)|0,h=h+Math.imul(E,xe)|0,h=h+Math.imul(N,_e)|0,x=x+Math.imul(N,xe)|0,y=y+Math.imul(g,Ee)|0,h=h+Math.imul(g,Se)|0,h=h+Math.imul(R,Ee)|0,x=x+Math.imul(R,Se)|0;var $t=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,y=Math.imul(se,le),h=Math.imul(se,pe),h=h+Math.imul(oe,le)|0,x=Math.imul(oe,pe),y=y+Math.imul(ie,ge)|0,h=h+Math.imul(ie,be)|0,h=h+Math.imul(ne,ge)|0,x=x+Math.imul(ne,be)|0,y=y+Math.imul(G,ve)|0,h=h+Math.imul(G,me)|0,h=h+Math.imul(Y,ve)|0,x=x+Math.imul(Y,me)|0,y=y+Math.imul($,ye)|0,h=h+Math.imul($,we)|0,h=h+Math.imul(V,ye)|0,x=x+Math.imul(V,we)|0,y=y+Math.imul(q,_e)|0,h=h+Math.imul(q,xe)|0,h=h+Math.imul(K,_e)|0,x=x+Math.imul(K,xe)|0,y=y+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(N,Ee)|0,x=x+Math.imul(N,Se)|0,y=y+Math.imul(g,Ie)|0,h=h+Math.imul(g,Me)|0,h=h+Math.imul(R,Ie)|0,x=x+Math.imul(R,Me)|0;var Ht=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,y=Math.imul(ae,le),h=Math.imul(ae,pe),h=h+Math.imul(fe,le)|0,x=Math.imul(fe,pe),y=y+Math.imul(se,ge)|0,h=h+Math.imul(se,be)|0,h=h+Math.imul(oe,ge)|0,x=x+Math.imul(oe,be)|0,y=y+Math.imul(ie,ve)|0,h=h+Math.imul(ie,me)|0,h=h+Math.imul(ne,ve)|0,x=x+Math.imul(ne,me)|0,y=y+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(Y,ye)|0,x=x+Math.imul(Y,we)|0,y=y+Math.imul($,_e)|0,h=h+Math.imul($,xe)|0,h=h+Math.imul(V,_e)|0,x=x+Math.imul(V,xe)|0,y=y+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,x=x+Math.imul(K,Se)|0,y=y+Math.imul(E,Ie)|0,h=h+Math.imul(E,Me)|0,h=h+Math.imul(N,Ie)|0,x=x+Math.imul(N,Me)|0,y=y+Math.imul(g,Ae)|0,h=h+Math.imul(g,Re)|0,h=h+Math.imul(R,Ae)|0,x=x+Math.imul(R,Re)|0;var Gt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,y=Math.imul(ce,le),h=Math.imul(ce,pe),h=h+Math.imul(he,le)|0,x=Math.imul(he,pe),y=y+Math.imul(ae,ge)|0,h=h+Math.imul(ae,be)|0,h=h+Math.imul(fe,ge)|0,x=x+Math.imul(fe,be)|0,y=y+Math.imul(se,ve)|0,h=h+Math.imul(se,me)|0,h=h+Math.imul(oe,ve)|0,x=x+Math.imul(oe,me)|0,y=y+Math.imul(ie,ye)|0,h=h+Math.imul(ie,we)|0,h=h+Math.imul(ne,ye)|0,x=x+Math.imul(ne,we)|0,y=y+Math.imul(G,_e)|0,h=h+Math.imul(G,xe)|0,h=h+Math.imul(Y,_e)|0,x=x+Math.imul(Y,xe)|0,y=y+Math.imul($,Ee)|0,h=h+Math.imul($,Se)|0,h=h+Math.imul(V,Ee)|0,x=x+Math.imul(V,Se)|0,y=y+Math.imul(q,Ie)|0,h=h+Math.imul(q,Me)|0,h=h+Math.imul(K,Ie)|0,x=x+Math.imul(K,Me)|0,y=y+Math.imul(E,Ae)|0,h=h+Math.imul(E,Re)|0,h=h+Math.imul(N,Ae)|0,x=x+Math.imul(N,Re)|0,y=y+Math.imul(g,Te)|0,h=h+Math.imul(g,De)|0,h=h+Math.imul(R,Te)|0,x=x+Math.imul(R,De)|0;var Qi=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,y=Math.imul(ue,le),h=Math.imul(ue,pe),h=h+Math.imul(de,le)|0,x=Math.imul(de,pe),y=y+Math.imul(ce,ge)|0,h=h+Math.imul(ce,be)|0,h=h+Math.imul(he,ge)|0,x=x+Math.imul(he,be)|0,y=y+Math.imul(ae,ve)|0,h=h+Math.imul(ae,me)|0,h=h+Math.imul(fe,ve)|0,x=x+Math.imul(fe,me)|0,y=y+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,x=x+Math.imul(oe,we)|0,y=y+Math.imul(ie,_e)|0,h=h+Math.imul(ie,xe)|0,h=h+Math.imul(ne,_e)|0,x=x+Math.imul(ne,xe)|0,y=y+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(Y,Ee)|0,x=x+Math.imul(Y,Se)|0,y=y+Math.imul($,Ie)|0,h=h+Math.imul($,Me)|0,h=h+Math.imul(V,Ie)|0,x=x+Math.imul(V,Me)|0,y=y+Math.imul(q,Ae)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(K,Ae)|0,x=x+Math.imul(K,Re)|0,y=y+Math.imul(E,Te)|0,h=h+Math.imul(E,De)|0,h=h+Math.imul(N,Te)|0,x=x+Math.imul(N,De)|0,y=y+Math.imul(g,Pe)|0,h=h+Math.imul(g,Ne)|0,h=h+Math.imul(R,Pe)|0,x=x+Math.imul(R,Ne)|0;var en=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(en>>>26)|0,en&=67108863,y=Math.imul(ue,ge),h=Math.imul(ue,be),h=h+Math.imul(de,ge)|0,x=Math.imul(de,be),y=y+Math.imul(ce,ve)|0,h=h+Math.imul(ce,me)|0,h=h+Math.imul(he,ve)|0,x=x+Math.imul(he,me)|0,y=y+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(fe,ye)|0,x=x+Math.imul(fe,we)|0,y=y+Math.imul(se,_e)|0,h=h+Math.imul(se,xe)|0,h=h+Math.imul(oe,_e)|0,x=x+Math.imul(oe,xe)|0,y=y+Math.imul(ie,Ee)|0,h=h+Math.imul(ie,Se)|0,h=h+Math.imul(ne,Ee)|0,x=x+Math.imul(ne,Se)|0,y=y+Math.imul(G,Ie)|0,h=h+Math.imul(G,Me)|0,h=h+Math.imul(Y,Ie)|0,x=x+Math.imul(Y,Me)|0,y=y+Math.imul($,Ae)|0,h=h+Math.imul($,Re)|0,h=h+Math.imul(V,Ae)|0,x=x+Math.imul(V,Re)|0,y=y+Math.imul(q,Te)|0,h=h+Math.imul(q,De)|0,h=h+Math.imul(K,Te)|0,x=x+Math.imul(K,De)|0,y=y+Math.imul(E,Pe)|0,h=h+Math.imul(E,Ne)|0,h=h+Math.imul(N,Pe)|0,x=x+Math.imul(N,Ne)|0;var tn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(tn>>>26)|0,tn&=67108863,y=Math.imul(ue,ve),h=Math.imul(ue,me),h=h+Math.imul(de,ve)|0,x=Math.imul(de,me),y=y+Math.imul(ce,ye)|0,h=h+Math.imul(ce,we)|0,h=h+Math.imul(he,ye)|0,x=x+Math.imul(he,we)|0,y=y+Math.imul(ae,_e)|0,h=h+Math.imul(ae,xe)|0,h=h+Math.imul(fe,_e)|0,x=x+Math.imul(fe,xe)|0,y=y+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,x=x+Math.imul(oe,Se)|0,y=y+Math.imul(ie,Ie)|0,h=h+Math.imul(ie,Me)|0,h=h+Math.imul(ne,Ie)|0,x=x+Math.imul(ne,Me)|0,y=y+Math.imul(G,Ae)|0,h=h+Math.imul(G,Re)|0,h=h+Math.imul(Y,Ae)|0,x=x+Math.imul(Y,Re)|0,y=y+Math.imul($,Te)|0,h=h+Math.imul($,De)|0,h=h+Math.imul(V,Te)|0,x=x+Math.imul(V,De)|0,y=y+Math.imul(q,Pe)|0,h=h+Math.imul(q,Ne)|0,h=h+Math.imul(K,Pe)|0,x=x+Math.imul(K,Ne)|0;var rn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(rn>>>26)|0,rn&=67108863,y=Math.imul(ue,ye),h=Math.imul(ue,we),h=h+Math.imul(de,ye)|0,x=Math.imul(de,we),y=y+Math.imul(ce,_e)|0,h=h+Math.imul(ce,xe)|0,h=h+Math.imul(he,_e)|0,x=x+Math.imul(he,xe)|0,y=y+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(fe,Ee)|0,x=x+Math.imul(fe,Se)|0,y=y+Math.imul(se,Ie)|0,h=h+Math.imul(se,Me)|0,h=h+Math.imul(oe,Ie)|0,x=x+Math.imul(oe,Me)|0,y=y+Math.imul(ie,Ae)|0,h=h+Math.imul(ie,Re)|0,h=h+Math.imul(ne,Ae)|0,x=x+Math.imul(ne,Re)|0,y=y+Math.imul(G,Te)|0,h=h+Math.imul(G,De)|0,h=h+Math.imul(Y,Te)|0,x=x+Math.imul(Y,De)|0,y=y+Math.imul($,Pe)|0,h=h+Math.imul($,Ne)|0,h=h+Math.imul(V,Pe)|0,x=x+Math.imul(V,Ne)|0;var nn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nn>>>26)|0,nn&=67108863,y=Math.imul(ue,_e),h=Math.imul(ue,xe),h=h+Math.imul(de,_e)|0,x=Math.imul(de,xe),y=y+Math.imul(ce,Ee)|0,h=h+Math.imul(ce,Se)|0,h=h+Math.imul(he,Ee)|0,x=x+Math.imul(he,Se)|0,y=y+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Me)|0,h=h+Math.imul(fe,Ie)|0,x=x+Math.imul(fe,Me)|0,y=y+Math.imul(se,Ae)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(oe,Ae)|0,x=x+Math.imul(oe,Re)|0,y=y+Math.imul(ie,Te)|0,h=h+Math.imul(ie,De)|0,h=h+Math.imul(ne,Te)|0,x=x+Math.imul(ne,De)|0,y=y+Math.imul(G,Pe)|0,h=h+Math.imul(G,Ne)|0,h=h+Math.imul(Y,Pe)|0,x=x+Math.imul(Y,Ne)|0;var sn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(sn>>>26)|0,sn&=67108863,y=Math.imul(ue,Ee),h=Math.imul(ue,Se),h=h+Math.imul(de,Ee)|0,x=Math.imul(de,Se),y=y+Math.imul(ce,Ie)|0,h=h+Math.imul(ce,Me)|0,h=h+Math.imul(he,Ie)|0,x=x+Math.imul(he,Me)|0,y=y+Math.imul(ae,Ae)|0,h=h+Math.imul(ae,Re)|0,h=h+Math.imul(fe,Ae)|0,x=x+Math.imul(fe,Re)|0,y=y+Math.imul(se,Te)|0,h=h+Math.imul(se,De)|0,h=h+Math.imul(oe,Te)|0,x=x+Math.imul(oe,De)|0,y=y+Math.imul(ie,Pe)|0,h=h+Math.imul(ie,Ne)|0,h=h+Math.imul(ne,Pe)|0,x=x+Math.imul(ne,Ne)|0;var on=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(on>>>26)|0,on&=67108863,y=Math.imul(ue,Ie),h=Math.imul(ue,Me),h=h+Math.imul(de,Ie)|0,x=Math.imul(de,Me),y=y+Math.imul(ce,Ae)|0,h=h+Math.imul(ce,Re)|0,h=h+Math.imul(he,Ae)|0,x=x+Math.imul(he,Re)|0,y=y+Math.imul(ae,Te)|0,h=h+Math.imul(ae,De)|0,h=h+Math.imul(fe,Te)|0,x=x+Math.imul(fe,De)|0,y=y+Math.imul(se,Pe)|0,h=h+Math.imul(se,Ne)|0,h=h+Math.imul(oe,Pe)|0,x=x+Math.imul(oe,Ne)|0;var an=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(an>>>26)|0,an&=67108863,y=Math.imul(ue,Ae),h=Math.imul(ue,Re),h=h+Math.imul(de,Ae)|0,x=Math.imul(de,Re),y=y+Math.imul(ce,Te)|0,h=h+Math.imul(ce,De)|0,h=h+Math.imul(he,Te)|0,x=x+Math.imul(he,De)|0,y=y+Math.imul(ae,Pe)|0,h=h+Math.imul(ae,Ne)|0,h=h+Math.imul(fe,Pe)|0,x=x+Math.imul(fe,Ne)|0;var fn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(fn>>>26)|0,fn&=67108863,y=Math.imul(ue,Te),h=Math.imul(ue,De),h=h+Math.imul(de,Te)|0,x=Math.imul(de,De),y=y+Math.imul(ce,Pe)|0,h=h+Math.imul(ce,Ne)|0,h=h+Math.imul(he,Pe)|0,x=x+Math.imul(he,Ne)|0;var cn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(cn>>>26)|0,cn&=67108863,y=Math.imul(ue,Pe),h=Math.imul(ue,Ne),h=h+Math.imul(de,Pe)|0,x=Math.imul(de,Ne);var hn=(_+y|0)+((h&8191)<<13)|0;return _=(x+(h>>>13)|0)+(hn>>>26)|0,hn&=67108863,m[0]=nr,m[1]=Be,m[2]=ke,m[3]=jt,m[4]=Vt,m[5]=$t,m[6]=Ht,m[7]=Gt,m[8]=Qi,m[9]=en,m[10]=tn,m[11]=rn,m[12]=nn,m[13]=sn,m[14]=on,m[15]=an,m[16]=fn,m[17]=cn,m[18]=hn,_!==0&&(m[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,d=0;d>>26)|0,a+=m>>>26,m&=67108863}w.words[d]=_,p=m,m=a}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(D,l,w){var p=new P;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=O(this,l,w),p};function P(D,l){this.x=D,this.y=l}P.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},P.prototype.permute=function(l,w,p,a,d,m){for(var _=0;_>>1)d++;return 1<>>13,p[2*m+1]=d&8191,d=d>>>13;for(m=2*w;m>=26,w+=a/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,d;if(w!==0){var m=0;for(d=0;d>>26-w}m&&(this.words[d]=m,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var a;w?a=(w-w%26)/26:a=0;var d=l%26,m=Math.min((l-d)/26,this.length),_=67108863^67108863>>>d<m)for(this.length-=m,h=0;h=0&&(x!==0||h>=a);h--){var A=this.words[h]|0;this.words[h]=x<<26-d|A>>>d,x=A&_}return y&&x!==0&&(y.words[y.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(y/67108864|0),this.words[d+p]=m&67108863}for(;d>26,this.words[d+p]=m&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,d=0;d>26,this.words[d]=m&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),d=l,m=d.words[d.length-1]|0,_=this._countBits(m);p=26-_,p!==0&&(d=d.ushln(p),a.iushln(p),m=d.words[d.length-1]|0);var y=a.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=y+1,h.words=new Array(h.length);for(var x=0;x=0;g--){var R=(a.words[d.length+g]|0)*67108864+(a.words[d.length+g-1]|0);for(R=Math.min(R/m|0,67108863),a._ishlnsubmul(d,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(d,1,g),a.isZero()||(a.negative^=1);h&&(h.words[g]=R)}return h&&h.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:h||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,d,m;return this.negative!==0&&l.negative===0?(m=this.neg().divmod(l,w),w!=="mod"&&(a=m.div.neg()),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:a,mod:d}):this.negative===0&&l.negative!==0?(m=this.divmod(l.neg(),w),w!=="mod"&&(a=m.div.neg()),{div:a,mod:m.mod}):this.negative&l.negative?(m=this.neg().divmod(l.neg(),w),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:m.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),d=l.andln(1),m=p.cmp(a);return m<0||d===1&&m===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=new n(0),_=new n(1),y=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++y;for(var h=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(h),d.isub(x)),a.iushrn(1),d.iushrn(1);for(var R=0,k=1;!(p.words[0]&k)&&R<26;++R,k<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(m.isOdd()||_.isOdd())&&(m.iadd(h),_.isub(x)),m.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(m),d.isub(_)):(p.isub(w),m.isub(a),_.isub(d))}return{a:m,b:_,gcd:p.iushln(y)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,y=1;!(w.words[0]&y)&&_<26;++_,y<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(m),a.iushrn(1);for(var h=0,x=1;!(p.words[0]&x)&&h<26;++h,x<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(m),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(d)):(p.isub(w),d.isub(a))}var A;return w.cmpn(1)===0?A=a:A=d,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var m=w;w=p,p=m}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[m]=_}return d!==0&&(this.words[m]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,d=l.words[p]|0;if(a!==d){ad&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new C(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var z={k256:null,p224:null,p192:null,p25519:null};function B(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}B.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},B.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},B.prototype.split=function(l,w){l.iushrn(this.n,0,w)},B.prototype.imulK=function(l){return l.imul(this.k)};function U(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(U,B),U.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),d=0;d>>22,m=_}m>>>=22,l.words[d-10]=m,m===0&&l.length>10?l.length-=10:l.length-=9},U.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(z[l])return z[l];var w;if(l==="k256")w=new U;else if(l==="p224")w=new j;else if(l==="p192")w=new H;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return z[l]=w,w};function C(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}C.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},C.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},C.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},C.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},C.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},C.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},C.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},C.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},C.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},C.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},C.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},C.prototype.isqr=function(l){return this.imul(l,l.clone())},C.prototype.sqr=function(l){return this.mul(l,l)},C.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);t(!a.isZero());var m=new n(1).toRed(this),_=m.redNeg(),y=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,y).cmp(_)!==0;)h.redIAdd(_);for(var x=this.pow(h,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=d;g.cmp(m)!==0;){for(var k=g,E=0;k.cmp(m)!==0;E++)k=k.redSqr();t(E=0;d--){for(var x=w.words[d],A=h-1;A>=0;A--){var g=x>>A&1;if(m!==a[0]&&(m=this.sqr(m)),g===0&&_===0){y=0;continue}_<<=1,_|=g,y++,!(y!==p&&(d!==0||A!==0))&&(m=this.mul(m,a[_]),y=0,_=0)}h=26}return m},C.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},C.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(D){C.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,C),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof su>"u"||su,vg)});var ou=Z(wg=>{"use strict";var hf=wg;function Y8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}hf.toArray=Y8;function mg(r){return r.length===1?"0"+r:r}hf.zero2=mg;function yg(r){for(var e="",t=0;t{"use strict";var dr=_g,X8=Jr(),Z8=Pi(),uf=ou();dr.assert=Z8;dr.toArray=uf.toArray;dr.zero2=uf.zero2;dr.toHex=uf.toHex;dr.encode=uf.encode;function Q8(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-u:f=u,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}dr.getNAF=Q8;function e4(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var u;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?u=-o:u=o):u=0,t[0].push(u);var c;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?c=-f:c=f):c=0,t[1].push(c),2*i===u+1&&(i=1-i),2*n===c+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}dr.getJSF=e4;function t4(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}dr.cachedProperty=t4;function r4(r){return typeof r=="string"?dr.toArray(r,"hex"):r}dr.parseBytes=r4;function i4(r){return new X8(r,"hex","le")}dr.intFromLE=i4});var hu=Z((KR,cu)=>{var au;cu.exports=function(e){return au||(au=new Fi(null)),au.generate(e)};function Fi(r){this.rand=r}cu.exports.Rand=Fi;Fi.prototype.generate=function(e){return this._rand(e)};Fi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var En=Jr(),mo=Bt(),df=mo.getNAF,n4=mo.getJSF,lf=mo.assert;function qi(r,e){this.type=r,this.p=new En(e.p,16),this.red=e.prime?En.red(e.prime):En.mont(this.p),this.zero=new En(0).toRed(this.red),this.one=new En(1).toRed(this.red),this.two=new En(2).toRed(this.red),this.n=e.n&&new En(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}xg.exports=qi;qi.prototype.point=function(){throw new Error("Not implemented")};qi.prototype.validate=function(){throw new Error("Not implemented")};qi.prototype._fixedNafMul=function(e,t){lf(e.precomputed);var i=e._getDoubles(),n=df(t,1,this._bitLength),s=(1<=f;c--)u=(u<<1)+n[c];o.push(u)}for(var b=this.jpoint(null,null,null),v=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;u--){for(var c=0;u>=0&&o[u]===0;u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var b=o[u];lf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};qi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,c=0,b,v,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){u[M]=df(i[M],o[M],this._bitLength),u[T]=df(i[T],o[T],this._bitLength),c=Math.max(u[M].length,c),c=Math.max(u[T].length,c);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],z=n4(i[M],i[T]);for(c=Math.max(z[0].length,c),u[M]=new Array(c),u[T]=new Array(c),v=0;v=0;b--){for(var L=0;b>=0;){var C=!0;for(v=0;v=0&&L++,j=j.dblp(L),b<0)break;for(v=0;v0?S=f[v][W-1>>1]:W<0&&(S=f[v][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Qt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var s4=Bt(),et=Jr(),uu=co(),ps=yo(),o4=s4.assert;function er(r){ps.call(this,"short",r),this.a=new et(r.a,16).toRed(this.red),this.b=new et(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}uu(er,ps);Eg.exports=er;er.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new et(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new et(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],o4(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new et(f.a,16),b:new et(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};er.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:et.mont(e),i=new et(2).toRed(t).redInvm(),n=i.redNeg(),s=new et(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};er.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new et(1),o=new et(0),f=new et(0),u=new et(1),c,b,v,S,I,M,T,O=0,P,z;i.cmpn(0)!==0;){var B=n.div(i);P=n.sub(B.mul(i)),z=f.sub(B.mul(s));var U=u.sub(B.mul(o));if(!v&&P.cmp(t)<0)c=T.neg(),b=s,v=P.neg(),S=z;else if(v&&++O===2)break;T=P,n=i,i=P,f=s,s=z,u=o,o=U}I=P.neg(),M=z;var j=v.sqr().add(S.sqr()),H=I.sqr().add(M.sqr());return H.cmp(j)>=0&&(I=c,M=b),v.negative&&(v=v.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:v,b:S},{a:I,b:M}]};er.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),c=s.mul(i.b),b=o.mul(n.b),v=e.sub(f).sub(u),S=c.add(b).neg();return{k1:v,k2:S}};er.prototype.pointFromX=function(e,t){e=new et(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};er.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};er.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ct.prototype.isInfinity=function(){return this.inf};ct.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ct.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ct.prototype.getX=function(){return this.x.fromRed()};ct.prototype.getY=function(){return this.y.fromRed()};ct.prototype.mul=function(e){return e=new et(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ct.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ct.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ct.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ct.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ct.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function bt(r,e,t,i){ps.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new et(0)):(this.x=new et(e,16),this.y=new et(t,16),this.z=new et(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}uu(bt,ps.BasePoint);er.prototype.jpoint=function(e,t,i){return new bt(this,e,t,i)};bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};bt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};bt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),c=o.redSub(f);if(u.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=u.redSqr(),v=b.redMul(u),S=n.redMul(b),I=c.redSqr().redIAdd(v).redISub(S).redISub(S),M=c.redMul(S.redISub(I)).redISub(o.redMul(v)),T=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(I,M,T)};bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),b=c.redMul(f),v=i.redMul(c),S=u.redSqr().redIAdd(b).redISub(v).redISub(v),I=u.redMul(v.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};bt.prototype.inspect=function(){return this.isInfinity()?"":""};bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Ag=Z(($R,Mg)=>{"use strict";var gs=Jr(),Ig=co(),pf=yo(),a4=Bt();function bs(r){pf.call(this,"mont",r),this.a=new gs(r.a,16).toRed(this.red),this.b=new gs(r.b,16).toRed(this.red),this.i4=new gs(4).toRed(this.red).redInvm(),this.two=new gs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Ig(bs,pf);Mg.exports=bs;bs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function ht(r,e,t){pf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new gs(e,16),this.z=new gs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Ig(ht,pf.BasePoint);bs.prototype.decodePoint=function(e,t){return this.point(a4.toArray(e,t),1)};bs.prototype.point=function(e,t){return new ht(this,e,t)};bs.prototype.pointFromJSON=function(e){return ht.fromJSON(this,e)};ht.prototype.precompute=function(){};ht.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};ht.fromJSON=function(e,t){return new ht(e,t[0],t[1]||e.one)};ht.prototype.inspect=function(){return this.isInfinity()?"":""};ht.prototype.isInfinity=function(){return this.z.cmpn(0)===0};ht.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};ht.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),u=s.redMul(n),c=t.z.redMul(f.redAdd(u).redSqr()),b=t.x.redMul(f.redISub(u).redSqr());return this.curve.point(c,b)};ht.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};ht.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};ht.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};ht.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Dg=Z((HR,Tg)=>{"use strict";var f4=Bt(),vi=Jr(),Rg=co(),gf=yo(),c4=f4.assert;function Yr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,gf.call(this,"edwards",r),this.a=new vi(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new vi(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new vi(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c4(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Rg(Yr,gf);Tg.exports=Yr;Yr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Yr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Yr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Yr.prototype.pointFromX=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=f.fromRed().isOdd();return(t&&!u||!t&&u)&&(f=f.redNeg()),this.point(e,f)};Yr.prototype.pointFromY=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};Yr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ge(r,e,t,i,n){gf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new vi(e,16),this.y=new vi(t,16),this.z=i?new vi(i,16):this.curve.one,this.t=n&&new vi(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Rg(Ge,gf.BasePoint);Yr.prototype.pointFromJSON=function(e){return Ge.fromJSON(this,e)};Yr.prototype.point=function(e,t,i,n){return new Ge(this,e,t,i,n)};Ge.fromJSON=function(e,t){return new Ge(e,t[0],t[1],t[2])};Ge.prototype.inspect=function(){return this.isInfinity()?"":""};Ge.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ge.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),u=n.redSub(t),c=s.redMul(f),b=o.redMul(u),v=s.redMul(u),S=f.redMul(o);return this.curve.point(c,b,S,v)};Ge.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,u,c;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(u=this.z.redSqr(),c=b.redSub(u).redISub(u),n=e.redSub(t).redISub(i).redMul(c),s=b.redMul(f.redSub(i)),o=b.redMul(c))}else f=t.redAdd(i),u=this.curve._mulC(this.z).redSqr(),c=f.redSub(u).redSub(u),n=this.curve._mulC(e.redISub(f)).redMul(c),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(c);return this.curve.point(n,s,o)};Ge.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ge.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),u=s.redAdd(n),c=i.redAdd(t),b=o.redMul(f),v=u.redMul(c),S=o.redMul(c),I=f.redMul(u);return this.curve.point(b,v,I,S)};Ge.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),u=i.redAdd(o),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(c),v,S;return this.curve.twisted?(v=t.redMul(u).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(u)):(v=t.redMul(u).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(u)),this.curve.point(b,v,S)};Ge.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ge.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ge.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ge.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ge.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ge.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ge.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ge.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ge.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ge.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ge.prototype.toP=Ge.prototype.normalize;Ge.prototype.mixedAdd=Ge.prototype.add});var du=Z(Pg=>{"use strict";var bf=Pg;bf.base=yo();bf.short=Sg();bf.mont=Ag();bf.edwards=Dg()});var Cg=Z((WR,Ng)=>{Ng.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var vf=Z(Fg=>{"use strict";var pu=Fg,Ui=lo(),lu=du(),h4=Bt(),Og=h4.assert;function Lg(r){r.type==="short"?this.curve=new lu.short(r):r.type==="edwards"?this.curve=new lu.edwards(r):this.curve=new lu.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,Og(this.g.validate(),"Invalid curve"),Og(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}pu.PresetCurve=Lg;function zi(r,e){Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,get:function(){var t=new Lg(e);return Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,value:t}),t}})}zi("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Ui.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});zi("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Ui.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});zi("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Ui.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});zi("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Ui.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]});zi("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Ui.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]});zi("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ui.sha256,gRed:!1,g:["9"]});zi("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ui.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var gu;try{gu=Cg()}catch{gu=void 0}zi("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Ui.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",gu]})});var zg=Z((YR,Ug)=>{"use strict";var u4=lo(),Sn=ou(),qg=Pi();function Bi(r){if(!(this instanceof Bi))return new Bi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Sn.toArray(r.entropy,r.entropyEnc||"hex"),t=Sn.toArray(r.nonce,r.nonceEnc||"hex"),i=Sn.toArray(r.pers,r.persEnc||"hex");qg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}Ug.exports=Bi;Bi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Bi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Sn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var d4=Jr(),l4=Bt(),bu=l4.assert;function St(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}Bg.exports=St;St.fromPublic=function(e,t,i){return t instanceof St?t:new St(e,{pub:t,pubEnc:i})};St.fromPrivate=function(e,t,i){return t instanceof St?t:new St(e,{priv:t,privEnc:i})};St.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};St.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};St.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};St.prototype._importPrivate=function(e,t){this.priv=new d4(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};St.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?bu(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&bu(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};St.prototype.derive=function(e){return e.validate()||bu(e.validate(),"public point not validated"),e.mul(this.priv).getX()};St.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};St.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)};St.prototype.inspect=function(){return""}});var Vg=Z((ZR,jg)=>{"use strict";var mf=Jr(),yu=Bt(),p4=yu.assert;function yf(r,e){if(r instanceof yf)return r;this._importDER(r,e)||(p4(r.r&&r.s,"Signature without r or s"),this.r=new mf(r.r,16),this.s=new mf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}jg.exports=yf;function g4(){this.place=0}function vu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Kg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}yf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Kg(t),i=Kg(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];mu(n,t.length),n=n.concat(t),n.push(2),mu(n,i.length);var s=n.concat(i),o=[48];return mu(o,s.length),o=o.concat(s),yu.encode(o,e)}});var Wg=Z((QR,Gg)=>{"use strict";var mi=Jr(),$g=zg(),b4=Bt(),wu=vf(),v4=hu(),Hg=b4.assert,_u=kg(),wf=Vg();function tr(r){if(!(this instanceof tr))return new tr(r);typeof r=="string"&&(Hg(Object.prototype.hasOwnProperty.call(wu,r),"Unknown curve "+r),r=wu[r]),r instanceof wu.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}Gg.exports=tr;tr.prototype.keyPair=function(e){return new _u(this,e)};tr.prototype.keyFromPrivate=function(e,t){return _u.fromPrivate(this,e,t)};tr.prototype.keyFromPublic=function(e,t){return _u.fromPublic(this,e,t)};tr.prototype.genKeyPair=function(e){e||(e={});for(var t=new $g({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new mi(2));;){var s=new mi(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};tr.prototype._truncateToN=function(e,t,i){var n;if(mi.isBN(e)||typeof e=="number")e=new mi(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new mi(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new mi(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};tr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength);for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new $g({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new mi(1)),b=0;;b++){var v=n.k?n.k(b):new mi(u.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(c)>=0)){var S=this.g.mul(v);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=v.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new wf({r:M,s:T,recoveryParam:O})}}}}}};tr.prototype.verify=function(e,t,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),t=new wf(t,"hex");var o=t.r,f=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),c=u.mul(e).umod(this.n),b=u.mul(o).umod(this.n),v;return this.curve._maxwellTrick?(v=this.g.jmulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.eqXToP(o)):(v=this.g.mulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.getX().umod(this.n).cmp(o)===0)};tr.prototype.recoverPubKey=function(r,e,t,i){Hg((3&t)===t,"The recovery param is more than two bits"),e=new wf(e,i);var n=this.n,s=new mi(r),o=e.r,f=e.s,u=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var b=e.r.invm(n),v=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(v,o,S)};tr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new wf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Zg=Z((eT,Xg)=>{"use strict";var wo=Bt(),Yg=wo.assert,Jg=wo.parseBytes,vs=wo.cachedProperty;function ut(r,e){this.eddsa=r,this._secret=Jg(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Jg(e.pub)}ut.fromPublic=function(e,t){return t instanceof ut?t:new ut(e,{pub:t})};ut.fromSecret=function(e,t){return t instanceof ut?t:new ut(e,{secret:t})};ut.prototype.secret=function(){return this._secret};vs(ut,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});vs(ut,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});vs(ut,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});vs(ut,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});vs(ut,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});vs(ut,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});ut.prototype.sign=function(e){return Yg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};ut.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};ut.prototype.getSecret=function(e){return Yg(this._secret,"KeyPair is public only"),wo.encode(this.secret(),e)};ut.prototype.getPublic=function(e){return wo.encode(this.pubBytes(),e)};Xg.exports=ut});var tb=Z((tT,eb)=>{"use strict";var m4=Jr(),_f=Bt(),Qg=_f.assert,xf=_f.cachedProperty,y4=_f.parseBytes;function In(r,e){this.eddsa=r,typeof e!="object"&&(e=y4(e)),Array.isArray(e)&&(Qg(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Qg(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof m4&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}xf(In,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});xf(In,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});xf(In,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});xf(In,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});In.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};In.prototype.toHex=function(){return _f.encode(this.toBytes(),"hex").toUpperCase()};eb.exports=In});var ob=Z((rT,sb)=>{"use strict";var w4=lo(),_4=vf(),ms=Bt(),x4=ms.assert,ib=ms.parseBytes,nb=Zg(),rb=tb();function Lt(r){if(x4(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Lt))return new Lt(r);r=_4[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=w4.sha512}sb.exports=Lt;Lt.prototype.sign=function(e,t){e=ib(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),u=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})};Lt.prototype.verify=function(e,t,i){if(e=ib(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Lt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Mn=ab;Mn.version=bg().version;Mn.utils=Bt();Mn.rand=hu();Mn.curve=du();Mn.curves=vf();Mn.ec=Wg();Mn.eddsa=ob()});var vv=Z($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isBrowserCryptoAvailable=$i.getSubtleCrypto=$i.getBrowerCrypto=void 0;function Wu(){return window?.crypto||window?.msCrypto||{}}$i.getBrowerCrypto=Wu;function bv(){let r=Wu();return r.subtle||r.webkitSubtle}$i.getSubtleCrypto=bv;function U_(){return!!Wu()&&!!bv()}$i.isBrowserCryptoAvailable=U_});var wv=Z(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.isBrowser=Hi.isNode=Hi.isReactNative=void 0;function mv(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Hi.isReactNative=mv;function yv(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Hi.isNode=yv;function z_(){return!mv()&&!yv()}Hi.isBrowser=z_});var Ju=Z(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});var _v=(zn(),qs(Un));_v.__exportStar(vv(),Lf);_v.__exportStar(wv(),Lf)});var Rv=Z((UT,Av)=>{"use strict";Av.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var dm=Z((qo,Ns)=>{var X_=200,cd="__lodash_hash_undefined__",Jf=1,jv=2,Vv=9007199254740991,Kf="[object Arguments]",rd="[object Array]",Z_="[object AsyncFunction]",$v="[object Boolean]",Hv="[object Date]",Gv="[object Error]",Wv="[object Function]",Q_="[object GeneratorFunction]",jf="[object Map]",Jv="[object Number]",ex="[object Null]",Ps="[object Object]",Nv="[object Promise]",tx="[object Proxy]",Yv="[object RegExp]",Vf="[object Set]",Xv="[object String]",rx="[object Symbol]",ix="[object Undefined]",id="[object WeakMap]",Zv="[object ArrayBuffer]",$f="[object DataView]",nx="[object Float32Array]",sx="[object Float64Array]",ox="[object Int8Array]",ax="[object Int16Array]",fx="[object Int32Array]",cx="[object Uint8Array]",hx="[object Uint8ClampedArray]",ux="[object Uint16Array]",dx="[object Uint32Array]",lx=/[\\^$.*+?()[\]{}|]/g,px=/^\[object .+?Constructor\]$/,gx=/^(?:0|[1-9]\d*)$/,Je={};Je[nx]=Je[sx]=Je[ox]=Je[ax]=Je[fx]=Je[cx]=Je[hx]=Je[ux]=Je[dx]=!0;Je[Kf]=Je[rd]=Je[Zv]=Je[$v]=Je[$f]=Je[Hv]=Je[Gv]=Je[Wv]=Je[jf]=Je[Jv]=Je[Ps]=Je[Yv]=Je[Vf]=Je[Xv]=Je[id]=!1;var Qv=typeof window=="object"&&window&&window.Object===Object&&window,bx=typeof self=="object"&&self&&self.Object===Object&&self,xi=Qv||bx||Function("return this")(),em=typeof qo=="object"&&qo&&!qo.nodeType&&qo,Cv=em&&typeof Ns=="object"&&Ns&&!Ns.nodeType&&Ns,tm=Cv&&Cv.exports===em,Qu=tm&&Qv.process,Ov=function(){try{return Qu&&Qu.binding&&Qu.binding("util")}catch{}}(),Lv=Ov&&Ov.isTypedArray;function vx(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function Gx(r,e){var t=this.__data__,i=Xf(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}Ei.prototype.clear=jx;Ei.prototype.delete=Vx;Ei.prototype.get=$x;Ei.prototype.has=Hx;Ei.prototype.set=Gx;function On(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var c=s.get(r);if(c&&s.get(e))return c==e;var b=-1,v=!0,S=t&jv?new Gf:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=Vv}function hm(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function Bo(r){return r!=null&&typeof r=="object"}var um=Lv?_x(Lv):hE;function SE(r){return xE(r)?oE(r):uE(r)}function IE(){return[]}function ME(){return!1}Ns.exports=EE});var Si=qe(un());var Pl=qe(un()),sa=qe(jn());var sr=class{};var mc=class extends sr{constructor(e){super()}},Dl=sa.FIVE_SECONDS,dn={pulse:"heartbeat_pulse"},na=class r extends mc{constructor(e){super(e),this.events=new Pl.EventEmitter,this.interval=Dl,this.interval=e?.interval||Dl}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,sa.toMiliseconds)(this.interval))}pulse(){this.events.emit(dn.pulse)}};var r2=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,i2=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n2=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function s2(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){o2(r);return}return e}function o2(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Bs(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!n2.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(r2.test(r)||i2.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,s2)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function a2(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ot(r,...e){try{return a2(r(...e))}catch(t){return Promise.reject(t)}}function f2(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function c2(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ks(r){if(f2(r))return String(r);if(c2(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ks(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Nl(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var yc="base64:";function Cl(r){if(typeof r=="string")return r;Nl();let e=Buffer.from(r).toString("base64");return yc+e}function Ol(r){return typeof r!="string"||!r.startsWith(yc)?r:(Nl(),Buffer.from(r.slice(yc.length),"base64"))}function Pt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Ll(...r){return Pt(r.join(":"))}function Ks(r){return r=Pt(r),r?r+":":""}var h2="memory",u2=()=>{let r=new Map;return{name:h2,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Ul(r={}){let e={mounts:{"":r.driver||u2()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(let b of e.mountpoints)if(c.startsWith(b))return{base:b,relativeKey:c.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,b)=>e.mountpoints.filter(v=>v.startsWith(c)||b&&c.startsWith(v)).map(v=>({relativeBase:c.length>v.length?c.slice(v.length):void 0,mountpoint:v,driver:e.mounts[v]})),n=(c,b)=>{if(e.watching){b=Pt(b);for(let v of e.watchListeners)v(c,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let c in e.mounts)e.unwatch[c]=await Fl(e.mounts[c],n,c)}},o=async()=>{if(e.watching){for(let c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},f=(c,b,v)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of c){let T=typeof M=="string",O=Pt(T?M:M.key),P=T?void 0:M.value,z=T||!M.options?b:{...b,...M.options},B=t(O);I(B).items.push({key:O,value:P,relativeKey:B.relativeKey,options:z})}return Promise.all([...S.values()].map(M=>v(M))).then(M=>M.flat())},u={hasItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.hasItem,v,b)},getItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.getItem,v,b).then(I=>Bs(I))},getItems(c,b){return f(c,b,v=>v.driver.getItems?ot(v.driver.getItems,v.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:Ll(v.base,I.key),value:Bs(I.value)}))):Promise.all(v.items.map(S=>ot(v.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Bs(I)})))))},getItemRaw(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return S.getItemRaw?ot(S.getItemRaw,v,b):ot(S.getItem,v,b).then(I=>Ol(I))},async setItem(c,b,v={}){if(b===void 0)return u.removeItem(c);c=Pt(c);let{relativeKey:S,driver:I}=t(c);I.setItem&&(await ot(I.setItem,S,ks(b),v),I.watch||n("update",c))},async setItems(c,b){await f(c,b,async v=>{if(v.driver.setItems)return ot(v.driver.setItems,v.items.map(S=>({key:S.relativeKey,value:ks(S.value),options:S.options})),b);v.driver.setItem&&await Promise.all(v.items.map(S=>ot(v.driver.setItem,S.relativeKey,ks(S.value),S.options)))})},async setItemRaw(c,b,v={}){if(b===void 0)return u.removeItem(c,v);c=Pt(c);let{relativeKey:S,driver:I}=t(c);if(I.setItemRaw)await ot(I.setItemRaw,S,b,v);else if(I.setItem)await ot(I.setItem,S,Cl(b),v);else return;I.watch||n("update",c)},async removeItem(c,b={}){typeof b=="boolean"&&(b={removeMeta:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c);S.removeItem&&(await ot(S.removeItem,v,b),(b.removeMeta||b.removeMata)&&await ot(S.removeItem,v+"$",b),S.watch||n("remove",c))},async getMeta(c,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ot(S.getMeta,v,b)),!b.nativeOnly){let M=await ot(S.getItem,v+"$",b).then(T=>Bs(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(c,b,v={}){return this.setItem(c+"$",b,v)},removeMeta(c,b={}){return this.removeItem(c+"$",b)},async getKeys(c,b={}){c=Ks(c);let v=i(c,!0),S=[],I=[];for(let M of v){let T=await ot(M.driver.getKeys,M.relativeBase,b);for(let O of T){let P=M.mountpoint+Pt(O);S.some(z=>P.startsWith(z))||I.push(P)}S=[M.mountpoint,...S.filter(O=>!O.startsWith(M.mountpoint))]}return c?I.filter(M=>M.startsWith(c)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(c,b={}){c=Ks(c),await Promise.all(i(c,!1).map(async v=>{if(v.driver.clear)return ot(v.driver.clear,v.relativeBase,b);if(v.driver.removeItem){let S=await v.driver.getKeys(v.relativeBase||"",b);return Promise.all(S.map(I=>v.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>ql(c)))},async watch(c){return await s(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,b){if(c=Ks(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((v,S)=>S.length-v.length)),e.mounts[c]=b,e.watching&&Promise.resolve(Fl(b,n,c)).then(v=>{e.unwatch[c]=v}).catch(console.error),u},async unmount(c,b=!0){c=Ks(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&(e.unwatch[c](),delete e.unwatch[c]),b&&await ql(e.mounts[c]),e.mountpoints=e.mountpoints.filter(v=>v!==c),delete e.mounts[c])},getMount(c=""){c=Pt(c)+":";let b=t(c);return{driver:b.driver,base:b.base}},getMounts(c="",b={}){return c=Pt(c),i(c,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(c,b={})=>u.getKeys(c,b),get:(c,b={})=>u.getItem(c,b),set:(c,b,v={})=>u.setItem(c,b,v),has:(c,b={})=>u.hasItem(c,b),del:(c,b={})=>u.removeItem(c,b),remove:(c,b={})=>u.removeItem(c,b)};return u}function Fl(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ql(r){typeof r.dispose=="function"&&await ot(r.dispose)}function ln(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function _c(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=ln(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var wc;function js(){return wc||(wc=_c("keyval-store","keyval")),wc}function xc(r,e=js()){return e("readonly",t=>ln(t.get(r)))}function zl(r,e,t=js()){return t("readwrite",i=>(i.put(e,r),ln(i.transaction)))}function Bl(r,e=js()){return e("readwrite",t=>(t.delete(r),ln(t.transaction)))}function kl(r=js()){return r("readwrite",e=>(e.clear(),ln(e.transaction)))}function d2(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},ln(r.transaction)}function Kl(r=js()){return r("readonly",e=>{if(e.getAllKeys)return ln(e.getAllKeys());let t=[];return d2(e,i=>t.push(i.key)).then(()=>t)})}var l2=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),p2=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Fr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return p2(r)}catch{return r}}function Wt(r){return typeof r=="string"?r:l2(r)||""}var g2="idb-keyval",b2=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=_c(r.dbName,r.storeName)),{name:g2,options:r,async hasItem(n){return!(typeof await xc(t(n),i)>"u")},async getItem(n){return await xc(t(n),i)??null},setItem(n,s){return zl(t(n),s,i)},removeItem(n){return Bl(t(n),i)},getKeys(){return Kl(i)},clear(){return kl(i)}}},v2="WALLET_CONNECT_V2_INDEXED_DB",m2="keyvaluestorage",Sc=class{constructor(){this.indexedDb=Ul({driver:b2({dbName:v2,storeName:m2})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Wt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},Ec=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},oa={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ec<"u"&&Ec.localStorage?oa.exports=Ec.localStorage:typeof window<"u"&&window.localStorage?oa.exports=window.localStorage:oa.exports=new e})();function y2(r){var e;return[r[0],Fr((e=r[1])!=null?e:"")]}var Ic=class{constructor(){this.localStorage=oa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(y2)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Fr(t)}async setItem(e,t){this.localStorage.setItem(e,Wt(t))}async removeItem(e){this.localStorage.removeItem(e)}},w2="wc_storage_version",jl=1,_2=async(r,e,t)=>{let i=w2,n=await e.getItem(i);if(n&&n>=jl){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let u=f.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){let c=await r.getItem(f);await e.setItem(f,c),o.push(f)}}await e.setItem(i,jl),t(e),x2(r,o)},x2=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},aa=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new Ic;this.storage=e;try{let t=new Sc;_2(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var ai=qe(Rc()),Hs=qe(Rc());var L2={level:"info"},Gs="custom_context",Nc=1e3*1024,Tc=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ha=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Tc(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},ua=class{constructor(e,t=Nc){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===ai.levels.values.error?console.error(e):t===ai.levels.values.warn?console.warn(e):t===ai.levels.values.debug?console.debug(e):t===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Wt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Wt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Dc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Pc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},F2=Object.defineProperty,q2=Object.defineProperties,U2=Object.getOwnPropertyDescriptors,Yl=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,B2=Object.prototype.propertyIsEnumerable,Xl=(r,e,t)=>e in r?F2(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e)=>{for(var t in e||(e={}))z2.call(e,t)&&Xl(r,t,e[t]);if(Yl)for(var t of Yl(e))B2.call(e,t)&&Xl(r,t,e[t]);return r},la=(r,e)=>q2(r,U2(e));function Ws(r){return la(da({},r),{level:r?.level||L2.level})}function k2(r,e=Gs){return r[e]||""}function K2(r,e,t=Gs){return r[t]=e,r}function yt(r,e=Gs){let t="";return typeof r.bindings>"u"?t=k2(r,e):t=r.bindings().context||"",t}function j2(r,e,t=Gs){let i=yt(r,t);return i.trim()?`${i}/${e}`:e}function lt(r,e,t=Gs){let i=j2(r,e,t),n=r.child({context:i});return K2(n,i,t)}function V2(r){var e,t;let i=new Dc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace",browser:la(da({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function $2(r){var e;let t=new Pc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Zl(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?V2(r):$2(r)}var Ql=qe(un()),pa=class extends sr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var ga=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},ba=class{constructor(e,t){this.logger=e,this.core=t}},va=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}},ma=class extends sr{constructor(e){super()}},ya=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var wa=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}};var _a=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t}};var xa=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Ea=class{constructor(e,t){this.projectId=e,this.logger=t}},Sa=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Ia=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Ma=class{constructor(e){this.client=e}};var re=qe(jn());var so=qe(T0()),op=qe(Js()),ap=qe(jn());var D0="EdDSA",P0="JWT",Zs=".",Qs="base64url",Xc="utf8",Zc="utf8",N0=":",C0="did",O0="key",Qc="base58btc",L0="z",F0="K36";function eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function vn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var nh={};Dt(nh,{identity:()=>$3});function B3(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(B);P!==z;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var k3=B3,K3=k3,q0=K3;var FI=new Uint8Array(0);var U0=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var z0=r=>new TextEncoder().encode(r),B0=r=>new TextDecoder().decode(r);var eh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},th=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K0(this,e)}},rh=class{constructor(e){this.decoders=e}or(e){return K0(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},K0=(r,e)=>new rh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ih=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,t,i),this.decoder=new th(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Yn=({name:r,prefix:e,encode:t,decode:i})=>new ih(r,e,t,i),Ti=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=q0(t,e);return Yn({prefix:r,name:e,encode:i,decode:s=>ci(n(s))})},j3=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[c++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},V3=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Yn({prefix:e,name:r,encode(n){return V3(n,i,t)},decode(n){return j3(n,i,t,r)}});var $3=Yn({prefix:"\0",name:"identity",encode:r=>B0(r),decode:r=>z0(r)});var sh={};Dt(sh,{base2:()=>H3});var H3=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oh={};Dt(oh,{base8:()=>G3});var G3=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah={};Dt(ah,{base10:()=>W3});var W3=Ti({prefix:"9",name:"base10",alphabet:"0123456789"});var fh={};Dt(fh,{base16:()=>J3,base16upper:()=>Y3});var J3=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y3=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ch={};Dt(ch,{base32:()=>Xn,base32hex:()=>e6,base32hexpad:()=>r6,base32hexpadupper:()=>i6,base32hexupper:()=>t6,base32pad:()=>Z3,base32padupper:()=>Q3,base32upper:()=>X3,base32z:()=>n6});var Xn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X3=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z3=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q3=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hh={};Dt(hh,{base36:()=>s6,base36upper:()=>o6});var s6=Ti({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o6=Ti({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uh={};Dt(uh,{base58btc:()=>Ur,base58flickr:()=>a6});var Ur=Ti({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),a6=Ti({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh={};Dt(dh,{base64:()=>f6,base64pad:()=>c6,base64url:()=>h6,base64urlpad:()=>u6});var f6=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),u6=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lh={};Dt(lh,{base256emoji:()=>b6});var j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),d6=j0.reduce((r,e,t)=>(r[t]=e,r),[]),l6=j0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function p6(r){return r.reduce((e,t)=>(e+=d6[t],e),"")}function g6(r){let e=[];for(let t of r){let i=l6[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var b6=Yn({prefix:"\u{1F680}",name:"base256emoji",encode:p6,decode:g6});var vh={};Dt(vh,{sha256:()=>L6,sha512:()=>F6});var v6=H0,V0=128,m6=127,y6=~m6,w6=Math.pow(2,31);function H0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=w6;)e[t++]=r&255|V0,r/=128;for(;r&y6;)e[t++]=r&255|V0,r>>>=7;return e[t]=r|0,H0.bytes=t-i+1,e}var _6=ph,x6=128,$0=127;function ph(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw ph.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&$0)<=x6);return ph.bytes=s-i,t}var E6=Math.pow(2,7),S6=Math.pow(2,14),I6=Math.pow(2,21),M6=Math.pow(2,28),A6=Math.pow(2,35),R6=Math.pow(2,42),T6=Math.pow(2,49),D6=Math.pow(2,56),P6=Math.pow(2,63),N6=function(r){return r[to.decode(r,e),to.decode.bytes],Zn=(r,e,t=0)=>(to.encode(r,e,t),e),Qn=r=>to.encodingLength(r);var mn=(r,e)=>{let t=e.byteLength,i=Qn(r),n=i+Qn(t),s=new Uint8Array(n+t);return Zn(r,s,0),Zn(t,s,i),s.set(e,n),new es(r,t,e,s)},G0=r=>{let e=ci(r),[t,i]=ro(e),[n,s]=ro(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new es(t,n,o,e)},W0=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&U0(r.bytes,e.bytes),es=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var bh=({name:r,code:e,encode:t})=>new gh(r,e,t),gh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?mn(this.code,t):t.then(i=>mn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var Y0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),L6=bh({name:"sha2-256",code:18,encode:Y0("SHA-256")}),F6=bh({name:"sha2-512",code:19,encode:Y0("SHA-512")});var mh={};Dt(mh,{identity:()=>z6});var X0=0,q6="identity",Z0=ci,U6=r=>mn(X0,Z0(r)),z6={code:X0,name:q6,encode:Z0,digest:U6};var iM=new TextEncoder,nM=new TextDecoder;var La=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oa,byteLength:Oa,code:Ca,version:Ca,multihash:Ca,bytes:Ca,_baseCache:Oa,asCID:Oa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==no)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=mn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&W0(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return j6(t,n,e||Ur.encoder);default:return V6(t,n,e||Xn.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return G6(/^0\.0/,W6),!!(e&&(e[ep]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||Q0(t,i,n.bytes))}else if(e!=null&&e[ep]===!0){let{version:t,multihash:i,code:n}=e,s=G0(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==no)throw new Error(`Version 0 CID must use dag-pb (code: ${no}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Q0(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,no,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=ci(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new es(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[v,S]=ro(e.subarray(t));return t+=S,v},n=i(),s=no;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),u=i(),c=t+u,b=c-o;return{version:n,codec:s,multihashCode:f,digestSize:u,multihashSize:b,size:c}}static parse(e,t){let[i,n]=K6(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},K6=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ur;return[Ur.prefix,t.decode(`${Ur.prefix}${r}`)]}case Ur.prefix:{let t=e||Ur;return[Ur.prefix,t.decode(r)]}case Xn.prefix:{let t=e||Xn;return[Xn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},j6=(r,e,t)=>{let{prefix:i}=t;if(i!==Ur.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},V6=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},no=112,$6=18,Q0=(r,e,t)=>{let i=Qn(r),n=i+Qn(e),s=new Uint8Array(n+t.byteLength);return Zn(r,s,0),Zn(e,s,i),s.set(t,n),s},ep=Symbol.for("@ipld/js-cid/CID"),Ca={writable:!1,configurable:!1,enumerable:!0},Oa={writable:!1,enumerable:!1,configurable:!1},H6="0.0.0-dev",G6=(r,e)=>{if(r.test(H6))console.warn(e);else throw new Error(e)},W6=`CID.isCID(v) is deprecated and will be removed in the next major release. Following code pattern: if (CID.isCID(value)) { diff --git a/package-lock.json b/package-lock.json index 9a0a9d7..97e4642 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,12 +13,12 @@ "@configs/esbuild": "workspace:*", "@configs/eslint-config": "workspace:*", "@configs/tsconfig": "workspace:*", - "@types/node": "22.8.7", - "eslint": "9.14.0", + "@types/node": "22.9.0", + "eslint": "9.15.0", "prettier": "3.3.3", "rimraf": "6.0.1", "serve-handler": "6.1.6", - "turbo": "2.2.3", + "turbo": "2.3.0", "typescript": "5.6.3" } }, @@ -32,44 +32,42 @@ "name": "@configs/eslint-config", "version": "0.0.0", "devDependencies": { - "@eslint/eslintrc": "3.1.0", - "@eslint/js": "9.14.0", - "@typescript-eslint/eslint-plugin": "8.12.2", - "@typescript-eslint/parser": "8.12.2", + "@eslint/eslintrc": "3.2.0", + "@eslint/js": "9.15.0", + "@typescript-eslint/eslint-plugin": "8.14.0", + "@typescript-eslint/parser": "8.14.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-prettier": "5.2.1" } }, - "configs/eslint-config/node_modules/@nodelib/fs.scandir": { - "version": "2.1.5", + "configs/eslint-config/node_modules/@eslint/eslintrc": { + "version": "3.1.0", "dev": true, "license": "MIT", "dependencies": { - "@nodelib/fs.stat": "2.0.5", - "run-parallel": "^1.1.9" + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" }, "engines": { - "node": ">= 8" - } - }, - "configs/eslint-config/node_modules/@nodelib/fs.stat": { - "version": "2.0.5", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, - "configs/eslint-config/node_modules/@nodelib/fs.walk": { - "version": "1.2.8", + "configs/eslint-config/node_modules/@eslint/js": { + "version": "9.14.0", "dev": true, "license": "MIT", - "dependencies": { - "@nodelib/fs.scandir": "2.1.5", - "fastq": "^1.6.0" - }, "engines": { - "node": ">= 8" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "configs/eslint-config/node_modules/@pkgr/core": { @@ -335,53 +333,6 @@ "dev": true, "license": "Apache-2.0" }, - "configs/eslint-config/node_modules/fast-glob": { - "version": "3.3.2", - "dev": true, - "license": "MIT", - "dependencies": { - "@nodelib/fs.stat": "^2.0.2", - "@nodelib/fs.walk": "^1.2.3", - "glob-parent": "^5.1.2", - "merge2": "^1.3.0", - "micromatch": "^4.0.4" - }, - "engines": { - "node": ">=8.6.0" - } - }, - "configs/eslint-config/node_modules/fast-glob/node_modules/glob-parent": { - "version": "5.1.2", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "configs/eslint-config/node_modules/fastq": { - "version": "1.17.1", - "dev": true, - "license": "ISC", - "dependencies": { - "reusify": "^1.0.4" - } - }, - "configs/eslint-config/node_modules/graphemer": { - "version": "1.4.0", - "dev": true, - "license": "MIT" - }, - "configs/eslint-config/node_modules/merge2": { - "version": "1.4.1", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, "configs/eslint-config/node_modules/prettier-linter-helpers": { "version": "1.0.0", "dev": true, @@ -393,67 +344,6 @@ "node": ">=6.0.0" } }, - "configs/eslint-config/node_modules/queue-microtask": { - "version": "1.2.3", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "configs/eslint-config/node_modules/reusify": { - "version": "1.0.4", - "dev": true, - "license": "MIT", - "engines": { - "iojs": ">=1.0.0", - "node": ">=0.10.0" - } - }, - "configs/eslint-config/node_modules/run-parallel": { - "version": "1.2.0", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "queue-microtask": "^1.2.2" - } - }, - "configs/eslint-config/node_modules/semver": { - "version": "7.6.3", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, "configs/eslint-config/node_modules/synckit": { "version": "0.9.2", "dev": true, @@ -469,17 +359,6 @@ "url": "https://opencollective.com/unts" } }, - "configs/eslint-config/node_modules/ts-api-utils": { - "version": "1.4.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=16" - }, - "peerDependencies": { - "typescript": ">=4.2.0" - } - }, "configs/eslint-config/node_modules/tslib": { "version": "2.8.1", "dev": true, @@ -929,9 +808,9 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", - "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.19.0.tgz", + "integrity": "sha512-zdHg2FPIFNKPdcHWtiNT+jEFCHYVplAXRDlQDyqy0zGx/q2parwh7brGJSiTxRk/TSMkbM//zt/f5CHgyTyaSQ==", "dev": true, "dependencies": { "@eslint/object-schema": "^2.1.4", @@ -943,18 +822,18 @@ } }, "node_modules/@eslint/core": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", - "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.9.0.tgz", + "integrity": "sha512-7ATR9F0e4W85D/0w7cU0SNj7qkAexMG+bAHEZOjo9akvGuhHE2m7umzWzfnpa0XAg5Kxc1BWmtPMV67jJ+9VUg==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/eslintrc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", - "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.2.0.tgz", + "integrity": "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -975,9 +854,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", - "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", + "version": "9.15.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.15.0.tgz", + "integrity": "sha512-tMTqrY+EzbXmKJR5ToI8lxu7jaN5EdmrBFJpQk5JmSlyLsx6o4t27r883K5xsLuCYCpfKBCGswMSWXsM+jB7lg==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -993,9 +872,9 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", - "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.3.tgz", + "integrity": "sha512-2b/g5hRmpbb1o4GnTZax9N9m0FXzz9OV42ZzI4rDDMDuHUqigAiQCEWChBWCY4ztAGVRjoWT19v0yMmc5/L5kA==", "dev": true, "dependencies": { "levn": "^0.4.1" @@ -1298,27 +1177,6 @@ "hash.js": "1.1.7" } }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "dev": true, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, "node_modules/@ethersproject/strings": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", @@ -1468,6 +1326,41 @@ "node": ">=12" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@parcel/watcher": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.0.tgz", @@ -1967,9 +1860,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "22.8.7", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.7.tgz", - "integrity": "sha512-LidcG+2UeYIWcMuMUpBKOnryBWG/rnmOHQR5apjn8myTQcx3rinFRn7DcIFhMnS0PPFSC6OafdIKEad0lj6U0Q==", + "version": "22.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", + "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", "dev": true, "dependencies": { "undici-types": "~6.19.8" @@ -2520,9 +2413,9 @@ "dev": true }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -2638,9 +2531,9 @@ } }, "node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==", "dev": true }, "node_modules/elven.js": { @@ -2714,26 +2607,26 @@ } }, "node_modules/eslint": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", - "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", + "version": "9.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.15.0.tgz", + "integrity": "sha512-7CrWySmIibCgT1Os28lUU6upBshZ+GxybLOrmRzi08kS8MBuO8QA7pXEgYgY5W8vK3e74xv0lpjo9DbaGU9Rkw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.18.0", - "@eslint/core": "^0.7.0", - "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.14.0", - "@eslint/plugin-kit": "^0.2.0", + "@eslint/config-array": "^0.19.0", + "@eslint/core": "^0.9.0", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "9.15.0", + "@eslint/plugin-kit": "^0.2.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.0", + "@humanwhocodes/retry": "^0.4.1", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", + "cross-spawn": "^7.0.5", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", @@ -2752,8 +2645,7 @@ "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "text-table": "^0.2.0" + "optionator": "^0.9.3" }, "bin": { "eslint": "bin/eslint.js" @@ -2898,6 +2790,34 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2919,6 +2839,15 @@ "node": ">=6" } }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -3106,6 +3035,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", + "dev": true + }, "node_modules/h3": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/h3/-/h3-1.13.0.tgz", @@ -3520,6 +3455,15 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -3612,14 +3556,14 @@ } }, "node_modules/mlly": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.2.tgz", - "integrity": "sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.3.tgz", + "integrity": "sha512-xUsx5n/mN0uQf4V548PKQ+YShA4/IW0KI1dZhrNrPCLG+xizETbHTkOa1f8/xut9JRPp8kQuMnz0oqwkTiLo/A==", "dev": true, "dependencies": { - "acorn": "^8.12.1", + "acorn": "^8.14.0", "pathe": "^1.1.2", - "pkg-types": "^1.2.0", + "pkg-types": "^1.2.1", "ufo": "^1.5.4" } }, @@ -3980,6 +3924,26 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/quick-format-unescaped": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", @@ -4045,6 +4009,16 @@ "node": ">=4" } }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rimraf": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", @@ -4064,6 +4038,29 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -4093,6 +4090,18 @@ "node": ">=10" } }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/serve-handler": { "version": "6.1.6", "resolved": "https://registry.npmjs.org/serve-handler/-/serve-handler-6.1.6.tgz", @@ -4169,9 +4178,9 @@ } }, "node_modules/std-env": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", - "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", + "integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==", "dev": true }, "node_modules/stream-shift": { @@ -4342,12 +4351,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true - }, "node_modules/thread-stream": { "version": "0.15.2", "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", @@ -4369,6 +4372,18 @@ "node": ">=8.0" } }, + "node_modules/ts-api-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz", + "integrity": "sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -4376,26 +4391,26 @@ "dev": true }, "node_modules/turbo": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/turbo/-/turbo-2.2.3.tgz", - "integrity": "sha512-5lDvSqIxCYJ/BAd6rQGK/AzFRhBkbu4JHVMLmGh/hCb7U3CqSnr5Tjwfy9vc+/5wG2DJ6wttgAaA7MoCgvBKZQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo/-/turbo-2.3.0.tgz", + "integrity": "sha512-/uOq5o2jwRPyaUDnwBpOR5k9mQq4c3wziBgWNWttiYQPmbhDtrKYPRBxTvA2WpgQwRIbt8UM612RMN8n/TvmHA==", "dev": true, "bin": { "turbo": "bin/turbo" }, "optionalDependencies": { - "turbo-darwin-64": "2.2.3", - "turbo-darwin-arm64": "2.2.3", - "turbo-linux-64": "2.2.3", - "turbo-linux-arm64": "2.2.3", - "turbo-windows-64": "2.2.3", - "turbo-windows-arm64": "2.2.3" + "turbo-darwin-64": "2.3.0", + "turbo-darwin-arm64": "2.3.0", + "turbo-linux-64": "2.3.0", + "turbo-linux-arm64": "2.3.0", + "turbo-windows-64": "2.3.0", + "turbo-windows-arm64": "2.3.0" } }, "node_modules/turbo-darwin-64": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-2.2.3.tgz", - "integrity": "sha512-Rcm10CuMKQGcdIBS3R/9PMeuYnv6beYIHqfZFeKWVYEWH69sauj4INs83zKMTUiZJ3/hWGZ4jet9AOwhsssLyg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-2.3.0.tgz", + "integrity": "sha512-pji+D49PhFItyQjf2QVoLZw2d3oRGo8gJgKyOiRzvip78Rzie74quA8XNwSg/DuzM7xx6gJ3p2/LylTTlgZXxQ==", "cpu": [ "x64" ], @@ -4406,9 +4421,9 @@ ] }, "node_modules/turbo-darwin-arm64": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-2.2.3.tgz", - "integrity": "sha512-+EIMHkuLFqUdJYsA3roj66t9+9IciCajgj+DVek+QezEdOJKcRxlvDOS2BUaeN8kEzVSsNiAGnoysFWYw4K0HA==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-2.3.0.tgz", + "integrity": "sha512-AJrGIL9BO41mwDF/IBHsNGwvtdyB911vp8f5mbNo1wG66gWTvOBg7WCtYQBvCo11XTenTfXPRSsAb7w3WAZb6w==", "cpu": [ "arm64" ], @@ -4419,9 +4434,9 @@ ] }, "node_modules/turbo-linux-64": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-2.2.3.tgz", - "integrity": "sha512-UBhJCYnqtaeOBQLmLo8BAisWbc9v9daL9G8upLR+XGj6vuN/Nz6qUAhverN4Pyej1g4Nt1BhROnj6GLOPYyqxQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-2.3.0.tgz", + "integrity": "sha512-jZqW6vc2sPJT3M/3ZmV1Cg4ecQVPqsbHncG/RnogHpBu783KCSXIndgxvUQNm9qfgBYbZDBnP1md63O4UTElhw==", "cpu": [ "x64" ], @@ -4432,9 +4447,9 @@ ] }, "node_modules/turbo-linux-arm64": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-2.2.3.tgz", - "integrity": "sha512-hJYT9dN06XCQ3jBka/EWvvAETnHRs3xuO/rb5bESmDfG+d9yQjeTMlhRXKrr4eyIMt6cLDt1LBfyi+6CQ+VAwQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-2.3.0.tgz", + "integrity": "sha512-HUbDLJlvd/hxuyCNO0BmEWYQj0TugRMvSQeG8vHJH+Lq8qOgDAe7J0K73bFNbZejZQxW3C3XEiZFB3pnpO78+A==", "cpu": [ "arm64" ], @@ -4445,9 +4460,9 @@ ] }, "node_modules/turbo-windows-64": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-2.2.3.tgz", - "integrity": "sha512-NPrjacrZypMBF31b4HE4ROg4P3nhMBPHKS5WTpMwf7wydZ8uvdEHpESVNMOtqhlp857zbnKYgP+yJF30H3N2dQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-2.3.0.tgz", + "integrity": "sha512-c5rxrGNTYDWX9QeMzWLFE9frOXnKjHGEvQMp1SfldDlbZYsloX9UKs31TzUThzfTgTiz8NYuShaXJ2UvTMnV/g==", "cpu": [ "x64" ], @@ -4458,9 +4473,9 @@ ] }, "node_modules/turbo-windows-arm64": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-2.2.3.tgz", - "integrity": "sha512-fnNrYBCqn6zgKPKLHu4sOkihBI/+0oYFr075duRxqUZ+1aLWTAGfHZLgjVeLh3zR37CVzuerGIPWAEkNhkWEIw==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-2.3.0.tgz", + "integrity": "sha512-7qfUuYhfIVb1AZgs89DxhXK+zZez6O2ocmixEQ4hXZK7ytnBt5vaz2zGNJJKFNYIL5HX1C3tuHolnpNgDNCUIg==", "cpu": [ "arm64" ], diff --git a/package.json b/package.json index 66a35b4..378be48 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "elven.js-monorepo", "private": true, "type": "module", - "packageManager": "npm@10.2.4", + "packageManager": "npm@10.9.0", "workspaces": [ "packages/*", "configs/*" @@ -19,12 +19,15 @@ "@configs/esbuild": "workspace:*", "@configs/eslint-config": "workspace:*", "@configs/tsconfig": "workspace:*", - "@types/node": "22.8.7", - "eslint": "9.14.0", + "@types/node": "22.9.0", + "eslint": "9.15.0", "prettier": "3.3.3", "rimraf": "6.0.1", "serve-handler": "6.1.6", - "turbo": "2.2.3", + "turbo": "2.3.0", "typescript": "5.6.3" + }, + "overrides": { + "elliptic": "6.6.0" } -} +} \ No newline at end of file diff --git a/packages/elven.js/src/auth/login-with-extension.ts b/packages/elven.js/src/auth/login-with-extension.ts index d857273..d432fb6 100644 --- a/packages/elven.js/src/auth/login-with-extension.ts +++ b/packages/elven.js/src/auth/login-with-extension.ts @@ -4,7 +4,7 @@ import { errorParse } from '../utils/error-parse'; import { EventStoreEvents, LoginMethodsEnum } from '../types'; import { getNewLoginExpiresTimestamp } from './expires-at'; import { accountSync } from './account-sync'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { NativeAuthClient } from '../core/native-auth-client'; export const loginWithExtension = async ( diff --git a/packages/elven.js/src/auth/login-with-web-wallet.ts b/packages/elven.js/src/auth/login-with-web-wallet.ts index e4922c8..92e3bd7 100644 --- a/packages/elven.js/src/auth/login-with-web-wallet.ts +++ b/packages/elven.js/src/auth/login-with-web-wallet.ts @@ -4,7 +4,7 @@ import { DAPP_INIT_ROUTE, networkConfig } from '../utils/constants'; import { errorParse } from '../utils/error-parse'; import { ls } from '../utils/ls-helpers'; import { getNewLoginExpiresTimestamp } from './expires-at'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; export const loginWithWebWallet = async ( urlAddress: string, diff --git a/packages/elven.js/src/auth/logout.ts b/packages/elven.js/src/auth/logout.ts index f1a01ac..c7ee5df 100644 --- a/packages/elven.js/src/auth/logout.ts +++ b/packages/elven.js/src/auth/logout.ts @@ -1,5 +1,5 @@ import { ls } from '../utils/ls-helpers'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { errorParse } from '../utils/error-parse'; diff --git a/packages/elven.js/src/config.ts b/packages/elven.js/src/config.ts new file mode 100644 index 0000000..a615e30 --- /dev/null +++ b/packages/elven.js/src/config.ts @@ -0,0 +1,23 @@ +import { ApiNetworkProvider } from './core/network-provider'; +import { DappProvider, InitOptions, MobileSigningProvider } from './types'; + +export interface ElvenConfig { + initOptions?: InitOptions; + dappProvider?: DappProvider; + networkProvider?: ApiNetworkProvider; + mobileProvider?: MobileSigningProvider; +} + +export const config: ElvenConfig = { + initOptions: undefined, + dappProvider: undefined, + networkProvider: undefined, + mobileProvider: undefined, +}; + +export const resetConfig = () => { + config.initOptions = undefined; + config.dappProvider = undefined; + config.networkProvider = undefined; + config.mobileProvider = undefined; +}; diff --git a/packages/elven.js/src/elven.ts b/packages/elven.js/src/elven.ts index e5d02a8..f1076fe 100644 --- a/packages/elven.js/src/elven.ts +++ b/packages/elven.js/src/elven.ts @@ -4,6 +4,6 @@ export { Account } from './core/account'; export { Transaction } from './core/transaction'; export { TransactionWatcher } from './core/transaction-watcher'; -export { ElvenJS } from './main'; +export * from './main'; export { parseAmount, formatAmount } from './utils/amount'; export * from './types'; diff --git a/packages/elven.js/src/events-store.ts b/packages/elven.js/src/events-store.ts index f42955b..fdf4b5a 100644 --- a/packages/elven.js/src/events-store.ts +++ b/packages/elven.js/src/events-store.ts @@ -1,25 +1,22 @@ import { EventStoreEvents } from './types'; -export class EventsStore { - private static events: Record void> | undefined; +let events: Record void> | undefined; - static set(name: EventStoreEvents, fn: (...args: any[]) => void) { - if (!name) return; - const eventsObj = { ...this.events, [name]: fn }; - this.events = eventsObj; - } +export function set(name: EventStoreEvents, fn: (...args: any[]) => void) { + if (!name) return; + events = { ...events, [name]: fn }; +} - static get(name: EventStoreEvents) { - if (!name || !this.events) return; - return this.events[name]; - } +export function get(name: EventStoreEvents) { + if (!name || !events) return; + return events[name]; +} - static run(name: EventStoreEvents, ...args: any[]) { - if (!name || !this.events) return; - this.events[name]?.(...args); - } +export function run(name: EventStoreEvents, ...args: any[]) { + if (!name || !events) return; + events[name]?.(...args); +} - static clear() { - this.events = undefined; - } +export function clear() { + events = undefined; } diff --git a/packages/elven.js/src/initialize-events-store.ts b/packages/elven.js/src/initialize-events-store.ts index abd4364..bd2516a 100644 --- a/packages/elven.js/src/initialize-events-store.ts +++ b/packages/elven.js/src/initialize-events-store.ts @@ -1,4 +1,4 @@ -import { EventsStore } from './events-store'; +import * as EventsStore from './events-store'; import { InitOptions, EventStoreEvents } from './types'; export const initializeEventsStore = (initOptions: InitOptions) => { diff --git a/packages/elven.js/src/interaction/post-send-tx.ts b/packages/elven.js/src/interaction/post-send-tx.ts index 9ec2cf4..7cd3ec5 100644 --- a/packages/elven.js/src/interaction/post-send-tx.ts +++ b/packages/elven.js/src/interaction/post-send-tx.ts @@ -2,7 +2,7 @@ import { Account } from '../core/account'; import { TransactionWatcher } from '../core/transaction-watcher'; import { ApiNetworkProvider } from '../core/network-provider'; import { ls } from '../utils/ls-helpers'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { ISentTransactionResponse } from '../core/types'; diff --git a/packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts b/packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts index c08bc98..9dd0592 100644 --- a/packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts +++ b/packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts @@ -1,4 +1,4 @@ -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { getParamFromUrl } from '../utils/get-param-from-url'; diff --git a/packages/elven.js/src/interaction/web-wallet-tx-finalize.ts b/packages/elven.js/src/interaction/web-wallet-tx-finalize.ts index e3d32fd..9305875 100644 --- a/packages/elven.js/src/interaction/web-wallet-tx-finalize.ts +++ b/packages/elven.js/src/interaction/web-wallet-tx-finalize.ts @@ -16,7 +16,7 @@ import { import { ApiNetworkProvider } from '../core/network-provider'; import { postSendTx } from './post-send-tx'; import { errorParse } from '../utils/error-parse'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { ls } from '../utils/ls-helpers'; import { DAPP_INIT_ROUTE } from '../utils/constants'; import { preSendTx } from './pre-send-tx'; diff --git a/packages/elven.js/src/main.ts b/packages/elven.js/src/main.ts index d80f4f7..b3a4811 100644 --- a/packages/elven.js/src/main.ts +++ b/packages/elven.js/src/main.ts @@ -12,21 +12,19 @@ import { SmartContractQueryArgs, } from './core/network-provider'; import { - DappProvider, LoginMethodsEnum, LoginOptions, InitOptions, EventStoreEvents, - MobileSigningProvider, MobileSigningProviderDeps, } from './types'; -import { logout } from './auth/logout'; +import { logout as logoutHelper } from './auth/logout'; import { loginWithExtension } from './auth/login-with-extension'; import { loginWithWebWallet } from './auth/login-with-web-wallet'; import { accountSync } from './auth/account-sync'; import { errorParse } from './utils/error-parse'; import { getNewLoginExpiresTimestamp, isLoginExpired } from './auth/expires-at'; -import { EventsStore } from './events-store'; +import * as EventsStore from './events-store'; import { networkConfig, defaultApiEndpoint, @@ -47,455 +45,452 @@ import { initializeEventsStore } from './initialize-events-store'; import { withLoginEvents } from './utils/with-login-events'; import { bytesToHex, stringToBytes } from './core/utils'; import { TransactionsConverter } from './core/transaction-converter'; +import { config, resetConfig } from './config'; + +/** + * Initialization of the Elven.js + */ +export const init = async (options: InitOptions) => { + const state = ls.get(); + + if (state.expires && isLoginExpired(state.expires)) { + ls.clear(); + config.dappProvider = undefined; + return; + } -export class ElvenJS { - private static initOptions: InitOptions | undefined; - static dappProvider: DappProvider; - static networkProvider: ApiNetworkProvider | undefined; - static mobileProvider: MobileSigningProvider | undefined; - - /** - * Initialization of the Elven.js - */ - static async init(options: InitOptions) { - const state = ls.get(); - - if (state.expires && isLoginExpired(state.expires)) { - ls.clear(); - this.dappProvider = undefined; - return; - } + config.initOptions = { + chainType: defaultChainTypeConfig, + apiUrl: defaultApiEndpoint, + apiTimeout: 10000, + ...options, + }; - this.initOptions = { - chainType: defaultChainTypeConfig, - apiUrl: defaultApiEndpoint, - apiTimeout: 10000, - ...options, + config.networkProvider = new ApiNetworkProvider(config.initOptions); + + initializeEventsStore(config.initOptions); + + // Initialize the optional mobile provider + const MobileProvider = + config.initOptions?.externalSigningProviders?.mobile?.provider; + if (MobileProvider) { + const deps: MobileSigningProviderDeps = { + networkConfig, + Message, + Transaction, + TransactionsConverter, + ls, + logout: logoutHelper, + getNewLoginExpiresTimestamp, + accountSync, + EventsStore, }; - - this.networkProvider = new ApiNetworkProvider(this.initOptions); - - initializeEventsStore(this.initOptions); - - // Initialize the optional mobile provider - const MobileProvider = - this.initOptions?.externalSigningProviders?.mobile?.provider; - if (MobileProvider) { - const deps: MobileSigningProviderDeps = { - networkConfig, - Message, - Transaction, - TransactionsConverter, - ls, - logout, - getNewLoginExpiresTimestamp, - accountSync, - EventsStore, - }; - const mobileProviderConfig = - this.initOptions?.externalSigningProviders?.mobile?.config; - if (mobileProviderConfig) { - this.mobileProvider = new MobileProvider(mobileProviderConfig, deps); - } else { - throw new Error('Mobile provider config is required!'); - } - } - - // Catch the nativeAuthToken and login with it (for example within xPortal Hub) - const nativeAuthTokenFromUrl = getParamFromUrl('accessToken'); - if (nativeAuthTokenFromUrl) { - await withLoginEvents(async (onLoginSuccess) => { - loginWithNativeAuthToken(nativeAuthTokenFromUrl, this); - await accountSync(this); - onLoginSuccess(); - }); - } - - const isAddress = - state?.address || - ((state.loginMethod === LoginMethodsEnum.webWallet || - state.loginMethod === LoginMethodsEnum.xAlias) && - getParamFromUrl('address')); - - if (isAddress && state?.loginMethod) { - await withLoginEvents(async (onLoginSuccess) => { - if (state.loginMethod === LoginMethodsEnum.browserExtension) { - this.dappProvider = await initExtensionProvider(); - } - if ( - state.loginMethod === LoginMethodsEnum.mobile && - this.mobileProvider - ) { - this.dappProvider = - await this.mobileProvider?.initMobileProvider(this); - } - if (state.loginMethod === LoginMethodsEnum.webview) { - this.dappProvider = new WebviewProvider(); - } - if ( - state.loginMethod === LoginMethodsEnum.webWallet && - this.initOptions?.chainType - ) { - this.dappProvider = await initWebWalletProvider( - networkConfig[this.initOptions.chainType].walletAddress, - this.initOptions.apiUrl - ); - } - if ( - state.loginMethod === LoginMethodsEnum.xAlias && - this.initOptions?.chainType - ) { - this.dappProvider = await initWebWalletProvider( - networkConfig[this.initOptions.chainType].xAliasAddress, - this.initOptions.apiUrl - ); - } - await accountSync(this); - onLoginSuccess(); - }); - - // After successful web wallet transaction (or guarded transaction that use web wallet 2FA hook) we will land back on our website - if (this.initOptions?.chainType) { - // We need to get params from callback url and finalize the transaction - // It will only trigger when there is a WALLET_PROVIDER_CALLBACK_PARAM_TX_SIGNED in url params - await webWalletTxFinalize( - this.dappProvider, - this.networkProvider, - networkConfig[this.initOptions.chainType][ - state.loginMethod === LoginMethodsEnum.xAlias - ? 'xAliasAddress' - : 'walletAddress' - ], - state.nonce - ); - - // We need to get the signature in case of signing a message with web wallet or guardians 2FA hook - webWalletSignMessageFinalize(); - } + const mobileProviderConfig = + config.initOptions?.externalSigningProviders?.mobile?.config; + if (mobileProviderConfig) { + config.mobileProvider = new MobileProvider(mobileProviderConfig, deps); + } else { + throw new Error('Mobile provider config is required!'); } } - /** - * Login function - */ - static async login(loginMethod: LoginMethodsEnum, options?: LoginOptions) { - const isProperLoginMethod = - Object.values(LoginMethodsEnum).includes(loginMethod); - if (!isProperLoginMethod) { - const error = 'Wrong login method!'; - EventsStore.run(EventStoreEvents.onLoginFailure, error); - throw new Error(error); - } + // Catch the nativeAuthToken and login with it (for example within xPortal Hub) + const nativeAuthTokenFromUrl = getParamFromUrl('accessToken'); + if (nativeAuthTokenFromUrl) { + await withLoginEvents(async (onLoginSuccess) => { + loginWithNativeAuthToken(nativeAuthTokenFromUrl, config); + await accountSync(config); + onLoginSuccess(); + }); + } - if (!this.networkProvider) { - const error = 'Login failed: Use ElvenJs.init() first!'; - EventsStore.run(EventStoreEvents.onLoginFailure, error); - throw new Error(error); - } + const isAddress = + state?.address || + ((state.loginMethod === LoginMethodsEnum.webWallet || + state.loginMethod === LoginMethodsEnum.xAlias) && + getParamFromUrl('address')); - await withLoginEvents(async () => { - // Native auth login token initialization - const nativeAuthClient = new NativeAuthClient({ - apiUrl: this.initOptions?.apiUrl, - origin: window.location.origin, - }); - - const loginToken = await nativeAuthClient.initialize({ - timestamp: `${Math.floor(Date.now() / 1000)}`, - }); - - // Login with browser extension - if (loginMethod === LoginMethodsEnum.browserExtension) { - const dappProvider = await loginWithExtension( - this, - loginToken, - nativeAuthClient, - options?.callbackRoute - ); - this.dappProvider = dappProvider; + if (isAddress && state?.loginMethod) { + await withLoginEvents(async (onLoginSuccess) => { + if (state.loginMethod === LoginMethodsEnum.browserExtension) { + config.dappProvider = await initExtensionProvider(); } - - // Login with optional mobile provider - if (loginMethod === LoginMethodsEnum.mobile && this.mobileProvider) { - const dappProvider = await this.mobileProvider?.loginWithMobile( - this, - loginToken, - nativeAuthClient - ); - this.dappProvider = dappProvider; + if ( + state.loginMethod === LoginMethodsEnum.mobile && + config.mobileProvider + ) { + config.dappProvider = + await config.mobileProvider?.initMobileProvider(config); + } + if (state.loginMethod === LoginMethodsEnum.webview) { + config.dappProvider = new WebviewProvider(); } - - // Login with Web Wallet if ( - loginMethod === LoginMethodsEnum.webWallet && - this.initOptions?.chainType + state.loginMethod === LoginMethodsEnum.webWallet && + config.initOptions?.chainType ) { - const dappProvider = await loginWithWebWallet( - networkConfig[this.initOptions.chainType].walletAddress, - loginToken, - this.initOptions?.chainType, - options?.callbackRoute + config.dappProvider = await initWebWalletProvider( + networkConfig[config.initOptions.chainType].walletAddress, + config.initOptions.apiUrl ); - this.dappProvider = dappProvider; } - - // Login with xAlias if ( - loginMethod === LoginMethodsEnum.xAlias && - this.initOptions?.chainType + state.loginMethod === LoginMethodsEnum.xAlias && + config.initOptions?.chainType ) { - // Login with xAlias is almost the same as with the web wallet, only endpoints are different - const dappProvider = await loginWithWebWallet( - networkConfig[this.initOptions.chainType].xAliasAddress, - loginToken, - this.initOptions?.chainType, - options?.callbackRoute + config.dappProvider = await initWebWalletProvider( + networkConfig[config.initOptions.chainType].xAliasAddress, + config.initOptions.apiUrl ); - this.dappProvider = dappProvider; } + await accountSync(config); + onLoginSuccess(); }); - } - /** - * Logout function - */ - static async logout() { - try { - const isLoggedOut = await logout(this); - this.dappProvider = undefined; - return isLoggedOut; - } catch (e) { - const err = errorParse(e); - console.warn('Something went wrong when logging out: ', err); - } - } + // After successful web wallet transaction (or guarded transaction that use web wallet 2FA hook) we will land back on our website + if (config.initOptions?.chainType) { + // We need to get params from callback url and finalize the transaction + // It will only trigger when there is a WALLET_PROVIDER_CALLBACK_PARAM_TX_SIGNED in url params + await webWalletTxFinalize( + config.dappProvider, + config.networkProvider, + networkConfig[config.initOptions.chainType][ + state.loginMethod === LoginMethodsEnum.xAlias + ? 'xAliasAddress' + : 'walletAddress' + ], + state.nonce + ); - /** - * Sign and send function - */ - static async signAndSendTransaction(transaction: Transaction) { - if (!this.dappProvider) { - const error = 'Transaction signing failed: There is no active session!'; - EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); - throw new Error(error); - } - if (!this.networkProvider) { - const error = - 'Transaction signing failed: There is no active network provider!'; - EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); - throw new Error(error); + // We need to get the signature in case of signing a message with web wallet or guardians 2FA hook + webWalletSignMessageFinalize(); } + } +}; + +/** + * Login function + */ +export const login = async ( + loginMethod: LoginMethodsEnum, + options?: LoginOptions +) => { + const isProperLoginMethod = + Object.values(LoginMethodsEnum).includes(loginMethod); + if (!isProperLoginMethod) { + const error = 'Wrong login method!'; + EventsStore.run(EventStoreEvents.onLoginFailure, error); + throw new Error(error); + } - let signedTx = guardianPreSignTxOperations(transaction); + if (!config.networkProvider) { + const error = 'Login failed: Use ElvenJs.init() first!'; + EventsStore.run(EventStoreEvents.onLoginFailure, error); + throw new Error(error); + } - try { - EventsStore.run(EventStoreEvents.onTxStart, transaction); + await withLoginEvents(async () => { + // Native auth login token initialization + const nativeAuthClient = new NativeAuthClient({ + apiUrl: config.initOptions?.apiUrl, + origin: window.location.origin, + }); - const currentState = ls.get(); + const loginToken = await nativeAuthClient.initialize({ + timestamp: `${Math.floor(Date.now() / 1000)}`, + }); - transaction.nonce = currentState.nonce; + // Login with browser extension + if (loginMethod === LoginMethodsEnum.browserExtension) { + const dp = await loginWithExtension( + config, + loginToken, + nativeAuthClient, + options?.callbackRoute + ); + config.dappProvider = dp; + } - if (this.dappProvider instanceof ExtensionProvider) { - signedTx = await this.dappProvider.signTransaction(transaction); - } - if ( - this.mobileProvider && - this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider - ) { - signedTx = await this.dappProvider.signTransaction(transaction); - } - if (this.dappProvider instanceof WebviewProvider) { - signedTx = await this.dappProvider.signTransaction(transaction); - } - if (this.dappProvider instanceof WalletProvider) { - await this.dappProvider.signTransaction(transaction); - } + // Login with optional mobile provider + if (loginMethod === LoginMethodsEnum.mobile && config.mobileProvider) { + const dp = await config.mobileProvider?.loginWithMobile( + config, + loginToken, + nativeAuthClient + ); + config.dappProvider = dp; + } - if ( - currentState.loginMethod !== LoginMethodsEnum.webWallet && - currentState.loginMethod !== LoginMethodsEnum.xAlias - ) { - const needsGuardianSign = checkNeedsGuardianSigning(signedTx); + // Login with Web Wallet + if ( + loginMethod === LoginMethodsEnum.webWallet && + config.initOptions?.chainType + ) { + const dp = await loginWithWebWallet( + networkConfig[config.initOptions.chainType].walletAddress, + loginToken, + config.initOptions?.chainType, + options?.callbackRoute + ); + config.dappProvider = dp; + } - if (!needsGuardianSign) { - preSendTx(signedTx); - } + // Login with xAlias + if ( + loginMethod === LoginMethodsEnum.xAlias && + config.initOptions?.chainType + ) { + // Login with xAlias is almost the same as with the web wallet, only endpoints are different + const dp = await loginWithWebWallet( + networkConfig[config.initOptions.chainType].xAliasAddress, + loginToken, + config.initOptions?.chainType, + options?.callbackRoute + ); + config.dappProvider = dp; + } + }); +}; + +/** + * Logout function + */ +export const logout = async () => { + try { + const isLoggedOut = await logoutHelper(config); + config.dappProvider = undefined; + return isLoggedOut; + } catch (e) { + const err = errorParse(e); + console.warn('Something went wrong when logging out: ', err); + } +}; + +/** + * Sign and send function + */ +export const signAndSendTransaction = async (transaction: Transaction) => { + if (!config.dappProvider) { + const error = 'Transaction signing failed: There is no active session!'; + EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); + throw new Error(error); + } + if (!config.networkProvider) { + const error = + 'Transaction signing failed: There is no active network provider!'; + EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); + throw new Error(error); + } - if (needsGuardianSign && this.initOptions?.chainType) { - await sendTxToGuardian( - signedTx, - networkConfig[this.initOptions.chainType].walletAddress - ); + let signedTx = guardianPreSignTxOperations(transaction); - return; - } + try { + EventsStore.run(EventStoreEvents.onTxStart, transaction); - const response = await this.networkProvider.sendTransaction(signedTx); - await postSendTx(response, this.networkProvider); - } - } catch (e) { - const err = errorParse(e); - EventsStore.run( - EventStoreEvents.onTxFailure, - signedTx, - `Getting transaction information failed! ${err}` - ); - throw new Error(`Getting transaction information failed! ${err}`); - } + const currentState = ls.get(); - return signedTx; - } + transaction.nonce = currentState.nonce; - /** - * Sign a single message - */ - static async signMessage( - message: string, - options?: { callbackUrl?: string } - ) { - if (!this.dappProvider) { - const error = 'Message signing failed: There is no active session!'; - EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); - throw new Error(error); + if (config.dappProvider instanceof ExtensionProvider) { + signedTx = await config.dappProvider.signTransaction(transaction); + } + if ( + config.mobileProvider && + config.dappProvider instanceof + config.mobileProvider.WalletConnectV2Provider + ) { + signedTx = await config.dappProvider.signTransaction(transaction); } - if (!this.networkProvider) { - const error = - 'Message signing failed: There is no active network provider!'; - EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); - throw new Error(error); + if (config.dappProvider instanceof WebviewProvider) { + signedTx = await config.dappProvider.signTransaction(transaction); + } + if (config.dappProvider instanceof WalletProvider) { + await config.dappProvider.signTransaction(transaction); } - let messageSignature = ''; + if ( + currentState.loginMethod !== LoginMethodsEnum.webWallet && + currentState.loginMethod !== LoginMethodsEnum.xAlias + ) { + const needsGuardianSign = checkNeedsGuardianSigning(signedTx); - try { - EventsStore.run(EventStoreEvents.onSignMsgStart, message); + if (!needsGuardianSign) { + preSendTx(signedTx); + } - if (this.dappProvider instanceof ExtensionProvider) { - const signedMessage = await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }) + if (needsGuardianSign && config.initOptions?.chainType) { + await sendTxToGuardian( + signedTx, + networkConfig[config.initOptions.chainType].walletAddress ); - if (typeof signedMessage !== 'string' && signedMessage?.signature) { - messageSignature = bytesToHex(signedMessage.signature); - } + return; } - if ( - this.mobileProvider && - this.dappProvider instanceof this.mobileProvider.WalletConnectV2Provider - ) { - const signedMessage = await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }) - ); + const response = await config.networkProvider.sendTransaction(signedTx); + await postSendTx(response, config.networkProvider); + } + } catch (e) { + const err = errorParse(e); + EventsStore.run( + EventStoreEvents.onTxFailure, + signedTx, + `Getting transaction information failed! ${err}` + ); + throw new Error(`Getting transaction information failed! ${err}`); + } - if (typeof signedMessage !== 'string' && signedMessage?.signature) { - messageSignature = bytesToHex(signedMessage.signature); - } - } + return signedTx; +}; + +/** + * Sign a single message + */ +export const signMessage = async ( + message: string, + options?: { callbackUrl?: string } +) => { + if (!config.dappProvider) { + const error = 'Message signing failed: There is no active session!'; + EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); + throw new Error(error); + } + if (!config.networkProvider) { + const error = + 'Message signing failed: There is no active network provider!'; + EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); + throw new Error(error); + } - if (this.dappProvider instanceof WebviewProvider) { - const signedMessage = await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }) - ); + let messageSignature = ''; - if (typeof signedMessage !== 'string' && signedMessage?.signature) { - messageSignature = bytesToHex(signedMessage.signature); - } - } - if (this.dappProvider instanceof WalletProvider) { - const encodeRFC3986URIComponent = (str: string) => { - return encodeURIComponent(str).replace( - /[!'()*]/g, - (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}` - ); - }; - - const url = options?.callbackUrl || window.location.origin; - await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }), - { - callbackUrl: encodeURIComponent( - `${url}${ - url.includes('?') ? '&' : '?' - }message=${encodeRFC3986URIComponent(message)}` - ), - } - ); - } + try { + EventsStore.run(EventStoreEvents.onSignMsgStart, message); - const currentState = ls.get(); + if (config.dappProvider instanceof ExtensionProvider) { + const signedMessage = await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }) + ); - if ( - currentState.loginMethod !== LoginMethodsEnum.webWallet && - currentState.loginMethod !== LoginMethodsEnum.xAlias - ) { - EventsStore.run( - EventStoreEvents.onSignMsgFinalized, - message, - messageSignature - ); + if (typeof signedMessage !== 'string' && signedMessage?.signature) { + messageSignature = bytesToHex(signedMessage.signature); } + } - return { message, messageSignature }; - } catch (e) { - const err = errorParse(e); - EventsStore.run(EventStoreEvents.onSignMsgFailure, message, err); - throw new Error(`Message signing failed! ${err}`); + if ( + config.mobileProvider && + config.dappProvider instanceof + config.mobileProvider.WalletConnectV2Provider + ) { + const signedMessage = await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }) + ); + + if (typeof signedMessage !== 'string' && signedMessage?.signature) { + messageSignature = bytesToHex(signedMessage.signature); + } } - } - /** - * Query Smart Contracts - */ - static async queryContract({ - address, - func, - args = [], - value = 0, - caller, - }: SmartContractQueryArgs) { - if (!this.networkProvider) { - throw new Error('Query failed: There is no active network provider!'); + if (config.dappProvider instanceof WebviewProvider) { + const signedMessage = await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }) + ); + + if (typeof signedMessage !== 'string' && signedMessage?.signature) { + messageSignature = bytesToHex(signedMessage.signature); + } } + if (config.dappProvider instanceof WalletProvider) { + const encodeRFC3986URIComponent = (str: string) => { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}` + ); + }; - if (!address || !func) { - throw new Error( - 'Query failed: The Query arguments are not valid! Address and func required' + const url = options?.callbackUrl || window.location.origin; + await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }), + { + callbackUrl: encodeURIComponent( + `${url}${ + url.includes('?') ? '&' : '?' + }message=${encodeRFC3986URIComponent(message)}` + ), + } ); } - const queryArgs = { - address, - func, - args, - value, - caller, - }; + const currentState = ls.get(); - try { - EventsStore.run(EventStoreEvents.onQueryStart, queryArgs); - const response = await this.networkProvider.queryContract(queryArgs); - EventsStore.run(EventStoreEvents.onQueryFinalized, response); - return response; - } catch (e) { - const err = errorParse(e); - EventsStore.run(EventStoreEvents.onQueryFinalized, queryArgs, err); - throw new Error(`Smart contract query failed! ${err}`); + if ( + currentState.loginMethod !== LoginMethodsEnum.webWallet && + currentState.loginMethod !== LoginMethodsEnum.xAlias + ) { + EventsStore.run( + EventStoreEvents.onSignMsgFinalized, + message, + messageSignature + ); } + + return { message, messageSignature }; + } catch (e) { + const err = errorParse(e); + EventsStore.run(EventStoreEvents.onSignMsgFailure, message, err); + throw new Error(`Message signing failed! ${err}`); + } +}; + +/** + * Query Smart Contracts + */ +export const queryContract = async ({ + address, + func, + args = [], + value = 0, + caller, +}: SmartContractQueryArgs) => { + if (!config.networkProvider) { + throw new Error('Query failed: There is no active network provider!'); } - /** - * Main storage - */ - static storage = ls; - - /** - * Destroy and cleanup if needed - */ - static destroy = () => { - this.networkProvider = undefined; - this.dappProvider = undefined; - this.initOptions = undefined; - EventsStore.clear(); + if (!address || !func) { + throw new Error( + 'Query failed: The Query arguments are not valid! Address and func required' + ); + } + + const queryArgs = { + address, + func, + args, + value, + caller, }; -} + + try { + EventsStore.run(EventStoreEvents.onQueryStart, queryArgs); + const response = await config.networkProvider.queryContract(queryArgs); + EventsStore.run(EventStoreEvents.onQueryFinalized, response); + return response; + } catch (e) { + const err = errorParse(e); + EventsStore.run(EventStoreEvents.onQueryFinalized, queryArgs, err); + throw new Error(`Smart contract query failed! ${err}`); + } +}; + +/** + * Main storage + */ +export const storage = ls; + +/** + * Destroy and cleanup if needed + */ +export const destroy = () => { + resetConfig(); + EventsStore.clear(); +}; diff --git a/packages/elven.js/src/types.ts b/packages/elven.js/src/types.ts index d3d525a..2c2548b 100644 --- a/packages/elven.js/src/types.ts +++ b/packages/elven.js/src/types.ts @@ -11,7 +11,7 @@ import { Message } from './core/message'; import { TransactionsConverter } from './core/transaction-converter'; import { NetworkType } from './utils/constants'; import { LocalStorage } from './utils/ls-helpers'; -import { EventsStore } from './events-store'; +import * as EventsStore from './events-store'; export interface MobileSigningProviderConfig { walletConnectV2ProjectId: string; diff --git a/packages/elven.js/src/utils/with-login-events.ts b/packages/elven.js/src/utils/with-login-events.ts index 915d3bc..6eb393a 100644 --- a/packages/elven.js/src/utils/with-login-events.ts +++ b/packages/elven.js/src/utils/with-login-events.ts @@ -1,4 +1,4 @@ -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { errorParse } from './error-parse';